Skip to content

Commit

Permalink
Merge pull request #148 from US-CBP/bugfix/storybook-updates-06102024
Browse files Browse the repository at this point in the history
Bugfix/storybook updates 06102024
  • Loading branch information
dgibson666 authored Jun 12, 2024
2 parents 0a13798 + 219536f commit c741387
Show file tree
Hide file tree
Showing 11 changed files with 1,706 additions and 1,157 deletions.
2,776 changes: 1,654 additions & 1,122 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/web-components/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ const config = {
//getAbsolutePath('@storybook/addon-interactions'),
getAbsolutePath('@storybook/addon-a11y'),
getAbsolutePath("@storybook/addon-mdx-gfm"),
getAbsolutePath("@storybook/addon-mdx-gfm"),
'@chromatic-com/storybook'
],
framework: {
name: getAbsolutePath('@storybook/web-components-vite'),
options: {},
},
docs: {
autodocs: 'tag',
},
docs: {},
staticDirs: [
'../dist',
'../assets'
Expand Down
17 changes: 2 additions & 15 deletions packages/web-components/.storybook/manager.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
// .storybook/manager.js

import { addons } from '@storybook/addons';
import { create } from '@storybook/theming';

import cbpLogo from '../assets/images/cbp-seal.svg';

const theme = create({
//base: 'light',
// Brand assets
brandTitle: 'CBP Design System | Web Components',
brandImage: cbpLogo,
brandTarget: '_self',
});

addons.setConfig({
//theme,
theme: themes.dark,
theme,
//theme: themes.dark,
toolbar: {
//zoom: { hidden: true }
}
Expand Down
16 changes: 15 additions & 1 deletion packages/web-components/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ const preview = {
date: /Date$/i,
},
},
options: {
storySort: {
//method: 'alphabetical',
order: [
'Introduction',
'Design Tokens',
'About Dark Mode',
'Components',
'Patterns',
[
'Page Templates',
]
]
}
},
// DEG: Enabling custom viewports seems to be linked to the HTML tab showing generated code instead of source/story code. Disabling custom viewports for further testing.
viewport: {
//viewports: CUSTOM_VIEWPORTS,
Expand Down Expand Up @@ -109,7 +124,6 @@ export default preview;


// Wrap every story with `cbp-app` component, which brings in the high level CSS resets, settings, and variables.
// DEG: 3/14/2024 - Adding theme=light temporarily until dark mode is implemented properly
const withWrapper = (story) => {
//return `<cbp-app theme="light">${story()}</cbp-app>`;
return `<cbp-app>${story()}</cbp-app>`;
Expand Down
8 changes: 8 additions & 0 deletions packages/web-components/.storybook/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { create } from '@storybook/theming/create';

export default create({
//base: 'light',
brandTitle: 'CBP Design System | Web Components',
brandImage: '../assets/images/cbp-seal.svg',
brandTarget: '_self',
});
6 changes: 6 additions & 0 deletions packages/web-components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This CHANGELOG.md tracks the updates to the web components package of the CBP de

The React components are wrappers generated from this package and will share the same changes.

## [unpublished] TBD

* Storybook upgrade and updates.
* Fixed `cbp-app` so that its dark mode detection is reactive to changes of the user's preferences.


## [0.0.1-develop.10] 06-10-2024

* Implemented dark mode for buttons, links, typography, accordion, drawer, and panel comprised of additional CSS and a `context` property to trigger a specific design contextually and specify whether it inverts or remains constant.
Expand Down
18 changes: 9 additions & 9 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@
"@stencil/core": "^4.15.0"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.3.2",
"@chromatic-com/storybook": "^1.5.0",
"@custom-elements-manifest/analyzer": "^0.9.4",
"@stencil/react-output-target": "^0.5.3",
"@stencil/sass": "^3.0.7",
"@stencil/store": "^2.0.12",
"@storybook/addon-essentials": "^8.0.8",
"@storybook/addon-links": "^8.0.8",
"@storybook/addon-mdx-gfm": "^8.0.8",
"@storybook/blocks": "^8.0.8",
"@storybook/test": "^8.0.8",
"@storybook/web-components": "^8.0.8",
"@storybook/web-components-vite": "^8.0.8",
"@storybook/addon-essentials": "^8.1.6",
"@storybook/addon-links": "^8.1.6",
"@storybook/addon-mdx-gfm": "^8.1.6",
"@storybook/blocks": "^8.1.6",
"@storybook/test": "^8.1.6",
"@storybook/web-components": "^8.1.6",
"@storybook/web-components-vite": "^8.1.6",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.11",
"@whitespace/storybook-addon-html": "^6.0.5",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"lit": "^3.1.2",
"puppeteer": "21.1.1",
"storybook": "^8.0.8",
"storybook": "^8.1.6",
"wc-storybook-helpers": "^2.0.1"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/src/components/cbp-app/cbp-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CbpApp {
componentDidLoad() {
const darkMode = window?.matchMedia(`(prefers-color-scheme: dark)`);
// Only set up the listener if we're using the system default, otherwise, it's being set manually
if (this.theme=="system" && darkMode) {
if (this.theme == "system") {
darkMode.addEventListener('change', mql => this.handleThemeChange(mql)); // Add an event listener to the media query
this.handleThemeChange(darkMode); // Run the theme change handler once on load
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ const UserPreferencesTemplate = ({ position, open, uid, accessibilityText, conte
id="panelheader"
context="dark-always"
>
Sidebar Header
User Preferences
</cbp-typography>
<p>Sidebar Content</p>
<p>Drawer Content</p>
</cbp-panel>
</cbp-drawer>
`;
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/src/stories/dark-mode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Most web components also support a dark context. Even in "light mode" (via syste
* dark-inverts
* dark-always

This supports a number of designs and behaviors. It is not a valid assumption that something with a dark appearance or background in light mode would automatically invert to a light appearance in dark mode. These values support a range of possibilities to meet various design requirements.
It is not a valid assumption that something with a dark appearance or background in light mode would automatically invert to a light appearance in dark mode. These values support a range of possibilities to meet various design requirements.

The values "light-always" and "dark-always" specify a visual design that does not change based on light or dark mode. However, "light-inverts" (the default value) and "dark-inverts" specify a visual design in light mode that inverts when changing to dark mode.

Expand Down
8 changes: 5 additions & 3 deletions packages/web-components/src/stories/introduction.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ export default {
const Template = () => {
return `
<cbp-app>
<img src="assets/images/cbp-seal.svg" height="245" width="245" style={{ display: "block", marginBottom: "2rem", marginLeft: 'auto', marginRight: 'auto' }} />
<img src="assets/images/cbp-seal.svg" height="245" width="245" style="margin-bottom: 2rem; margin-inline: auto" />
<cbp-typography tag="h1" sx='{"text-align":"center","margin-bottom":"1rem"}'>CBP Design System</cbp-typography>
<cbp-typography tag="h2" sx='{"margin-bottom":"1rem"}'>Work in Progress</cbp-typography>
<h1 style={{ textAlign: "center" }}>CBP Design System</h1>
<h2>Work in Progress</h2>
<p>
The CBP Design System (1.0) is still in a stage of **very active development**.
As such, much of the code base is still somewhat fragile and may break at any time.
Expand Down

0 comments on commit c741387

Please sign in to comment.