Skip to content

Commit

Permalink
docs(storybook): add storybook as an experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
joschka committed Jan 10, 2024
1 parent 139676c commit c5c79d5
Show file tree
Hide file tree
Showing 59 changed files with 29,909 additions and 8,614 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHROMATIC_PROJECT_TOKEN=
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1

- name: Deploy Storybook to Chromatic
run: npm run chromatic
env:
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.env
_site
dist
node_modules
.DS_Store
.idea
build-storybook.log
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ LICENSE
*.jpeg
*.png
*.svg
.env.example

21 changes: 21 additions & 0 deletions .storybook/DigitalServiceTheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { create } from "@storybook/theming/create";
import digitalServiceLogo from "./assets/images/logo.png";

export default create({
base: "light",
brandTitle: "DigitalService Design System",
brandUrl: "https://digitalservice.bund.de",
brandImage: digitalServiceLogo,
brandTarget: "_self",

fontBase: "Inter, Arial, sans-serif", // UI only (sidebar), does not affect preview + docs
colorPrimary: "blue", // where is that used? not links
colorSecondary: "blue",

appBorderRadius: 0,

textColor: "#000",

barSelectedColor: "#00f",
barHoverColor: "#00f",
});
Binary file added .storybook/assets/fonts/Inter-Bold.woff
Binary file not shown.
Binary file added .storybook/assets/fonts/Inter-Bold.woff2
Binary file not shown.
Binary file added .storybook/assets/fonts/Inter-Light.woff
Binary file not shown.
Binary file added .storybook/assets/fonts/Inter-Light.woff2
Binary file not shown.
Binary file added .storybook/assets/fonts/Inter-Medium.woff
Binary file not shown.
Binary file added .storybook/assets/fonts/Inter-Medium.woff2
Binary file not shown.
Binary file added .storybook/assets/fonts/Inter-Regular.woff
Binary file not shown.
Binary file added .storybook/assets/fonts/Inter-Regular.woff2
Binary file not shown.
Binary file added .storybook/assets/fonts/Inter-SemiBold.woff
Binary file not shown.
Binary file added .storybook/assets/fonts/Inter-SemiBold.woff2
Binary file not shown.
3 changes: 3 additions & 0 deletions .storybook/assets/images/colorvector.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/assets/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions .storybook/blocks/ColorBlob.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from "react";
import tokens from "@digitalservice4germany/style-dictionary/tokens.json";
import "../styles.css";

export default function ColorBlob({
name,
shade,
}: {
name: string;
shade?: string;
}) {
console.log({ tokens });
const hex = shade ? tokens.color.base[name][shade] : tokens.color.base[name];
return (
<div className="colordefinitionbox">
{name === "white" ? (
<div
style={{ backgroundColor: "black" }}
className="colorshapebox mask1"
>
<div
style={{
backgroundColor: hex,
transform: "scale(0.95)",
}}
className="colorshapebox mask1"
></div>
</div>
) : (
<div
style={{
backgroundColor: hex,
}}
className="colorshapebox mask1"
></div>
)}

<span className="colorname">{shade ? `${name} ${shade}` : name}</span>
<br />
<span className="hexvalue">{hex.toUpperCase()}</span>
</div>
);
}
28 changes: 28 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/** @type { import('@storybook/html-vite').StorybookConfig } */
const config = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-a11y",
{
name: "@storybook/addon-storysource",
options: {
loaderOptions: {
injectStoryParameters: false,
},
},
},
"@storybook/addon-designs",
],
framework: {
name: "@storybook/html-vite",
options: {},
},
docs: {
autodocs: "tag",
},
staticDirs: ["./assets"],
};
export default config;
47 changes: 47 additions & 0 deletions .storybook/manager-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<style>
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-Light.woff2") format("woff2"),
url("/fonts/Inter-Light.woff") format("woff");
font-weight: 300;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-Regular.woff2") format("woff2"),
url("/fonts/Inter-Regular.woff") format("woff");
font-weight: normal;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-Medium.woff2") format("woff2"),
url("/fonts/Inter-Medium.woff") format("woff");
font-weight: 500;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-SemiBold.woff2") format("woff2"),
url("/fonts/Inter-SemiBold.woff") format("woff");
font-weight: 600;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-Bold.woff2") format("woff2"),
url("/fonts/Inter-Bold.woff") format("woff");
font-weight: 700;
font-style: normal;
font-display: swap;
}
</style>
6 changes: 6 additions & 0 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { addons } from "@storybook/manager-api";
import digitalServiceTheme from "./DigitalServiceTheme";

addons.setConfig({
theme: digitalServiceTheme,
});
159 changes: 159 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<style>
@font-face {
font-family: BundesSansWeb;
font-style: normal;
font-weight: 400;
font-display: swap;
src:
url("./fonts/BundesSansWeb-Regular.woff2") format("woff2"),
url("./fonts/BundesSansWeb-Regular.woff") format("woff");
}
@font-face {
font-family: BundesSansWeb;
font-style: italic;
font-weight: 400;
font-display: swap;
src:
url("./fonts/BundesSansWeb-Italic.woff2") format("woff2"),
url("./fonts/BundesSansWeb-Italic.woff") format("woff");
}
@font-face {
font-family: BundesSansWeb;
font-style: normal;
font-weight: 700;
font-display: swap;
src:
url("./fonts/BundesSansWeb-Bold.woff2") format("woff2"),
url("./fonts/BundesSansWeb-Bold.woff") format("woff");
}
@font-face {
font-family: BundesSansWeb;
font-style: italic;
font-weight: 700;
font-display: swap;
src:
url("./fonts/BundesSansWeb-BoldItalic.woff2") format("woff2"),
url("./fonts/BundesSansWeb-BoldItalic.woff") format("woff");
}
/* BundesSerif */
@font-face {
font-family: BundesSerifWeb;
font-style: normal;
font-weight: 400;
font-display: swap;
src:
url("./fonts/BundesSerifWeb-Regular.woff2") format("woff2"),
url("./fonts/BundesSerifWeb-Regular.woff") format("woff");
}
@font-face {
font-family: BundesSerifWeb;
font-style: italic;
font-weight: 400;
font-display: swap;
src:
url("./fonts/BundesSerifWeb-Italic.woff2") format("woff2"),
url("./fonts/BundesSerifWeb-Italic.woff") format("woff");
}
@font-face {
font-family: BundesSerifWeb;
font-style: normal;
font-weight: 700;
font-display: swap;
src:
url("./fonts/BundesSerifWeb-Bold.woff2") format("woff2"),
url("./fonts/BundesSerifWeb-Bold.woff") format("woff");
}
@font-face {
font-family: BundesSerifWeb;
font-style: italic;
font-weight: 700;
font-display: swap;
src:
url("./fonts/BundesSerifWeb-BoldItalic.woff2") format("woff2"),
url("./fonts/BundesSerifWeb-BoldItalic.woff") format("woff");
}
/* BundesSans Condensed */
@font-face {
font-family: BundesSansCondWeb;
font-style: normal;
font-weight: 400;
font-display: swap;
src:
url("./fonts/BundesSansCondWeb.woff2") format("woff2"),
url("./fonts/BundesSansCondWeb.woff") format("woff");
}
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-Light.woff2") format("woff2"),
url("/fonts/Inter-Light.woff") format("woff");
font-weight: 300;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-Regular.woff2") format("woff2"),
url("/fonts/Inter-Regular.woff") format("woff");
font-weight: normal;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-Medium.woff2") format("woff2"),
url("/fonts/Inter-Medium.woff") format("woff");
font-weight: 500;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-SemiBold.woff2") format("woff2"),
url("/fonts/Inter-SemiBold.woff") format("woff");
font-weight: 600;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: Inter;
src:
url("/fonts/Inter-Bold.woff2") format("woff2"),
url("/fonts/Inter-Bold.woff") format("woff");
font-weight: 700;
font-style: normal;
font-display: swap;
}
.sbdocs-content > :not(.sb-unstyled),
.sbdocs-content > :not(.sb-unstyled) * {
font-family: Inter, Arial, sans-serif;
}

.sbdocs-preview,
#storybook-root * {
font-family: BundesSansWeb, Calibri, Verdana, Arial, Helvetica, sans-serif;
}

.sbdocs a {
color: #00f;
text-decoration: underline;
}
</style>

<script src="https://unpkg.com/magic-snowflakes/dist/snowflakes.min.js"></script>
<script>
window.sfLoaded = false;
document.addEventListener("DOMContentLoaded", function () {
if (!window.sfLoaded) {
var sf = new Snowflakes({
color: "#0000ff",
count: 10,
minOpacity: 0.2,
});
window.sfLoaded = true;
}
});
</script>
28 changes: 28 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import "../_site/fonts.css";
import "../build/styles.css";

/** @type { import('@storybook/html').Preview } */
const preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
options: {
storySort: {
order: [
"Homepage",
"Styleguide",
"Accessibility",
"Components",
"Development",
],
},
},
},
};

export default preview;
Loading

0 comments on commit c5c79d5

Please sign in to comment.