Skip to content

Commit

Permalink
docs: rounding tool
Browse files Browse the repository at this point in the history
  • Loading branch information
adarshpastakia committed Aug 24, 2024
1 parent 6593ba6 commit 3aff99e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
30 changes: 23 additions & 7 deletions .storybook/addon-theme/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ enum TINT {
SAND = "sand",
}
enum ROUNDING {
MINIMAL = "minimal",
SMALL = "sm",
NORMAL = "normal",
MEDIUM = "md",
FULL = "full",
}

Expand Down Expand Up @@ -316,13 +317,13 @@ export const ThemeToggle = () => {
/>

<IconButton
title="Rounding: Minimal"
active={rounding === ROUNDING.MINIMAL}
onClick={() => changeRounding(ROUNDING.MINIMAL)}
title="Rounding: Small"
active={rounding === ROUNDING.SMALL}
onClick={() => changeRounding(ROUNDING.SMALL)}
>
<div
style={{
width: "1rem",
width: "1.5rem",
height: "1rem",
borderRadius: "2px",
backgroundColor: "gray",
Expand All @@ -337,22 +338,37 @@ export const ThemeToggle = () => {
>
<div
style={{
width: "1rem",
width: "1.5rem",
height: "1rem",
borderRadius: "4px",
backgroundColor: "gray",
}}
/>
</IconButton>

<IconButton
title="Rounding: Medium"
active={rounding === ROUNDING.MEDIUM}
onClick={() => changeRounding(ROUNDING.MEDIUM)}
>
<div
style={{
width: "1.5rem",
height: "1rem",
borderRadius: "6px",
backgroundColor: "gray",
}}
/>
</IconButton>

<IconButton
title="Rounding: Full"
active={rounding === ROUNDING.FULL}
onClick={() => changeRounding(ROUNDING.FULL)}
>
<div
style={{
width: "1rem",
width: "1.5rem",
height: "1rem",
borderRadius: "8px",
backgroundColor: "gray",
Expand Down
2 changes: 2 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export default {
const [globals] = useGlobals();

useEffect(() => {
const scheme = localStorage.getItem("storybook-scheme") ?? "light";
const theme = localStorage.getItem("storybook-theme") ?? "denim:jade";
const tint = localStorage.getItem("storybook-tint") ?? "silver";
const round = localStorage.getItem("storybook-rounding") ?? "normal";
Expand All @@ -163,6 +164,7 @@ export default {
"--ruf-tint",
`var(--${tint})`,
);
document.documentElement.dataset.colorScheme = scheme;
document.documentElement.dataset.rounding = round;
}, []);

Expand Down
4 changes: 2 additions & 2 deletions packages/core/css/reset/_theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@
background-color: color-mix(in lab, var(--ruf-bg) 92%, var(--ruf-tint));
}

[data-rounding="minimal"] {
[data-rounding="sm"] {
/* default rounding */
--ruf-rounding: 2px;
--ruf-rounding-cap: 2px;
}

[data-rounding="normal"] {
[data-rounding="md"] {
/* default rounding */
--ruf-rounding: 0.5rem;
--ruf-rounding-cap: 0.5rem;
Expand Down

0 comments on commit 3aff99e

Please sign in to comment.