Skip to content

Color picker #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
245957a
Initial commit
bjarnef Aug 3, 2022
02fa235
Add color swatch
bjarnef Aug 3, 2022
910aeb9
Use Colord library instead
bjarnef Aug 8, 2022
c738638
Merge branch 'v1/dev' of https://github.com/umbraco/Umbraco.UI into v…
bjarnef Aug 8, 2022
92443d8
Update pacage-lock.json
bjarnef Aug 8, 2022
4a1ca79
Make slider vertical
bjarnef Aug 8, 2022
2e230b5
Merge branch 'v1/dev' into v1/feature/color-picker
bjarnef Aug 8, 2022
da0bb0e
Make transparent background
bjarnef Aug 9, 2022
6f389c7
Merge branch 'v1/feature/color-picker' of https://github.com/bjarnef/…
bjarnef Aug 9, 2022
d9c0008
Update Colord type
bjarnef Aug 9, 2022
8e37f35
Adjust events in color picker components
bjarnef Aug 9, 2022
e848210
Merge branch 'v1/dev' into v1/feature/color-picker
bjarnef Aug 10, 2022
decc694
Update inline picker
bjarnef Aug 10, 2022
c9c6147
Update complete
bjarnef Aug 10, 2022
564eddd
Merge branch 'v1/dev' into v1/feature/color-picker
bjarnef Aug 10, 2022
8ef6ac3
Merge branch 'v1/dev' into v1/feature/color-picker
bjarnef Aug 11, 2022
1ea9c0d
Merge branch 'v1/dev' into v1/feature/color-picker
bjarnef Aug 11, 2022
8cb4b87
Merge branch 'v1/dev' into v1/feature/color-picker
bjarnef Aug 12, 2022
130cf13
Merge branch 'v1/dev' into v1/feature/color-picker
bjarnef Aug 15, 2022
2dc3d94
Update HSB spectrum when hue change
bjarnef Aug 16, 2022
cfc8d9c
Merge branch 'v1/feature/color-picker' of https://github.com/bjarnef/…
bjarnef Aug 16, 2022
7d759f3
Update value
bjarnef Aug 16, 2022
23153e8
Adjust hue change
bjarnef Aug 16, 2022
d59c308
Update brightness
bjarnef Aug 16, 2022
a56cbbc
Make selection of color swatches working
bjarnef Aug 19, 2022
3e35f0d
Outout value
bjarnef Aug 19, 2022
211f00a
Update single color swatch story
bjarnef Aug 19, 2022
e206638
Include names plugin from Colord
bjarnef Aug 19, 2022
beb9ba8
update uui-base dependecy to latest rc3
madsrasmussen Sep 8, 2022
bdb81bc
Merge branch 'v1/contrib' of https://github.com/umbraco/Umbraco.UI in…
bjarnef Oct 11, 2022
70220c4
Update package lock
bjarnef Oct 11, 2022
7293447
Update package lock
bjarnef Oct 11, 2022
ce8380b
Update import of utils
bjarnef Oct 11, 2022
bdc046b
Merge branch 'v1/dev' into v1/feature/color-picker
bjarnef Oct 12, 2022
18097f1
update reference to uui-base to avoid clash in main package-lock
iOvergaard Oct 13, 2022
3c41360
Adjust color picker to use popover as default
bjarnef Oct 14, 2022
3489199
Adjust selected checkmark and color picker popover
bjarnef Oct 14, 2022
bda620e
Add example of transparent colors
bjarnef Oct 14, 2022
e303872
Move button trigger outside popover so it is closed when clicking nex…
bjarnef Oct 14, 2022
792adf9
Adjust preview and trigger buttons
bjarnef Oct 14, 2022
ffb7e97
Accessibility
bjarnef Oct 15, 2022
bcab926
Adjust copy color from preview button
bjarnef Oct 15, 2022
72d7f05
Update keyboard selection in color area
bjarnef Oct 15, 2022
2766377
Update story
bjarnef Oct 15, 2022
05c721a
Update keyboard selection on slider handle
bjarnef Oct 15, 2022
d62a56f
Add slot for inner color hue gradient
bjarnef Oct 19, 2022
01b3513
Close popover when pressing esc key
bjarnef Oct 25, 2022
194a7be
Modify selection
bjarnef Nov 22, 2022
4315e91
Merge branch 'v1/dev' of https://github.com/umbraco/Umbraco.UI into v…
bjarnef Nov 22, 2022
4cffcf7
Simplify clamp function
bjarnef Nov 22, 2022
454f8a0
Update package-lock
bjarnef Nov 22, 2022
89cfd7f
Use rem instead
bjarnef Nov 22, 2022
a4cdc3c
Use regular button element for preview color
bjarnef Nov 22, 2022
9920d2c
Cleanup
bjarnef Nov 22, 2022
1df08f6
Update package-lock
bjarnef Nov 22, 2022
87b38d8
Uppercase text
bjarnef Nov 22, 2022
d2e52a6
Update button style
bjarnef Nov 22, 2022
ec6b8ec
update package-lock to latest
iOvergaard Nov 23, 2022
b7ae5cb
update to new mjs import
iOvergaard Nov 23, 2022
5e3057c
add dependency between color-swatches and color-swatch
iOvergaard Nov 23, 2022
0cb44c8
add dependency between color-swatch and icon-registry-essential
iOvergaard Nov 23, 2022
3bf415a
update package-lock
iOvergaard Nov 23, 2022
fd89099
add dependency of colord to color packages and mark as external
iOvergaard Nov 23, 2022
8542510
remove duplicate class
iOvergaard Nov 23, 2022
6f19c71
add demand for uui-color-swatch
iOvergaard Nov 23, 2022
a98dd73
Adjust button elements
bjarnef Nov 25, 2022
6936278
Adjust styling of sliders
bjarnef Nov 25, 2022
4b3a1d7
Adjust color area sizing
bjarnef Nov 25, 2022
f67ae6f
Use vertical attribute for slider
bjarnef Nov 26, 2022
7d7a52b
Make handle in color area update when selecting color from palette
bjarnef Nov 26, 2022
3337666
Focus and selection of swatches
bjarnef Nov 26, 2022
0f3a71c
Set initial value on color area
bjarnef Nov 26, 2022
7ddb3b8
Adjust styling
bjarnef Nov 27, 2022
38ad1e0
Adjust text transform of button
bjarnef Nov 27, 2022
2db0042
Adjust story with format
bjarnef Nov 27, 2022
b981cce
Merge remote-tracking branch 'origin/v1/contrib' into pr/bjarnef/280
iOvergaard Jan 6, 2023
e16cde6
add internal deps between uui --> color*
iOvergaard Jan 6, 2023
a755e6f
auto-generate new tsconfig
iOvergaard Jan 6, 2023
138573a
fix lint warning for a11y keydown on slider
iOvergaard Jan 6, 2023
44ac15c
add support for ArrowUp and ArrowDown with vertical on/off
iOvergaard Jan 6, 2023
d124d87
fix eslint errors
iOvergaard Jan 6, 2023
94580eb
add support for storybook controls for uui-color-slider
iOvergaard Jan 6, 2023
a017221
uui-color-area: add support for disabled state
iOvergaard Jan 6, 2023
b24bed9
uui-color-area: add support for storybook controls
iOvergaard Jan 6, 2023
537fbf6
add correct storybook category
iOvergaard Jan 6, 2023
8862e3a
uui-color-swatches: add default slot to support lightdom swatches
iOvergaard Jan 6, 2023
1e4eb02
uui-color-picker: dispatch a change event on update
iOvergaard Jan 6, 2023
5c24128
uui-color-picker: add support for controls and actions on storybook
iOvergaard Jan 6, 2023
c3d3ccf
run formatting
iOvergaard Jan 6, 2023
85bd4c2
update main README
iOvergaard Jan 6, 2023
43b3dea
Merge branch 'v1/contrib' into v1/feature/color-picker
iOvergaard Jan 6, 2023
ab4a208
fix a11y tests
iOvergaard Jan 6, 2023
ce439df
Merge branch 'v1/contrib' into pr/bjarnef/280
iOvergaard Jan 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ If you want to develop a component or contribute to the repository go to ["Get s
| [`<uui-card-user>`](packages/uui-card-user) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-card-user?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-card-user) |
| [`<uui-caret>`](packages/uui-caret) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-caret?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-caret) |
| [`<uui-checkbox>`](packages/uui-checkbox) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-checkbox?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-checkbox) |
| [`<uui-color-area>`](packages/uui-color-area) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-color-area?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-color-area) |
| [`<uui-color-picker>`](packages/uui-color-picker) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-color-picker?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-color-picker) |
| [`<uui-color-slider>`](packages/uui-color-slider) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-color-slider?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-color-slider) |
| [`<uui-color-swatch>`](packages/uui-color-swatch) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-color-swatch?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-color-swatch) |
| [`<uui-color-swatches>`](packages/uui-color-swatches) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-color-swatches?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-color-swatches) |
| [`<uui-combobox>`](packages/uui-combobox) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-combobox?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-combobox) |
| [`<uui-combobox-list>`](packages/uui-combobox-list) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-combobox-list?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-combobox-list) |
| [`<uui-dialog>`](packages/uui-dialog) | [![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-dialog?logoColor=%231B264F)](https://www.npmjs.com/package/@umbraco-ui/uui-dialog) |
Expand Down
129 changes: 115 additions & 14 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"autoprefixer": "10.4.11",
"babel-loader": "9.1.0",
"chromatic": "6.11.4",
"colord": "2.9.3",
"element-internals-polyfill": "1.1.14",
"eslint": "8.24.0",
"eslint-config-prettier": "8.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/rollup-package.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const createEsModulesConfig = (entryPoints = []) => {
file: `./lib/${name}.js`,
format: 'es',
},
external: [/^lit/, /^@umbraco-ui/],
external: [/^lit/, /^@umbraco-ui/, /^colord/],
plugins: [
importCss({ from: undefined }),
esbuild(),
Expand Down
47 changes: 47 additions & 0 deletions packages/uui-base/lib/utils/drag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
interface DragOptions {
/** Callback that runs as dragging occurs. */
onMove: (x: number, y: number) => void;
/** Callback that runs when dragging stops. */
onStop: () => void;
/**
* When an initial event is passed, the first drag will be triggered immediately using the coordinates therein. This
* is useful when the drag is initiated by a mousedown/touchstart event but you want the initial "click" to activate
* a drag (e.g. positioning a handle initially at the click target).
*/
initialEvent: PointerEvent;
}

export const drag = (
container: HTMLElement,
options?: Partial<DragOptions>
) => {
function move(pointerEvent: PointerEvent) {
const dims = container.getBoundingClientRect();
const defaultView = container.ownerDocument.defaultView!;
const offsetX = dims.left + defaultView.pageXOffset;
const offsetY = dims.top + defaultView.pageYOffset;
const x = pointerEvent.pageX - offsetX;
const y = pointerEvent.pageY - offsetY;

if (options?.onMove) {
options.onMove(x, y);
}
}

function stop() {
document.removeEventListener('pointermove', move);
document.removeEventListener('pointerup', stop);

if (options?.onStop) {
options.onStop();
}
}

document.addEventListener('pointermove', move, { passive: true });
document.addEventListener('pointerup', stop);

// If an initial event is set, trigger the first drag immediately
if (options?.initialEvent) {
move(options.initialEvent);
}
};
2 changes: 2 additions & 0 deletions packages/uui-base/lib/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from './Timer';
export * from './demandCustomElement';
export * from './drag';
export * from './math';
6 changes: 6 additions & 0 deletions packages/uui-base/lib/utils/math.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//
// Ensures a number stays within a minimum and maximum value
//
export const clamp = (value: number, min: number, max: number) => {
return Math.min(Math.max(value, min), max);
};
31 changes: 31 additions & 0 deletions packages/uui-color-area/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# uui-color-area

![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-color-area?logoColor=%231B264F)

Umbraco style color-area component.

## Installation

### ES imports

```zsh
npm i @umbraco-ui/uui-color-area
```

Import the registration of `<uui-color-area>` via:

```javascript
import '@umbraco-ui/uui-color-area';
```

When looking to leverage the `UUIColorAreaElement` base class as a type and/or for extension purposes, do so via:

```javascript
import { UUIColorAreaElement } from '@umbraco-ui/uui-color-area';
```

## Usage

```html
<uui-color-area></uui-color-area>
```
6 changes: 6 additions & 0 deletions packages/uui-color-area/lib/UUIColorAreaEvents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
import { UUIColorAreaElement } from './uui-color-area.element';

export class UUIColorAreaEvent extends UUIEvent<{}, UUIColorAreaElement> {
public static readonly CHANGE = 'change';
}
2 changes: 2 additions & 0 deletions packages/uui-color-area/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './uui-color-area.element';
export * from './UUIColorAreaEvents';
Loading