-
-
Notifications
You must be signed in to change notification settings - Fork 512
feat: ColorPicker #2478
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
feat: ColorPicker #2478
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
201578c
feat: enable compat
markjaniczak 057e447
feat: enable compat
markjaniczak dd0047d
chore: add dist artifacts
markjaniczak 5a05389
chore: add dist artifacts
markjaniczak 13e7e27
fix: fix accessibility label
markjaniczak 2cb0351
chore: build artifacts
markjaniczak 8eb42b9
fix: daterangepickerfield not resetting
markjaniczak c0a34a7
fix: do not prevent event on paste
markjaniczak 184d3e1
fix: do not prevent keydown if ctrl or meta key is held
markjaniczak 87d6ec4
fix: tags input
markjaniczak d40a951
feat: add open on focus option
markjaniczak 985517d
fix: revert
markjaniczak 89dfa61
fix: revert
markjaniczak f347278
fix: focus
markjaniczak 3c58eaa
fix: focus
markjaniczak ecfe93c
fix: focus
markjaniczak 8ddf1d0
feat: add copy paste function to date field input
markjaniczak 42a65e7
Merge branch 'feat/1897' into v2
markjaniczak 812dfad
chore: update artifacts
markjaniczak aade35b
feat: add to date range field
markjaniczak 23ed663
Merge branch 'feat/1897' into v2
markjaniczak 7b9538e
chore: update artifacts
markjaniczak c44f5d6
Merge remote-tracking branch 'upstream/v2' into v2
markjaniczak 1d78614
feat: add readonly to number field
markjaniczak 13ff72e
feat: add color swatches
markjaniczak 939adf2
feat: use radix colors
markjaniczak bd0be40
feat: update docs
markjaniczak 10f9912
feat: docs
markjaniczak fdd294a
feat: comments
markjaniczak 7495c92
feat: tests
markjaniczak a547d27
feat: change color picker colors
markjaniczak b4c081f
feat: docs
markjaniczak b317675
feat: utils
markjaniczak 4a16bc7
chore: remove console.log
markjaniczak 1920189
chore: remove console log
markjaniczak d4561b1
Merge remote-tracking branch 'upstream/v2' into v2
markjaniczak e202618
fix: build errors
markjaniczak 13c4ce1
chore: update build artifacts
markjaniczak 8a9a72f
chore: remove dist
markjaniczak 2e40589
chore: update gitignore
markjaniczak 942f417
Merge v2 into current branch
zernonia e4f9799
fix: handled coderabbit feedback
zernonia d7855fc
chore: position folder, add test
zernonia 3501023
revert: compatConfig
zernonia 3e9ab0c
revert: unneeded stuff
zernonia a465add
Merge remote-tracking branch 'origin/v2' into 501-feature-colorpicker
zernonia 670fbc8
revert: unneeded change
zernonia aa71c5b
feat: new ColorArea component
zernonia 93e918f
feat: new ColorField component
zernonia e30b2f7
feat: new ColorSlider component
zernonia 487b826
refactor: swatches component
zernonia 59e183f
feat: demos and shared function
zernonia 016f135
fix: adapt feedback
zernonia 248980b
docs: add color docs
zernonia cd80cc5
docs: update comments
zernonia 5581550
Merge remote-tracking branch 'origin/v2' into 501-feature-colorpicker
zernonia 6d05003
docs: chore gen
zernonia 5e5a4de
fix: quick test setup, feedback
zernonia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <script setup lang="ts"> | ||
| import { | ||
| ColorAreaArea, | ||
| ColorAreaRoot, | ||
| ColorAreaThumb, | ||
| } from 'reka-ui' | ||
| import { ref } from 'vue' | ||
|
|
||
| const color = ref('#ff0000') | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex flex-col gap-4"> | ||
| <div class="text-sm text-gray-600 dark:text-gray-400"> | ||
| Current: {{ color }} | ||
| </div> | ||
|
|
||
| <ColorAreaRoot | ||
| v-slot="{ style }" | ||
| v-model="color" | ||
| class="relative" | ||
| > | ||
| <ColorAreaArea | ||
| class="relative w-[200px] h-[200px] rounded-lg overflow-hidden focus:outline-none focus:ring-2 focus:ring-green-500" | ||
| :style="style" | ||
| > | ||
| <ColorAreaThumb class="block w-4 h-4 rounded-full bg-white border-2 border-gray-400 shadow cursor-pointer" /> | ||
| </ColorAreaArea> | ||
| </ColorAreaRoot> | ||
| </div> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <script setup lang="ts"> | ||
| import { | ||
| ColorFieldInput, | ||
| ColorFieldRoot, | ||
| } from 'reka-ui' | ||
| import { ref } from 'vue' | ||
|
|
||
| const color = ref('#3b82f6') | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex flex-col gap-3"> | ||
| <ColorFieldRoot | ||
| v-model="color" | ||
| class="inline-flex flex-col gap-1" | ||
| > | ||
| <label class="text-sm font-medium text-gray-900 dark:text-gray-100"> | ||
| Color | ||
| </label> | ||
| <div class="flex items-center gap-2"> | ||
| <div | ||
| class="w-8 h-8 rounded border border-gray-200 dark:border-gray-700 shrink-0" | ||
| :style="{ background: color }" | ||
| /> | ||
| <ColorFieldInput | ||
| class="px-3 py-2 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500 disabled:opacity-50 disabled:cursor-not-allowed w-32" | ||
| /> | ||
| </div> | ||
| </ColorFieldRoot> | ||
|
|
||
| <div class="flex items-center gap-2 text-xs text-gray-500"> | ||
| <span>Value: {{ color }}</span> | ||
| </div> | ||
| </div> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <script setup lang="ts"> | ||
| import { | ||
| ColorSliderRoot, | ||
| ColorSliderThumb, | ||
| ColorSliderTrack, | ||
| } from 'reka-ui' | ||
| import { ref } from 'vue' | ||
|
|
||
| const color = ref('#10b981') | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex flex-col gap-4"> | ||
| <ColorSliderRoot | ||
| v-model="color" | ||
| channel="hue" | ||
| class="relative flex items-center select-none touch-none w-[200px] h-5" | ||
| > | ||
| <ColorSliderTrack | ||
| class="relative flex-1 rounded-full h-3" | ||
| > | ||
| <div class="absolute inset-0 rounded-full" /> | ||
| </ColorSliderTrack> | ||
| <ColorSliderThumb | ||
| class="block w-5 h-5 rounded-full bg-white border-2 border-gray-400 shadow-lg cursor-pointer hover:scale-110 transition-transform focus:outline-none focus:ring-2 focus:ring-green-500" | ||
| /> | ||
| </ColorSliderRoot> | ||
|
|
||
| <div class="flex items-center gap-2 text-xs text-gray-500"> | ||
| <div | ||
| class="w-5 h-5 rounded border border-gray-200 shrink-0" | ||
| :style="{ background: color }" | ||
| /> | ||
| <span class="font-mono">{{ color }}</span> | ||
| </div> | ||
| </div> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <script setup lang="ts"> | ||
| import { green } from '@radix-ui/colors' | ||
| import { ColorSwatch } from 'reka-ui' | ||
| import './styles.css' | ||
| </script> | ||
|
|
||
| <template> | ||
| <ColorSwatch | ||
| :color="green.green9" | ||
| class="swatch" | ||
| /> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| .swatch { | ||
| width: 32px; | ||
| height: 32px; | ||
| border-radius: 4px; | ||
| box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| .dark .swatch { | ||
| box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <script setup lang="ts"> | ||
| import { green } from '@radix-ui/colors' | ||
| import { ColorSwatch } from 'reka-ui' | ||
| </script> | ||
|
|
||
| <template> | ||
| <ColorSwatch | ||
| :color="green.green9" | ||
| class="size-8 shrink-0 bg-[--reka-color-swatch-color] rounded ring-1 ring-inset ring-black/15 dark:ring-white/15" | ||
| /> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /** @type {import('tailwindcss').Config} */ | ||
| module.exports = { | ||
| content: ['./**/*.vue'], | ||
| theme: {}, | ||
| plugins: [], | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <script setup lang="ts"> | ||
| import { Icon } from '@iconify/vue' | ||
| import { | ||
| blue, | ||
| green, | ||
| orange, | ||
| pink, | ||
| red, | ||
| violet, | ||
| yellow, | ||
| } from '@radix-ui/colors' | ||
| import { ColorSwatchPickerItem, ColorSwatchPickerItemIndicator, ColorSwatchPickerItemSwatch, ColorSwatchPickerRoot } from 'reka-ui' | ||
| import './styles.css' | ||
|
|
||
| const colors = [ | ||
| red.red9, | ||
| pink.pink9, | ||
| violet.violet9, | ||
| blue.blue9, | ||
| green.green9, | ||
| orange.orange9, | ||
| yellow.yellow9, | ||
| ] | ||
| </script> | ||
|
|
||
| <template> | ||
| <ColorSwatchPickerRoot class="root"> | ||
| <ColorSwatchPickerItem | ||
| v-for="color in colors" | ||
| :key="color" | ||
| :value="color" | ||
| class="item" | ||
| > | ||
| <ColorSwatchPickerItemSwatch | ||
| class="swatch" | ||
| /> | ||
| <ColorSwatchPickerItemIndicator class="indicator"> | ||
| <Icon icon="radix-icons:check" /> | ||
| </ColorSwatchPickerItemIndicator> | ||
| </ColorSwatchPickerItem> | ||
| </ColorSwatchPickerRoot> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| .root { | ||
| display: flex; | ||
| gap: 8px; | ||
| } | ||
|
|
||
| .item { | ||
| position: relative; | ||
| } | ||
|
|
||
| .swatch { | ||
| height: 32px; | ||
| width: 32px; | ||
| border-radius: 4px; | ||
| box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); | ||
| flex-shrink: 0; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .dark .swatch { | ||
| box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); | ||
| } | ||
|
|
||
| .indicator { | ||
| position: absolute; | ||
| bottom: 4px; | ||
| right: 4px; | ||
| color: white; | ||
| } | ||
|
|
||
| .swatch[data-color-contrast='dark'] ~ .indicator { | ||
| color: black; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <script setup lang="ts"> | ||
| import { Icon } from '@iconify/vue' | ||
| import { | ||
| blue, | ||
| green, | ||
| indigo, | ||
| orange, | ||
| red, | ||
| violet, | ||
| yellow, | ||
| } from '@radix-ui/colors' | ||
| import { ColorSwatchPickerItem, ColorSwatchPickerItemIndicator, ColorSwatchPickerItemSwatch, ColorSwatchPickerRoot } from 'reka-ui' | ||
|
|
||
| const colors = [ | ||
| red.red9, | ||
| orange.orange9, | ||
| yellow.yellow9, | ||
| green.green9, | ||
| blue.blue9, | ||
| indigo.indigo9, | ||
| violet.violet9, | ||
| ] | ||
| </script> | ||
|
|
||
| <template> | ||
| <ColorSwatchPickerRoot class="flex gap-2"> | ||
| <ColorSwatchPickerItem | ||
| v-for="color in colors" | ||
| :key="color" | ||
| :value="color" | ||
| class="relative" | ||
| > | ||
| <ColorSwatchPickerItemSwatch | ||
| class="size-8 rounded ring-1 ring-inset ring-black/15 dark:ring-white/15 bg-[--reka-color-swatch-color] peer" | ||
| /> | ||
| <ColorSwatchPickerItemIndicator class="text-white peer-data-[color-contrast=dark]:text-black absolute right-1 bottom-1"> | ||
| <Icon icon="radix-icons:check" /> | ||
| </ColorSwatchPickerItemIndicator> | ||
| </ColorSwatchPickerItem> | ||
| </ColorSwatchPickerRoot> | ||
| </template> |
6 changes: 6 additions & 0 deletions
6
docs/components/demo/ColorSwatchPicker/tailwind/tailwind.config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /** @type {import('tailwindcss').Config} */ | ||
| module.exports = { | ||
| content: ['./**/*.vue'], | ||
| theme: {}, | ||
| plugins: [], | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.