Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunear committed Jan 16, 2025
1 parent e2271bb commit 91a24bd
Show file tree
Hide file tree
Showing 11 changed files with 635 additions and 151 deletions.
7 changes: 6 additions & 1 deletion apps/theme/app/debug/ColorGrid/ColorGrid.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.row {
display: flex;
margin-bottom: 12px;
margin-left: -4px;
margin-left: -8px;
}

.item {
Expand Down Expand Up @@ -36,3 +36,8 @@
margin-top: 4px;
margin-bottom: 24px;
}

.grid {
background-color: white;
padding: 24px;
}
8 changes: 5 additions & 3 deletions apps/theme/app/debug/ColorGrid/ColorGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ export const ColorGrid = ({ colors, colorNumber }: ColorGridProps) => {
onChange={(e) => setShowBase(e.target.checked)}
className={classes.checkbox}
/>
{colors.map((item, index) => (
<Row key={index} rowColors={item} />
))}
<div className={classes.grid}>
{colors.map((item, index) => (
<Row key={index} rowColors={item} />
))}
</div>
</div>
);
};
63 changes: 63 additions & 0 deletions apps/theme/app/debug/ContrastColors/ContrastColors.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.container {
display: flex;
flex-wrap: wrap;
gap: 20px;
}

.item {
width: 150px;
background-color: white;
}

.color {
width: 100%;
height: 60px;
display: flex;
gap: 10px;
padding: 10px;
}

.circle {
height: 22px;
width: 22px;
border-radius: 50%;
}

.group {
display: flex;
border: 1px solid var(--ds-color-neutral-border-subtle);
margin-bottom: 20px;
border-radius: 4px;
overflow: hidden;
}

.content {
display: flex;
font-size: 14px;
gap: 10px;
padding: 10px;
flex-wrap: wrap;
}

.content > div {
width: 46%;
}

.contrastSection {
display: flex;
gap: 8px;
align-items: center;
}

.contrastCircle {
height: 14px;
width: 14px;
border-radius: 50%;
border: 1px solid black;
margin-bottom: -1px;
}

.group .item:nth-child(1) .content,
.group .item:nth-child(2) .content {
border-right: 1px solid rgb(201, 201, 201);
}
80 changes: 80 additions & 0 deletions apps/theme/app/debug/ContrastColors/ContrastColors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import {
type CssColor,
type ThemeInfo,
getContrastFromHex,
getLightnessFromHex,
} from '@digdir/designsystemet/color';
import chroma from 'chroma-js';
import { useDebugStore } from '../debugStore';
import classes from './ContrastColors.module.css';

export const ContrastColors = () => {
const colorScales = useDebugStore((state) => state.colorScales);

const contrastSection = (color1: CssColor, color2: CssColor) => {
const contrast = getContrastFromHex(color1, color2).toFixed(2);
return (
<div className={classes.contrastSection}>
<div
className={classes.contrastCircle}
style={{ backgroundColor: color2 }}
></div>
<div>{contrast}</div>
</div>
);
};

const Item = ({
color,
scheme,
hideSecondCircle,
}: { color: CssColor; scheme: ThemeInfo; hideSecondCircle?: boolean }) => {
return (
<div className={classes.item}>
<div className={classes.color} style={{ backgroundColor: color }}>
<div
className={classes.circle}
style={{ backgroundColor: scheme.light[13].hex }}
></div>
{!hideSecondCircle && (
<div
className={classes.circle}
style={{ backgroundColor: scheme.light[14].hex }}
></div>
)}
</div>
<div className={classes.content}>
<div>Li: {getLightnessFromHex(color).toFixed(1)}</div>
<div>Lu: {chroma(color).luminance().toFixed(2)}</div>
<div>{contrastSection(color, '#ffffff')}</div>
<div>{contrastSection(color, '#000000')}</div>
<div>{contrastSection(color, scheme.light[14].hex)}</div>
</div>
</div>
);
};

return (
<div className={classes.container}>
{colorScales.map((outerScales, outerKey) => (
<div key={outerKey}>
{outerScales.map((innerScale, key) => (
<div key={key} className={classes.group}>
<Item color={innerScale.light[8].hex} scheme={innerScale} />
<Item
color={innerScale.light[9].hex}
scheme={innerScale}
hideSecondCircle
/>
<Item
color={innerScale.light[10].hex}
scheme={innerScale}
hideSecondCircle
/>
</div>
))}
</div>
))}
</div>
);
};
36 changes: 28 additions & 8 deletions apps/theme/app/debug/ContrastTests/ContrastTests.module.css
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
.container {
display: flex;
gap: 24px;
gap: 20px;
flex-wrap: wrap;
}
.row {
display: flex;
gap: 32px;
gap: 20px;
width: 100%;
}

.column {
border: 1px solid rgb(192, 192, 192);
padding: 24px;
padding: 20px;
border-radius: 8px;
width: 50%;
background-color: var(--ds-color-neutral-background-default);
}
.item {
border-radius: 8px;
font-size: 16px;
font-size: 15px;
display: flex;
align-items: center;
gap: 12px;
Expand All @@ -26,22 +27,41 @@
.items {
width: 100%;
display: flex;
gap: 16px;
gap: 12px;
flex-direction: column;
margin-top: 16px;
}

.itemPassed {
.title {
font-weight: 500;
}

.header {
display: flex;
justify-content: space-between;
position: relative;
font-weight: 500;
}

.btn {
font-size: 14px;
position: absolute;
right: 0;
top: 0;
}

.circle {
background-color: #b0e7b0;
height: 42px;
width: 42px;
height: 36px;
width: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: 500;
}

.failed {
background-color: #f8b4b4;
}
Loading

0 comments on commit 91a24bd

Please sign in to comment.