New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@9am/ctrl-panel

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@9am/ctrl-panel

A simple control panel.

latest
Source
npmnpm
Version
1.3.1
Version published
Maintainers
1
Created
Source
ctrl-panel

<ctrl-panel>

A simple control panel.

GitHub npm npm npm bundle size

Why Build This

See my blog post on 9am.github.io

Every Animation Lover Needs A Control Panel

Features

  • 9 custom elements to choose.
  • 3 themes out of the box.
  • Control the value shape with the template.
  • Customize or make your own theme with CSS properties.

Elements

ElementScreenshotVarientDescriptionLive Demo
ctrl-panel--------------The root element.demo
ctrl-group--------------Group ctrl-* together to shape the value.demo
ctrl-sliderslider-1slider-2A numblic slider.demo
ctrl-clampclamp-1clamp-2Select a tuple low-high value.demo
ctrl-switchswitch-1switch-2A ON/OFF switch.demo
ctrl-radioradio-1radio-2Multiple/Single switch.demo
ctrl-vectorvectorSelect a tuple vector on a 2D surface.demo
ctrl-texttextText input.demo
ctrl-colorcolorColor picker.demo

Usage

Install

npm install @9am/ctrl-panel

HTML

<ctrl-panel theme="neumorphism">
    <ctrl-slider name="slider">slider</ctrl-slider>
    <ctrl-clamp name="clamp">clamp</ctrl-clamp>
    <ctrl-vector name="vector">vector</ctrl-vector>
    <ctrl-switch name="switch">switch</ctrl-switch>
    <ctrl-radio name="radio">
        <ctrl-switch name="a">A</ctrl-switch>
        <ctrl-switch name="b">B</ctrl-switch>
        <ctrl-switch name="c" default="true">C</ctrl-switch>
    </ctrl-radio>
    <ctrl-group name="group">
        <ctrl-text name="text">text</ctrl-text>
        <ctrl-color name="color">color</ctrl-color>
    </ctrl-group>
</ctrl-panel>

Javascript

import '@9am/ctrl-panel';
// import '@9am/ctrl-panel/theme.css'; // css to enable default themes.

document.querySelector('ctrl-panel').addEventListener('CHANGE', (evt) => {
    console.log('[panel value]:', evt.currentTarget.value);
    /* output:
     * {
     *     slider: 5,
     *     clamp: [0, 10],
     *     vector: [0, 0],
     *     switch: false,
     *     radio: 'c',
     *     group: {
     *         text: '',
     *         color: '#000000'
     *     }
     * }
     */
});

Documentation

<ctrl-group>

DocNameTypeDefaultDescription
attributename*stringrequiredvalue key
attributeorientationh | vhlayout direction
attributetypeobject | arrayobjectvalue shape
----
propertyget valueValue{}value
----
slotlabelhtml taglabel
slotdefaultctrl-*''value

<ctrl-panel>

DocNameTypeDefaultDescription
attributeextends <ctrl-group>------------
attributethemestringflattheme (flat | oldschool | neumorphism)
attributewidthcss lengthautopanel width
attributeheightcss lengthautopanel height
attributeplacementtop-left | top-right | bottom-left | bottom-right''if placement is set, panel will be positioned as fixed, and with a button to toggle the visibility.
----
propertyextends <ctrl-group>------------
----
slotextends <ctrl-group>------------

<ctrl-radio>

DocNameTypeDefaultDescription
attributeextends <ctrl-group>------------
attributemultiplebooleanfalseenable select multiple items
----
propertyextends <ctrl-group>------------
----
slotextends <ctrl-group>------------
slotdefaultctrl-switch''value

<ctrl-slider>

DocNameTypeDefaultDescription
attributename*stringrequiredvalue key
attributeorientationh | vhlayout direction
attributetyperange | knobrangeslider type
attributeminnumber0min value
attributemaxnumber10max value
attributestepnumber | 'any'1step interval
attributedefaultnumber5default value
----
propertyget valuenumber5value

<ctrl-clamp>

DocNameTypeDefaultDescription
attributeextends <ctrl-slider>------------
attributedefaultstring(JSON)'[0,10]'default value
----
propertyextends <ctrl-slider>------------
propertyget valuenumber[0,10]value
----
slotextends <ctrl-slider>------------

<ctrl-switch>

DocNameTypeDefaultDescription
attributename*stringrequiredvalue key
attributeorientationh | vhlayout direction
attributetyperange | toggletoggleslider type
attributedefaultbooleandefault value
----
propertyget valuenumberfalsevalue

<ctrl-text>

DocNameTypeDefaultDescription
attributename*stringrequiredvalue key
attributedefaultstring''default value
----
propertyget valuenumber''value

<ctrl-color>

DocNameTypeDefaultDescription
attributename*stringrequiredvalue key
attributeorientationh | vhlayout direction
attributedefaultstring#000000default value
----
propertyget valuenumber#000000value

Event

{
  type: 'CHANGE',
  detail: {
    name: string, // attribute 'name' of <ctrl-*>
    value: Value, // property 'value' of <ctrl-*>
  }
}

License

MIT

Keywords

ctrl-panel

FAQs

Package last updated on 24 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts