Skip to content
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

Remove postcss-color-contrast dependency in favor of native CSS #56

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 0 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: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"vite-css-modules": "^1.6.0",
"typescript-plugin-css-modules": "^5.0.1",
"sass-embedded": "^1.82.0",
"postcss-color-contrast": "^1.1.0",
"lightningcss": "^1.28.2",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1"
Expand Down
1 change: 0 additions & 1 deletion package.json.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ const packageConfig = {
'vite-css-modules': '^1.6.0',
'typescript-plugin-css-modules': '^5.0.1',
'sass-embedded': '^1.82.0',
'postcss-color-contrast': '^1.1.0',
'lightningcss': '^1.28.2',

// React
Expand Down
5 changes: 1 addition & 4 deletions src/docs/Colors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import cx from 'classnames/dedupe';
import { Meta, Unstyled } from '@storybook/blocks';

import colorContrast from 'postcss-color-contrast/js';
import { colorsByCategory } from '../styling/variables.ts';

import { H4, H5 } from '../typography/Heading/Heading.tsx';
Expand Down Expand Up @@ -38,9 +37,7 @@ Primitive color tokens are the basic color definitions which are not dependent o
<dl className={cl['colors-list']}>
{Object.entries(colorCategory).map(([colorName, { weight, color }]) =>
<TooltipProvider key={colorName} tooltip={<code className="bk-body-text">{`bk.$color-${colorName}`}</code>}>
<div className={cl['color']} tabIndex="1"
style={{ '--color': color, '--contrast': colorContrast(color, ['#e5e5e5', '#171717']) }}
>
<div className={cl['color']} tabIndex="1" style={{ '--color': color }}>
<dt>{weight}</dt>
<dd>{color}</dd>
</div>
Expand Down
9 changes: 5 additions & 4 deletions src/docs/Colors.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
justify-content: end;

color: black;
/* color: color-contrast(var(--color) vs #171717, #e5e5e5); // Insufficient browser support */
/* color: white; mix-blend-mode: difference; // Works but results in some ugly colors */
color: lch(from var(--color) calc((49.44 - l) * infinity) 0 0); // https://codepen.io/devongovett/pen/QwLbRrW

font-size: 0.8rem;

dt, dd {
all: unset;
/* color: color-contrast(var(--color) vs black, white); // Insufficient browser support */
/* color: white; mix-blend-mode: difference; */

color: var(--contrast);
color: inherit;
}
dt {
font-weight: 600;
Expand Down
Loading