Skip to content

Commit

Permalink
v0.3.0 (#4)
Browse files Browse the repository at this point in the history
* add web component export

* improve readme

* add more options + changelog

* fix color conversion

* v0.3.0

* cleanup actions

* Update .mergify.yml
  • Loading branch information
adrianjost authored Nov 30, 2019
1 parent 33e20d3 commit c9aa548
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 87 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/lint.yml

This file was deleted.

26 changes: 13 additions & 13 deletions .github/workflows/npm-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install
run: |
npm ci
- name: Build
run: |
npm run build
- name: Publish
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > .npmrc
npm publish || true
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- uses: actions/checkout@v1
- name: Install
run: |
npm ci
- name: Build
run: |
npm run build
- name: Publish
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > .npmrc
npm publish || true
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/push-process-todo-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
uses: dtinth/todo-actions@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TODO_ACTIONS_MONGO_URL: ${{ secrets.TODO_ACTIONS_MONGO_URL }}
TODO_ACTIONS_MONGO_URL: ${{ secrets.TODO_ACTIONS_MONGO_URL }}
25 changes: 25 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Push

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install
run: |
npm ci
- name: Lint
run: |
npm run lint
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install
run: |
npm ci
- name: Build
run: |
npm run build
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pull_request_rules:
conditions:
- author=greenkeeper[bot]
- label~=greenkeeper
- status-success~=Lint
- status-success~=Push
- status-success~=WIP
actions:
merge:
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 0.3.0

**Additions**

- add native WebComponents support including attribute type conversion.

**Changes**

- added `options` attribute where all options (`colorLeft`, `colorRight`, ...) now must be placed in. The old Attributes were removed.

# 0.2.0

**Fixes**

- channel value `[1,1]` was not reachable. The top center value is therefore now `[1,1]`

# 0.1.0

- Initial Release, may be buggy, unstable and not ready for production until version 1.0.0 is reached.
97 changes: 78 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@

> A simple two channel Color Picker
![two channel picker screenshot](docs/img/screenshot.png)
## About

I needed an intuitive color picker to control my warm-white-cold-white (WWCW) LED Strips with the [SmartLight Project](https://github.com/adrianjost/SmartLight-Web-Client).

<p align="center">
<img src="docs/img/screenshot.png" alt="two channel picker screenshot" style="max-width: 300px;">
</p>

The picker value is therefore indepent from the displayed color. The given value is a number between 0 and 1 for each of the two channels. The brightness can be determined by dragging the slider along the Y-axis. Dragging along the X-axis changes the relationship between the two channels.

<p align="center">
<img src="docs/img/values.png" align="center" alt="two channel picker screenshot" style="max-width: 500px;">
</p>

## Usage

### 1. Install
### Vue

Install the package:

```bash
npm i @adrianjost/two-channel-picker
Expand All @@ -18,29 +32,74 @@ or
yarn add @adrianjost/two-channel-picker
```

### 2. Usage in Component (Vue)
In your App:

```vue
<template>
<TwoChannelPicker
v-model="channels"
colorLeft="#f00"
colorRight="#00f"
/>
<TwoChannelPicker v-model="channels" colorLeft="#fd9" colorRight="#9df" />
</template>
<script>
import TwoChannelPicker from "@adrianjost/two-channel-picker"
import TwoChannelPicker from "@adrianjost/two-channel-picker";
export default {
components: {
TwoChannelPicker
},
data(){
return {
channels: [0, 1]
}
}
}
components: {
TwoChannelPicker,
},
data() {
return {
channels: [0, 1],
};
},
};
</script>
```

### As a native Web Component

```html
<script src="https://cdn.jsdelivr.net/npm/@adrianjost/[email protected]/dist/wc/two-channel-picker.min.js"></script>

<div style="width: 300px; height: 300px;">
<two-channel-picker
value="[0,1]"
id="picker"
options='{"colorLeft": "#f00", "colorRight": "#00f" }'
></two-channel-picker>
</div>

<script>
document.getElementById("picker").addEventListener("input", (event) => {
console.log(event.detail[0]);
});
</script>
```
```

> please note, that you may need to adjust the version number in the url.
## API

### Props

You can customize the picker with the following props/attributes.

> When using the lib as a web component you must provide all attributes `JSON.stringify()`-ed.
| attribute | type | default value | description |
| --- | --- | --- | --- |
| `value` / `v-model` | Array, String | `[1,0]` | the current channel values, if provided as a String, this must be `JSON.parse()`-able |
| `options` | Object | `{}` | all your config goes in here |

#### Options

Available Attributes in the `options` prop:

| attribute | type | default value | description |
| --- | --- | --- | --- |
| `readOnly` | Boolean | `false` | should the user be able to move the marker? |
| `colorLeft` | String | `#fd9` | the color in the top left corner. Must be in the HEX Format with 3 or 6 digits. |
| `colorRight` | String | `#fd9` | the color in the top right corner. Must be in the HEX Format with 3 or 6 digits. |
| `marker.borderWidth` | Number | `2` | The border width of the active marker in px. |
| `marker.radius` | Number | `16` | The border radius including the borderWidth in px. |

You need more options? Please open an issue and I will do my best to implement it. Pull Requests are also welcome!
Binary file modified docs/img/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"name": "@adrianjost/two-channel-picker",
"version": "0.2.0",
"version": "0.3.0",
"author": "Adrian Jost <[email protected]> (https://adrianjost.dev)",
"scripts": {
"lint": "vue-cli-service lint",
"build": "vue-cli-service build --target lib --name TwoChannelPicker ./src/TwoChannelPicker.vue --mode production --dest dist/lib",
"build:vue": "vue-cli-service build --target lib --name TwoChannelPicker ./src/TwoChannelPicker.vue --mode production --dest dist/lib",
"build:wc": "vue-cli-service build --target wc --inline-vue --name two-channel-picker ./src/TwoChannelPicker.vue --dest dist/wc",
"build": "run-p build:*",
"dev": "vue-cli-service serve"
},
"dependencies": {
"peerDependencies": {
"vue": "^2.6.10"
},
"devDependencies": {
"vue": "^2.6.10",
"@vue/cli-plugin-babel": "^3.7.0",
"@vue/cli-plugin-eslint": "^3.8.0",
"@vue/cli-service": "^4.0.0",
Expand Down Expand Up @@ -39,7 +42,10 @@
"last 2 versions"
],
"files": [
"dist/lib/*"
"dist/*",
"docs/*",
"LICENSE",
"README.md"
],
"gitHooks": {
"pre-commit": "lint-staged"
Expand Down
2 changes: 1 addition & 1 deletion src/Dev.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="wrapper">
<h1> {{ formatedValue }} </h1>
<Picker v-model="value" class="picker" />
<Picker v-model="value" :options="{ colorLeft: '#f00' }" class="picker" />
</div>
</template>

Expand Down
Loading

0 comments on commit c9aa548

Please sign in to comment.