Skip to content

Commit d37ee03

Browse files
authored
Merge pull request #460 from acelaya-forks/feature/tests-with-tailwind
Define new brand colors for dark and light modes
2 parents cd04ac7 + 81a3551 commit d37ee03

File tree

16 files changed

+207
-136
lines changed

16 files changed

+207
-136
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
66

7-
## [Unreleased]
7+
## [0.9.0] - 2025-05-08
88
### Added
99
* Add tailwind-based `CopyToClipboardButton` component.
1010
* Allow `CardModal`'s `title` to be any `ReactNode` not just a `string`.
1111

1212
### Changed
13-
* *Nothing*
13+
* Define accessible brand colors for light and dark mode.
14+
15+
The one used for dark mode is the same previously used, but for light mode we use a slightly darker shade of blue that ensures proper color contrast.
16+
17+
As a consequence, the `--color-brand` and `--color-brand-dark` CSS variables have been removed, and specific ones have been defined for light and dark modes.
1418

1519
### Deprecated
1620
* *Nothing*

dev/tailwind/navigation/PaginatorPage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { FC } from 'react';
22
import { useState } from 'react';
3-
import { SimpleCard } from '../../../src';
4-
import { Paginator } from '../../../src/tailwind';
3+
import { Paginator, SimpleCard } from '../../../src/tailwind';
54

65
export const PaginatorPage: FC = () => {
76
const [currentPage, setCurrentPage] = useState(3);

src/tailwind/feedback/Result.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const Result: FC<ResultProps> = ({ variant, className, size = 'md', child
2020
'tw:p-4': size === 'md',
2121
'tw:p-6': size === 'lg',
2222
'tw:[&]:text-white': variant !== 'warning',
23-
'tw:bg-brand': variant === 'success',
23+
'tw:bg-lm-brand tw:dark:bg-dm-brand': variant === 'success',
2424
'tw:bg-danger': variant === 'error',
2525
'tw:bg-warning tw:text-black': variant === 'warning',
2626
},

src/tailwind/form/BooleanControl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const BooleanControl = forwardRef<HTMLInputElement, BooleanControlProps>(
1919
className={clsx(
2020
'tw:appearance-none tw:focus-ring tw:cursor-[inherit]',
2121
'tw:border-1 tw:border-lm-input-border tw:dark:border-dm-input-border',
22-
'tw:bg-lm-primary tw:dark:bg-dm-primary tw:checked:bg-brand tw:bg-no-repeat',
22+
'tw:bg-lm-primary tw:dark:bg-dm-primary tw:checked:bg-lm-brand tw:dark:checked:bg-dm-brand tw:bg-no-repeat',
2323
// Use different background color when rendered inside a card
2424
'tw:group-[&]/card:bg-lm-input tw:group-[&]/card:dark:bg-dm-input',
2525
className,

src/tailwind/form/Button.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ export const Button: FC<ButtonProps> = ({
5353
'tw:px-4 tw:py-2 tw:text-lg': size === 'lg',
5454
},
5555
{
56-
'tw:border-brand tw:text-brand': variant === 'primary',
56+
'tw:border-lm-brand tw:dark:border-dm-brand': variant === 'primary',
57+
'tw:text-lm-brand tw:dark:text-dm-brand': variant === 'primary' && !solid,
5758
'tw:border-zinc-500': variant === 'secondary',
5859
'tw:text-zinc-500': variant === 'secondary' && !solid,
5960
'tw:border-danger': variant === 'danger',
6061
'tw:text-danger': variant === 'danger' && !solid,
6162
},
6263
solid && {
6364
'tw:text-white': true,
64-
'tw:bg-brand': variant === 'primary',
65-
'tw:highlight:bg-brand-dark tw:highlight:border-brand-dark': variant === 'primary',
65+
'tw:bg-lm-brand tw:dark:bg-dm-brand': variant === 'primary',
66+
'tw:highlight:bg-lm-brand-dark tw:dark:highlight:bg-dm-brand-dark': variant === 'primary',
67+
'tw:highlight:border-lm-brand-dark tw:dark:highlight:border-dm-brand-dark': variant === 'primary',
6668

6769
'tw:bg-zinc-500': variant === 'secondary',
6870
'tw:highlight:bg-zinc-600 tw:highlight:border-zinc-600': variant === 'secondary',
@@ -72,7 +74,7 @@ export const Button: FC<ButtonProps> = ({
7274
},
7375
!disabled && {
7476
'tw:highlight:text-white': !solid,
75-
'tw:highlight:bg-brand': variant === 'primary',
77+
'tw:highlight:bg-lm-brand tw:dark:highlight:bg-dm-brand': variant === 'primary',
7678
'tw:highlight:bg-zinc-500': variant === 'secondary',
7779
'tw:highlight:bg-danger': variant === 'danger',
7880
},

src/tailwind/navigation/LinkButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export const LinkButton: FC<LinkButtonProps> = ({ className, disabled, size = 'm
1111
<button
1212
className={clsx(
1313
'tw:inline-flex tw:rounded-md tw:focus-ring',
14-
'tw:text-brand tw:highlight:text-brand-dark tw:highlight:underline',
14+
'tw:text-lm-brand tw:dark:text-dm-brand',
15+
'tw:highlight:text-lm-brand-dark tw:dark:highlight:text-dm-brand-dark tw:highlight:underline',
1516
{
1617
'tw:px-1.5 tw:py-1 tw:text-sm': size === 'sm',
1718
'tw:px-3 tw:py-1.5': size === 'md',

src/tailwind/navigation/NavPills.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ const Pill: FC<PillProps> = ({ className, to, ...rest }) => {
1818
to={to}
1919
className={({ isActive }) => clsx(
2020
'tw:px-4 tw:pt-2 tw:pb-[calc(0.5rem-3px)] tw:border-b-3',
21-
'tw:font-bold tw:no-underline tw:text-center tw:highlight:text-brand tw:transition-colors',
22-
'tw:rounded-none tw:outline-none tw:focus-visible:inset-ring-2 tw:focus-visible:inset-ring-brand/50',
21+
'tw:highlight:text-lm-brand tw:dark:highlight:text-dm-brand',
22+
'tw:font-bold tw:text-center tw:no-underline tw:transition-colors',
23+
'tw:rounded-none tw:outline-none tw:focus-visible:inset-ring-2',
24+
'tw:focus-visible:inset-ring-lm-brand/50 tw:dark:focus-visible:inset-ring-dm-brand/50',
2325
{
24-
'tw:border-b-brand active': isActive,
26+
'tw:text-lm-brand tw:dark:text-dm-brand': isActive,
27+
'tw:border-b-lm-brand tw:dark:border-b-dm-brand active': isActive,
2528
'tw:border-b-transparent tw:text-gray-500': !isActive,
2629
'tw:flex-grow': context?.fill,
2730
},

src/tailwind/navigation/Paginator.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ const buildPaginatorItemClasses = (active = false) => clsx(
1616
commonClasses,
1717
'tw:px-3 py-2 tw:cursor-pointer tw:no-underline',
1818
'tw:focus-ring tw:focus-visible:z-1',
19-
{
20-
'tw:highlight:bg-lm-secondary tw:dark:highlight:bg-dm-secondary tw:text-brand': !active,
21-
'tw:bg-lm-brand tw:dark:bg-dm-brand tw:text-white': active,
22-
},
19+
!active && [
20+
'tw:text-lm-brand tw:dark:text-dm-brand',
21+
'tw:bg-lm-primary tw:dark:bg-dm-primary',
22+
'tw:highlight:bg-lm-secondary tw:dark:highlight:bg-dm-secondary',
23+
],
24+
active && 'tw:bg-lm-main tw:dark:bg-dm-main tw:text-white',
2325
);
2426

2527
const DisabledPaginatorItem: FC<PropsWithChildren> = ({ children }) => (

src/tailwind/tailwind.preset.css

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,44 @@
66

77
@theme static inline {
88
/* Light mode */
9-
/*--color-lm-main: #2078CF;*/ /*Properly accessible with white background*/
10-
--color-lm-main: #4696e5; /* TODO Rename to "brand" */
11-
--color-lm-main-dark: #1f69c0;
9+
--color-lm-brand: #2078CF;
10+
--color-lm-brand-dark: color-mix(in srgb, black 20%, var(--tw-color-lm-brand) 80%);
1211
--color-lm-primary: #ffffff;
1312
--color-lm-primary-alfa: rgb(var(--tw-color-lm-primary) / .5);
1413
--color-lm-secondary: #f5f6fe;
1514
--color-lm-text: #232323;
1615
--color-lm-border: rgb(0 0 0 / .125);
1716
--color-lm-table-border: #dee2e6;
1817
--color-lm-active: #eeeeee;
19-
--color-lm-brand: var(--tw-color-lm-main); /* TODO Rename to "main" */
18+
--color-lm-main: var(--tw-color-lm-brand);
2019
--color-lm-input: var(--tw-color-lm-primary);
2120
--color-lm-disabled-input: var(--tw-color-lm-secondary);
2221
--color-lm-input-text: #495057;
2322
--color-lm-input-border: rgb(0 0 0 / .19);
2423
--color-lm-table-highlight: rgb(0 0 0 / .075);
2524

2625
/* Dark mode */
27-
--color-dm-main: #4696e5; /* TODO Rename to "brand" */
28-
--color-dm-main-dark: #1f69c0;
26+
--color-dm-brand: #4696e5;
27+
--color-dm-brand-dark: color-mix(in srgb, black 25%, var(--tw-color-dm-brand) 75%);
2928
--color-dm-primary: #161b22;
3029
--color-dm-primary-alfa: rgb(var(--tw-color-dm-primary) / .8);
3130
--color-dm-secondary: #0f131a;
3231
--color-dm-text: rgb(201 209 217);
3332
--color-dm-border: rgb(255 255 255 / .15);
3433
--color-dm-table-border: #393d43;
3534
--color-dm-active: var(--tw-color-dm-secondary);
36-
--color-dm-brand: #0b2d4e; /* TODO Rename to "main" */
35+
--color-dm-main: #0b2d4e;
3736
--color-dm-input: rgb(17.9928571429 22.0821428571 27.8071428571);
3837
--color-dm-disabled-input: rgb(26.0071428571 31.9178571429 40.1928571429);
3938
--color-dm-input-text: var(--tw-color-dm-text);
4039
--color-dm-input-border: var(--tw-color-dm-border);
4140
--color-dm-table-highlight: var(--tw-color-dm-border);
4241

43-
/* TODO Remove these two colors */
44-
--color-brand: #4696e5;
45-
--color-brand-dark: #1f69c0;
46-
4742
/* General color palette */
4843
--color-danger: #dc3545;
49-
--color-danger-dark: #bb2d3b;
44+
--color-danger-dark: color-mix(in srgb, black 20%, var(--tw-color-danger) 80%);
5045
--color-warning: #ffc107;
51-
--color-warning-dark: #ffca2c;
46+
--color-warning-dark: color-mix(in srgb, black 20%, var(--tw-color-warning) 80%);
5247
--color-placeholder: #6c757d;
5348

5449
/* Override breakpoints with the values from bootstrap, to keep sizing until fully migrated */
@@ -59,6 +54,7 @@
5954
--breakpoint-2xl: 1400px;
6055
}
6156

57+
/* Deprecated. TODO Remove with bootstrap support */
6258
@layer base {
6359
html:not([data-theme='dark']) {
6460
--primary-color: var(--tw-color-lm-primary);
@@ -67,7 +63,7 @@
6763
--text-color: var(--tw-color-lm-text);
6864
--border-color: var(--tw-color-lm-border);
6965
--active-color: var(--tw-color-lm-active);
70-
--brand-color: var(--tw-color-lm-brand);
66+
--brand-color: var(--tw-color-lm-main);
7167
--input-color: var(--tw-color-lm-input);
7268
--input-disabled-color: var(--tw-color-lm-disabled-input);
7369
--input-text-color: var(--tw-color-lm-input-text);
@@ -121,7 +117,10 @@
121117
color: var(--tw-color-brand);
122118
border-radius: var(--tw-radius-xs);
123119

124-
@apply tw:focus-visible:outline-3 tw:focus-visible:outline-brand/50 tw:focus-visible:outline-offset-3 tw:focus-visible:z-1;
120+
@apply
121+
tw:focus-visible:outline-3 tw:focus-visible:outline-offset-3
122+
tw:focus-visible:outline-lm-brand/50 tw:dark:focus-visible:outline-dm-brand/50
123+
tw:focus-visible:z-1;
125124
}
126125

127126
h1 {
@@ -161,7 +160,7 @@
161160
}
162161

163162
@utility focus-ring {
164-
@apply tw:focus-ring-base tw:focus-visible:ring-brand/50;
163+
@apply tw:focus-ring-base tw:focus-visible:ring-lm-brand/50 tw:dark:focus-visible:ring-dm-brand/50;
165164
}
166165

167166
@utility focus-ring-danger {

test/tailwind/feedback/__snapshots__/CardModal.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ exports[`<CardModal /> > renders expected variant 1`] = `
285285
data-testid="footer"
286286
>
287287
<button
288-
class="tw:inline-flex tw:rounded-md tw:focus-ring tw:text-brand tw:highlight:text-brand-dark tw:highlight:underline tw:px-3 tw:py-1.5"
288+
class="tw:inline-flex tw:rounded-md tw:focus-ring tw:text-lm-brand tw:dark:text-dm-brand tw:highlight:text-lm-brand-dark tw:dark:highlight:text-dm-brand-dark tw:highlight:underline tw:px-3 tw:py-1.5"
289289
type="button"
290290
>
291291
Cancel
292292
</button>
293293
<button
294-
class="tw:flex tw:gap-2 tw:items-center tw:justify-center tw:border tw:rounded-md tw:no-underline tw:transition-colors tw:focus-ring tw:px-3 tw:py-1.5 tw:border-brand tw:text-brand tw:text-white tw:bg-brand tw:highlight:bg-brand-dark tw:highlight:border-brand-dark tw:highlight:bg-brand"
294+
class="tw:flex tw:gap-2 tw:items-center tw:justify-center tw:border tw:rounded-md tw:no-underline tw:transition-colors tw:focus-ring tw:px-3 tw:py-1.5 tw:border-lm-brand tw:dark:border-dm-brand tw:text-white tw:bg-lm-brand tw:dark:bg-dm-brand tw:highlight:bg-lm-brand-dark tw:dark:highlight:bg-dm-brand-dark tw:highlight:border-lm-brand-dark tw:dark:highlight:border-dm-brand-dark tw:highlight:bg-lm-brand tw:dark:highlight:bg-dm-brand"
295295
type="button"
296296
>
297297
Confirm
@@ -359,7 +359,7 @@ exports[`<CardModal /> > renders expected variant 2`] = `
359359
data-testid="footer"
360360
>
361361
<button
362-
class="tw:inline-flex tw:rounded-md tw:focus-ring tw:text-brand tw:highlight:text-brand-dark tw:highlight:underline tw:px-3 tw:py-1.5"
362+
class="tw:inline-flex tw:rounded-md tw:focus-ring tw:text-lm-brand tw:dark:text-dm-brand tw:highlight:text-lm-brand-dark tw:dark:highlight:text-dm-brand-dark tw:highlight:underline tw:px-3 tw:py-1.5"
363363
type="button"
364364
>
365365
Cancel

0 commit comments

Comments
 (0)