Skip to content

Commit

Permalink
Fix how the changeTo label is overriden (related to #65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ennoriel committed Jan 26, 2024
1 parent a2277bd commit 973043f
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 53 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# svelte-awesome-color-picker

## 3.0.4

### Patch Changes

- Fix how the changeTo label is overriden (related to #65)

## 3.0.3

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svelte-awesome-color-picker",
"version": "3.0.3",
"version": "3.0.4",
"description": "A highly customizable color picker component library",
"homepage": "https://svelte-awesome-color-picker.vercel.app",
"repository": {
Expand Down Expand Up @@ -68,4 +68,4 @@
"svelte",
"color picker"
]
}
}
10 changes: 5 additions & 5 deletions src/lib/components/ColorPicker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@
/** required WCAG contrast level */
export let a11yLevel: 'AA' | 'AAA' = 'AA';
/** all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/texts.ts) */
/** all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/utils/texts.ts) */
export let texts: TextsPartial | undefined = undefined;
/** all a11y translation tokens used in the library; override with translations if necessary; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/texts.ts) */
/** all a11y translation tokens used in the library; override with translations if necessary; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/utils/texts.ts) */
export let a11yTexts: A11yTextsPartial | undefined = undefined;
/**
Expand Down Expand Up @@ -122,7 +122,7 @@
...defaultTexts.color,
...texts?.color
},
changeTo: defaultTexts.changeTo ?? texts?.changeTo
changeTo: texts?.changeTo ?? defaultTexts.changeTo
};
}
Expand Down Expand Up @@ -367,8 +367,8 @@ import ColorPicker from 'svelte-awesome-color-picker';
@prop disableCloseClickOutside: boolean = false — If set to true, it will not be possible to close the color picker by clicking outside
@prop a11yColors: Array<A11yColor> = [{ bgHex: '#ffffff' }] — used with the A11yVariant. Define the accessibility examples in the color picker
@prop a11yLevel: 'AA' | 'AAA' = 'AA' — required WCAG contrast level
@prop texts: TextsPartial | undefined = undefined — all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/texts.ts)
@prop a11yTexts: A11yTextsPartial | undefined = undefined — all a11y translation tokens used in the library; override with translations if necessary; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/texts.ts)
@prop texts: TextsPartial | undefined = undefined — all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/utils/texts.ts)
@prop a11yTexts: A11yTextsPartial | undefined = undefined — all a11y translation tokens used in the library; override with translations if necessary; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/utils/texts.ts)
-->
<style>
span {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/variant/accessibility/A11yNotice.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/** required WCAG contrast level */
export let a11yLevel: 'AA' | 'AAA';
/** all a11y translation tokens used in the library; override with translations if necessary; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/texts.ts) */
/** all a11y translation tokens used in the library; override with translations if necessary; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/utils/texts.ts) */
export let a11yTexts: A11yTextsPartial | undefined = undefined;
extend([a11yPlugin]);
Expand Down Expand Up @@ -79,7 +79,7 @@ import { A11yVariant } from 'svelte-awesome-color-picker';
@prop hex: string — hex color
@prop a11yColors: Array&lt;A11yColor&gt; — define the accessibility examples in the color picker
@prop a11yLevel: 'AA' | 'AAA' — required WCAG contrast level
@prop a11yTexts: A11yTextsPartial | undefined = undefined — all a11y translation tokens used in the library; override with translations if necessary; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/texts.ts)
@prop a11yTexts: A11yTextsPartial | undefined = undefined — all a11y translation tokens used in the library; override with translations if necessary; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/utils/texts.ts)
-->
<style>
.a11y-notice {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/** whether the color picker is undefined */
export let isUndefined: boolean;
/** all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/texts.ts) */
/** all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/utils/texts.ts) */
export let texts: Texts;
</script>

Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/variant/default/TextInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/** configure which hex, rgb and hsv inputs will be visible and in which order. If overridden, it is necessary to provide at least one value */
export let textInputModes: Array<'hex' | 'rgb' | 'hsv'>;
/** all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/texts.ts) */
/** all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/utils/texts.ts) */
export let texts: Texts;
const HEX_COLOR_REGEX = /^#?([A-F0-9]{6}|[A-F0-9]{8})$/i;
Expand Down Expand Up @@ -109,7 +109,7 @@ _N.A._
@prop hsv: HsvaColor — hsv color
@prop hex: string — hex color
@prop textInputModes: Array&lt;'hex' | 'rgb' | 'hsv'&gt; — configure which hex, rgb and hsv inputs will be visible and in which order. If overridden, it is necessary to provide at least one value
@prop texts: Texts — all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/texts.ts)
@prop texts: Texts — all translation tokens used in the library; can be partially overridden; see [full object type](https://github.com/Ennoriel/svelte-awesome-color-picker/blob/master/src/lib/utils/texts.ts)
-->
<style>
.text-input {
Expand Down
1 change: 1 addition & 0 deletions src/routes/sections/40-Summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [Bind event '`on:input`'](#bind-event-oninput)
- [Override the css variables](#override-the-css-variables)
- [Dark theme](#dark-theme)
- [Override the css variables](#override-the-css-variables)
- [Api](#api)
- [Color picker](#color-picker)
- [events](#events)
Expand Down
68 changes: 68 additions & 0 deletions src/routes/sections/50-Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,71 @@ In this example, the color is appended to the history at each event.

</div>
</div>

### Override the css variables

Note: the `texts` props can be **partially** overridden. It's mostly used to translate the component. Most texts are used for accessibility aria-labels.

<div class="example-wrapper">
<div>
<ColorPicker
bind:rgb
bind:hsv
bind:hex
label="Choisir une couleur"
texts={{
label: {
h: 'teinte',
s: 'saturation',
v: 'luminosité',
r: 'rouge',
g: 'vert',
b: 'bleu',
a: 'transparence',
hex: 'couleur hexadécimale',
withoutColor: 'sans couleur'
},
color: {
rgb: 'rgb',
hsv: 'hsv',
hex: 'hex'
},
changeTo: 'changer à '
}}
/>
</div>
<div class="overflow">

**Source code**

<!-- prettier-ignore -->
```svelte
<ColorPicker
bind:rgb
bind:hsv
bind:hex
label="Choisir une couleur"
texts={{
label: {
h: 'teinte',
s: 'saturation',
v: 'luminosité',
r: 'rouge',
g: 'vert',
b: 'bleu',
a: 'transparence',
hex: 'couleur hexadécimale',
withoutColor: 'sans couleur'
},
color: {
rgb: 'rgb',
hsv: 'hsv',
hex: 'hex'
},
changeTo: 'changer à '
}}
/>
```

</div>
</div>
Loading

0 comments on commit 973043f

Please sign in to comment.