diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60b0bb96..928c7a55 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: yarn install --immutable yarn build - name: Upload built files - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: built path: .svelte-kit @@ -40,7 +40,7 @@ jobs: node-version-file: .nvmrc cache: yarn - name: Download built files - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: built path: .svelte-kit @@ -60,7 +60,7 @@ jobs: node-version-file: .nvmrc cache: yarn - name: Download built files - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: built path: .svelte-kit diff --git a/src/lib/components/colors/FormatGroup.svelte b/src/lib/components/colors/FormatGroup.svelte new file mode 100644 index 00000000..28fb4c82 --- /dev/null +++ b/src/lib/components/colors/FormatGroup.svelte @@ -0,0 +1,57 @@ + + +
+
+

{formatGroup.name}

+ {#if !isInGamut} + Selected color is outside the {formatGroup.gamutName} gamut. + {/if} +
+ {#each formatGroup.formats as format (format)} + + {/each} +
+ + diff --git a/src/lib/components/colors/Formats.svelte b/src/lib/components/colors/Formats.svelte index ef706db6..a19ab637 100644 --- a/src/lib/components/colors/Formats.svelte +++ b/src/lib/components/colors/Formats.svelte @@ -1,31 +1,47 @@
-

{displayType} Color

- {#each otherFormats as format (format)} - +

{displayType} Color

+ {#each otherFormats as formatGroup} + {/each}
diff --git a/src/lib/components/colors/Header.svelte b/src/lib/components/colors/Header.svelte index 3d96363f..407c2fd3 100644 --- a/src/lib/components/colors/Header.svelte +++ b/src/lib/components/colors/Header.svelte @@ -165,7 +165,7 @@ } [data-label] { - --label-margin-bottom: var(--half-shim); + --label-margin-block-end: var(--half-shim); grid-area: label; } diff --git a/src/lib/components/colors/Output.svelte b/src/lib/components/colors/Output.svelte index 6a906f44..37a7db09 100644 --- a/src/lib/components/colors/Output.svelte +++ b/src/lib/components/colors/Output.svelte @@ -1,5 +1,5 @@ diff --git a/src/lib/components/colors/Sliders.svelte b/src/lib/components/colors/Sliders.svelte index 2e1e98d5..9afa1d5c 100644 --- a/src/lib/components/colors/Sliders.svelte +++ b/src/lib/components/colors/Sliders.svelte @@ -103,7 +103,7 @@ } [data-group~='sliders'] { - --label-margin-bottom: var(--half-shim); + --label-margin-block-end: var(--half-shim); margin-bottom: var(--triple-gutter); } diff --git a/src/lib/components/colors/index.svelte b/src/lib/components/colors/index.svelte index e666ed02..ee82c135 100644 --- a/src/lib/components/colors/index.svelte +++ b/src/lib/components/colors/index.svelte @@ -18,7 +18,6 @@ -

Additional Formats

diff --git a/src/lib/components/ratio/index.svelte b/src/lib/components/ratio/index.svelte index db8e1828..f0162277 100644 --- a/src/lib/components/ratio/index.svelte +++ b/src/lib/components/ratio/index.svelte @@ -38,7 +38,7 @@
-

AA Contrast Ratio

+

AA Contrast Ratio

{RATIOS.AA.Normal} : 1
@@ -48,7 +48,7 @@
Large Text
-

AAA Contrast Ratio

+

AAA Contrast Ratio

{RATIOS.AAA.Normal} : 1
Normal Text
@@ -57,7 +57,7 @@
Large Text
-

Large Text Size

+

Large Text Size

≥ 24px
Regular Weight
@@ -141,8 +141,11 @@ align-items: start; display: inline-flex; grid-area: number; - justify-content: flex-end; line-height: 0.7; // weird number alignment + + @include config.between('sm-column-break', 'lg-page-break') { + justify-content: flex-end; + } } .result-ratio-number { diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 885bf128..4bb8aea8 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -24,6 +24,29 @@ export const FORMATS: ColorFormatId[] = [ 'srgb', ]; +export type FormatGroup = { + name: string; + formats: ColorFormatId[]; + gamutFormat?: ColorFormatId; + gamutName?: string; +}; + +export const FORMAT_GROUPS: FormatGroup[] = [ + { + name: 'sRGB FORMATS', + formats: ['hex', 'hsl', 'srgb'], + gamutFormat: 'srgb', + gamutName: 'sRGB', + }, + { name: 'UNBOUNDED SPACES', formats: ['lab', 'lch', 'oklab', 'oklch'] }, + { + name: 'DISPLAY P3 SPACE', + formats: ['p3'], + gamutFormat: 'p3', + gamutName: 'P3', + }, +]; + export const RATIOS = { AA: { Normal: 4.5, diff --git a/src/sass/initial/_type.scss b/src/sass/initial/_type.scss index f3f42728..baab320a 100644 --- a/src/sass/initial/_type.scss +++ b/src/sass/initial/_type.scss @@ -22,8 +22,7 @@ h1, h2, -h3, -h4 { +h3 { font-weight: normal; margin: 0; } @@ -42,15 +41,13 @@ h4 { display: block; font-size: var(--heading-size, var(--label-size)); letter-spacing: var(--heading-letterspacing, 0.05rem); - margin-bottom: var(--label-margin-bottom, 0); + margin-block-end: var(--label-margin-block-end, 0); text-transform: var(--heading-transform, uppercase); } .section-heading { @include heading; - --label-margin-bottom: var(--gutter-plus); - @include config.below('sm-page-break') { --heading-size: var(--medium); } diff --git a/test/js/fixtures.ts b/test/js/fixtures.ts index 4f46fb68..61d597f2 100644 --- a/test/js/fixtures.ts +++ b/test/js/fixtures.ts @@ -18,3 +18,9 @@ export const HSL_BLACK: PlainColorObject = { }; export const HSL_WHITE_SERIALIZED = serialize(HSL_WHITE, { inGamut: false }); + +export const OUT_OF_BOUNDED_GAMUTS: PlainColorObject = { + space: ColorSpace.get('oklch'), + coords: [1, 1, 1], + alpha: 1, +}; diff --git a/test/js/lib/components/colors/FormatGroup.spec.ts b/test/js/lib/components/colors/FormatGroup.spec.ts new file mode 100644 index 00000000..1c90f326 --- /dev/null +++ b/test/js/lib/components/colors/FormatGroup.spec.ts @@ -0,0 +1,36 @@ +import { render } from '@testing-library/svelte'; + +import FormatGroup from '$lib/components/colors/FormatGroup.svelte'; +import { FORMAT_GROUPS } from '$src/lib/constants'; +import { HSL_WHITE, OUT_OF_BOUNDED_GAMUTS } from '$test/fixtures'; + +describe('FormatGroup', () => { + it('renders selected group', () => { + const FORMAT_GROUP = FORMAT_GROUPS[0]!; + const { getByTestId, getByText } = render(FormatGroup, { + type: 'bg', + color: HSL_WHITE, + formatGroup: FORMAT_GROUP, + }); + + expect(getByText(FORMAT_GROUP.name)).toBeVisible(); + FORMAT_GROUP.formats.forEach((format) => { + expect(getByTestId(`format-${format}`)).toBeVisible(); + }); + }); + + it('renders warning if out of gamut', () => { + const FORMAT_GROUP = FORMAT_GROUPS[0]!; + const { getByTestId, getByText } = render(FormatGroup, { + type: 'bg', + color: OUT_OF_BOUNDED_GAMUTS, + formatGroup: FORMAT_GROUP, + }); + + expect(getByText(FORMAT_GROUP.name)).toBeVisible(); + FORMAT_GROUP.formats.forEach((format) => { + expect(getByTestId(`format-${format}`)).toBeVisible(); + }); + expect(getByText('outside the sRGB gamut.')).toBeVisible(); + }); +}); diff --git a/test/js/lib/components/colors/Output.spec.ts b/test/js/lib/components/colors/Output.spec.ts index 16f3e3bb..93882a10 100644 --- a/test/js/lib/components/colors/Output.spec.ts +++ b/test/js/lib/components/colors/Output.spec.ts @@ -1,9 +1,7 @@ import { render } from '@testing-library/svelte'; import { serialize, to } from 'colorjs.io/fn'; -import type { PlainColorObject } from 'colorjs.io/types/src/color'; import Output from '$lib/components/colors/Output.svelte'; -import { ColorSpace } from '$lib/stores'; import { HSL_WHITE, HSL_WHITE_SERIALIZED } from '$test/fixtures'; describe('Output', () => { @@ -28,19 +26,4 @@ describe('Output', () => { getByText(serialize(to(HSL_WHITE, 'oklch'), { inGamut: false })), ).toBeVisible(); }); - - it('renders warning if out of gamut', () => { - const color: PlainColorObject = { - space: ColorSpace.get('oklch'), - coords: [0.01, 0.02, 0], - alpha: 1, - }; - const { getByText } = render(Output, { - type: 'fg', - color, - format: 'hsl', - }); - - expect(getByText('outside the HSL gamut', { exact: false })).toBeVisible(); - }); });