https://github.com/9am/ctrl-panel
A simple control panel. 🎚🎛🕹
https://github.com/9am/ctrl-panel
clamp color control ctrl group input knob panel radio range slider switch text vector web-components
Last synced: 24 days ago
JSON representation
A simple control panel. 🎚🎛🕹
- Host: GitHub
- URL: https://github.com/9am/ctrl-panel
- Owner: 9am
- License: mit
- Created: 2022-11-11T03:13:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-24T10:03:49.000Z (about 2 years ago)
- Last Synced: 2025-05-08T00:02:27.664Z (24 days ago)
- Topics: clamp, color, control, ctrl, group, input, knob, panel, radio, range, slider, switch, text, vector, web-components
- Language: TypeScript
- Homepage: https://9am.github.io/ctrl-panel/
- Size: 177 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
---
## Why Build This
See my blog post on [9am.github.io](https://9am.github.io/)
> [Every Animation Lover Needs A Control Panel](https://github.com/9am/9am.github.io/issues/10)## 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
| Element | Screenshot | Varient | Description | Live Demo |
| ------- | ---------- | ------- | ----------- | --------- |
| ctrl-panel | ------- | ------- | The root element. | [demo](http://9am.github.io/ctrl-panel/ctrl-panel.html) |
| ctrl-group | ------- | ------- | Group ctrl-* together to shape the value. | [demo](http://9am.github.io/ctrl-panel/ctrl-group.html) |
| ctrl-slider |  |  | A numblic slider. | [demo](http://9am.github.io/ctrl-panel/ctrl-slider.html) |
| ctrl-clamp |  |  | Select a tuple low-high value. | [demo](http://9am.github.io/ctrl-panel/ctrl-clamp.html) |
| ctrl-switch |  |  | A ON/OFF switch. | [demo](http://9am.github.io/ctrl-panel/ctrl-switch.html) |
| ctrl-radio |  |  | Multiple/Single switch. | [demo](http://9am.github.io/ctrl-panel/ctrl-radio.html) |
| ctrl-vector |  | | Select a tuple vector on a 2D surface. | [demo](http://9am.github.io/ctrl-panel/ctrl-vector.html) |
| ctrl-text |  | | Text input. | [demo](http://9am.github.io/ctrl-panel/ctrl-text.html) |
| ctrl-color |  | | Color picker. | [demo](http://9am.github.io/ctrl-panel/ctrl-color.html) |## Usage
#### Install
```bash
npm install @9am/ctrl-panel
```#### HTML
```htmlslider
clamp
vector
switch
A
B
C
text
color
```
#### Javascript
```js
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
### \
| Doc | Name | Type | Default | Description |
| --- | ---- | ---- | ------- | ----------- |
| attribute | **`name*`** | string | **required** | value key |
| attribute | **`orientation`** | h \| v | `h` | layout direction |
| attribute | **`type`** | object \| array | `object` | value shape |
| ---- | | | | |
| property | get **`value`** | Value | `{}` | value |
| ---- | | | | |
| slot | **`label`** | html tag | | label |
| slot | **`default`** | ctrl-* | `''` | value |### \
| Doc | Name | Type | Default | Description |
| --- | ---- | ---- | ------- | ----------- |
| attribute | `extends ` | ---- | ---- | ---- |
| attribute | **`theme`** | string | `flat` | theme (flat \| oldschool \| neumorphism) |
| attribute | **`width`** | css length | `auto` | panel width |
| attribute | **`height`** | css length | `auto` | panel height |
| attribute | **`placement`** | top-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. |
| ---- | | | | |
| property | `extends ` | ---- | ---- | ---- |
| ---- | | | | |
| slot | `extends ` | ---- | ---- | ---- |### \
| Doc | Name | Type | Default | Description |
| --- | ---- | ---- | ------- | ----------- |
| attribute | `extends ` | ---- | ---- | ---- |
| attribute | **`multiple`** | boolean | `false` | enable select multiple items |
| ---- | | | | |
| property | `extends ` | ---- | ---- | ---- |
| ---- | | | | |
| slot | `extends ` | ---- | ---- | ---- |
| slot | **`default`** | `ctrl-switch` | `''` | value |### \
| Doc | Name | Type | Default | Description |
| --- | ---- | ---- | ------- | ----------- |
| attribute | **`name*`** | string | **required** | value key |
| attribute | **`orientation`** | h \| v | `h` | layout direction |
| attribute | **`type`** | range \| knob | `range` | slider type |
| attribute | **`min`** | number | `0` | min value |
| attribute | **`max`** | number | `10` | max value |
| attribute | **`step`** | number \| 'any' | `1` | step interval |
| attribute | **`default`** | number | `5` | default value |
| ---- | | | | |
| property | get **`value`** | number | `5` | value |### \
| Doc | Name | Type | Default | Description |
| --- | ---- | ---- | ------- | ----------- |
| attribute | `extends ` | ---- | ---- | ---- |
| attribute | **`default`** | string(JSON) | `'[0,10]'` | default value |
| ---- | | | | |
| property | `extends ` | ---- | ---- | ---- |
| property | get **`value`** | number | `[0,10]` | value |
| ---- | | | | |
| slot | `extends ` | ---- | ---- | ---- |### \
| Doc | Name | Type | Default | Description |
| --- | ---- | ---- | ------- | ----------- |
| attribute | **`name*`** | string | **required** | value key |
| attribute | **`orientation`** | h \| v | `h` | layout direction |
| attribute | **`type`** | range \| toggle | `toggle` | slider type |
| attribute | **`default`** | boolean | | default value |
| ---- | | | | |
| property | get **`value`** | number | `false` | value |### \
| Doc | Name | Type | Default | Description |
| --- | ---- | ---- | ------- | ----------- |
| attribute | **`name*`** | string | **required** | value key |
| attribute | **`default`** | string | `''` | default value |
| ---- | | | | |
| property | get **`value`** | number | `''` | value |### \
| Doc | Name | Type | Default | Description |
| --- | ---- | ---- | ------- | ----------- |
| attribute | **`name*`** | string | **required** | value key |
| attribute | **`orientation`** | h \| v | `h` | layout direction |
| attribute | **`default`** | string | `#000000` | default value |
| ---- | | | | |
| property | get **`value`** | number | `#000000` | value |### Event
```js
{
type: 'CHANGE',
detail: {
name: string, // attribute 'name' of
value: Value, // property 'value' of
}
}
```## License
[MIT](LICENSE)