Skip to content

Commit

Permalink
feat: Expose CSS variables for theming the SwitchField component (#765
Browse files Browse the repository at this point in the history
)
  • Loading branch information
frankieyan authored Apr 26, 2023
1 parent 281170c commit 2ecbb50
Show file tree
Hide file tree
Showing 34 changed files with 48 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Reactist follows [semantic versioning](https://semver.org/) and doesn't introduce breaking changes (API-wise) in minor or patch releases. However, the appearance of a component might change in a minor or patch release so keep an eye on redesigns and make sure your app still looks and feels like you expect it.

# v20.2.0

- [Feat] Expose CSS variables for theming the `SwitchField` component.

# v20.1.0

- [Feat] New `Prose` component to style free-form HTML content consistently.
Expand Down

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/1.2ea4b52e0673a31c7230.manager.bundle.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/1.f697a8c29cf68bb5cb06.manager.bundle.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/6.675f564a19ee7a73e49b.manager.bundle.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/6.97c9cc9361142d6bb8c6.manager.bundle.js

This file was deleted.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/8.1825dade33c66fa24e41.manager.bundle.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/8.596300ec504eb8dad625.manager.bundle.js

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,4 @@



window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(tsx|mdx)","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(tsx|mdx))$"},{"titlePrefix":"","directory":"./stories","files":"**/*.stories.@(js|jsx|ts|tsx|mdx)","importPathMatcher":"^\\.[\\\\/](?:stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx|mdx))$"}];</script><script src="runtime~main.8b1ed5da.iframe.bundle.js"></script><script src="vendors~main.6eae3178.iframe.bundle.js"></script><script src="main.5b17ba62.iframe.bundle.js"></script></body></html>
window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(tsx|mdx)","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(tsx|mdx))$"},{"titlePrefix":"","directory":"./stories","files":"**/*.stories.@(js|jsx|ts|tsx|mdx)","importPathMatcher":"^\\.[\\\\/](?:stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx|mdx))$"}];</script><script src="runtime~main.8b1ed5da.iframe.bundle.js"></script><script src="vendors~main.44ce8732.iframe.bundle.js"></script><script src="main.233bd9c7.iframe.bundle.js"></script></body></html>
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@



window['DOCS_MODE'] = false;</script><script src="runtime~main.1ddf0cb1fbc5a28dc85b.manager.bundle.js"></script><script src="vendors~main.fbe5cb2e7c42a5dde98b.manager.bundle.js"></script><script src="main.3a427fb1d7687254a3ff.manager.bundle.js"></script></body></html>
window['DOCS_MODE'] = false;</script><script src="runtime~main.967a1490e75c30bed429.manager.bundle.js"></script><script src="vendors~main.ff25b74b26d4b719fdc9.manager.bundle.js"></script><script src="main.880233a3f4fa47c6fa05.manager.bundle.js"></script></body></html>
1 change: 1 addition & 0 deletions docs/main.233bd9c7.iframe.bundle.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/main.3a427fb1d7687254a3ff.manager.bundle.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/main.5b17ba62.iframe.bundle.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/main.880233a3f4fa47c6fa05.manager.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/project.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"generatedAt":1677608237660,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.19.2"},"typescriptOptions":{"check":true,"checkOptions":{},"reactDocgen":"react-docgen-typescript","reactDocgenTypescriptOptions":{"shouldExtractLiteralValuesFromEnum":true}},"features":{"interactionsDebugger":true},"storybookVersion":"^6.5.3","language":"typescript","storybookPackages":{"@storybook/addon-knobs":{"version":"6.3.1"},"@storybook/addon-links":{"version":"6.5.3"},"@storybook/addons":{"version":"6.5.3"},"@storybook/jest":{"version":"0.0.10"},"@storybook/react":{"version":"6.5.3"},"@storybook/testing-library":{"version":"0.0.13"}},"framework":{"name":"react"},"addons":{"@storybook/addon-postcss":{"version":"2.0.0"},"@storybook/addon-actions":{"version":"6.5.3"},"@storybook/addon-docs":{"options":{"configureJSX":true},"version":"6.5.3"},"@storybook/addon-controls":{"version":"6.5.3"},"@geometricpanda/storybook-addon-badges":{"version":"0.2.2"},"@storybook/addon-interactions":{"version":"6.5.15"}}}
{"generatedAt":1682536241278,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.19.2"},"typescriptOptions":{"check":true,"checkOptions":{},"reactDocgen":"react-docgen-typescript","reactDocgenTypescriptOptions":{"shouldExtractLiteralValuesFromEnum":true}},"features":{"interactionsDebugger":true},"storybookVersion":"^6.5.3","language":"typescript","storybookPackages":{"@storybook/addon-knobs":{"version":"6.3.1"},"@storybook/addon-links":{"version":"6.5.3"},"@storybook/addons":{"version":"6.5.3"},"@storybook/jest":{"version":"0.0.10"},"@storybook/react":{"version":"6.5.3"},"@storybook/testing-library":{"version":"0.0.13"}},"framework":{"name":"react"},"addons":{"@storybook/addon-postcss":{"version":"2.0.0"},"@storybook/addon-actions":{"version":"6.5.3"},"@storybook/addon-docs":{"options":{"configureJSX":true},"version":"6.5.3"},"@storybook/addon-controls":{"version":"6.5.3"},"@geometricpanda/storybook-addon-badges":{"version":"0.2.2"},"@storybook/addon-interactions":{"version":"6.5.15"}}}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/vendors~main.44ce8732.iframe.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/vendors~main.6eae3178.iframe.bundle.js.map

This file was deleted.

2 changes: 0 additions & 2 deletions docs/vendors~main.fbe5cb2e7c42a5dde98b.manager.bundle.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/vendors~main.ff25b74b26d4b719fdc9.manager.bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"email": "[email protected]",
"url": "http://doist.com"
},
"version": "20.1.0",
"version": "20.2.0",
"license": "MIT",
"homepage": "https://github.com/Doist/reactist#readme",
"repository": {
Expand Down
1 change: 0 additions & 1 deletion src/styles/design-tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
--reactist-content-danger: rgb(209, 69, 59);

/* component-specific */
--reactist-switch-checked: rgb(5, 133, 39);

/* alerts */
--reactist-alert-tone-info-icon: #1d438c;
Expand Down
10 changes: 8 additions & 2 deletions src/switch-field/switch-field.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
:root {
--reactist-switch-background: var(--reactist-framework-fill-summit);
--reactist-switch-checked: var(--reactist-content-positive);
--reactist-switch-toggle: var(--reactist-bg-default);
}

.container,
.container * {
font-family: var(--reactist-font-family);
Expand Down Expand Up @@ -28,7 +34,7 @@
height: var(--tmp-switch-height);
min-height: auto;
border-radius: calc(var(--tmp-switch-height) / 2);
background-color: var(--reactist-framework-fill-summit);
background-color: var(--reactist-switch-background);
cursor: pointer;
position: relative;
}
Expand All @@ -49,7 +55,7 @@
width: var(--tmp-handle-size);
height: var(--tmp-handle-size);
border-radius: 50%;
background: var(--reactist-bg-default);
background: var(--reactist-switch-toggle);
transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

Expand Down
12 changes: 12 additions & 0 deletions src/switch-field/switch-field.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ export function Template({ label, hint, disabled }) {
return <SwitchField label={label || 'Default label'} hint={hint} disabled={disabled} />
}

## Colors

The following CSS custom properties are available to customize the SwitchField's appearance. The values appearing below are the default values.

```css
:root {
--reactist-switch-background: rgb(214, 214, 214);
--reactist-switch-checked: rgb(5, 133, 39);
--reactist-switch-toggle: rgb(255, 255, 255);
}
```

## Accessibility

<Canvas>
Expand Down

0 comments on commit 2ecbb50

Please sign in to comment.