diff --git a/.prettierignore b/.prettierignore index ce1fd035b..2f11e4f94 100644 --- a/.prettierignore +++ b/.prettierignore @@ -9,4 +9,5 @@ node_modules/ # Generated apps/frontend/src/gql/*.ts apps/frontend/src/gql-fragments.json -apps/backend/src/graphql/__generated__/* \ No newline at end of file +apps/backend/src/graphql/__generated__/* +examples/storybook \ No newline at end of file diff --git a/examples/storybook/.eslintrc.cjs b/examples/storybook/.eslintrc.cjs new file mode 100644 index 000000000..200a16658 --- /dev/null +++ b/examples/storybook/.eslintrc.cjs @@ -0,0 +1,19 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react-hooks/recommended", + "plugin:storybook/recommended", + ], + ignorePatterns: ["dist", ".eslintrc.cjs"], + parser: "@typescript-eslint/parser", + plugins: ["react-refresh"], + rules: { + "react-refresh/only-export-components": [ + "warn", + { allowConstantExport: true }, + ], + }, +}; diff --git a/examples/storybook/.github/workflows/ci.yml b/examples/storybook/.github/workflows/ci.yml new file mode 100644 index 000000000..c16af1afc --- /dev/null +++ b/examples/storybook/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: Argos + Storybook and Storycap +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + + - name: Install dependencies + run: npm ci + + - name: Build Storybook + run: npm exec -- storybook build --output-dir ./storybook-static + + - name: Screenshot Storybook with Storycap + run: npm exec -- storycap --outDir ./screenshots --serverCmd "npx http-server ./storybook-static --port 6006" http://127.0.0.1:6006 + + - name: Upload screenshots to Argos + run: npm exec -- argos upload ./screenshots + env: + ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }} diff --git a/examples/storybook/.gitignore b/examples/storybook/.gitignore new file mode 100644 index 000000000..7383759f6 --- /dev/null +++ b/examples/storybook/.gitignore @@ -0,0 +1,30 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +# Storybook build output +/storybook-static + +# Storycap screenshots +/screenshots \ No newline at end of file diff --git a/examples/storybook/.storybook/main.ts b/examples/storybook/.storybook/main.ts new file mode 100644 index 000000000..6d68d18ca --- /dev/null +++ b/examples/storybook/.storybook/main.ts @@ -0,0 +1,19 @@ +import type { StorybookConfig } from "@storybook/react-vite"; + +const config: StorybookConfig = { + stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], + addons: [ + "@storybook/addon-links", + "@storybook/addon-essentials", + "@storybook/addon-onboarding", + "@storybook/addon-interactions", + ], + framework: { + name: "@storybook/react-vite", + options: {}, + }, + docs: { + autodocs: "tag", + }, +}; +export default config; diff --git a/examples/storybook/.storybook/preview.ts b/examples/storybook/.storybook/preview.ts new file mode 100644 index 000000000..ff58bbda2 --- /dev/null +++ b/examples/storybook/.storybook/preview.ts @@ -0,0 +1,15 @@ +import type { Preview } from "@storybook/react"; + +const preview: Preview = { + parameters: { + actions: { argTypesRegex: "^on[A-Z].*" }, + controls: { + matchers: { + color: /(background|color)$/i, + date: /Date$/i, + }, + }, + }, +}; + +export default preview; diff --git a/examples/storybook/README.md b/examples/storybook/README.md new file mode 100644 index 000000000..1447ddf0f --- /dev/null +++ b/examples/storybook/README.md @@ -0,0 +1,22 @@ +

+ + Argos + +

+ +# Example of Argos + Storybook and Storycap + +This example showcases Argos Visual Testing integrated to [Storybook](https://storybook.js.org/) using [Storycap](https://github.com/reg-viz/storycap) to capture screenshots. + +## Integrate with CI + +This example shows how configure GitHub Actions to run build Storybook and capture screenshots with Storycap on your CI. + +Read Argos' [Storybook Quickstart](https://argos-ci.com/docs/quickstart/storybook) to learn how to integrate Argos with Storybook. + +## Links + +- [Official Argos Docs](https://argos-ci.com/docs) +- [Storybook Quickstart](https://argos-ci.com/docs/quickstart/storybook) +- [Storycap Documentation](https://github.com/reg-viz/storycap) +- [Argos Discord](https://argos-ci.com/discord) diff --git a/examples/storybook/index.html b/examples/storybook/index.html new file mode 100644 index 000000000..e0d1c8408 --- /dev/null +++ b/examples/storybook/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/examples/storybook/package.json b/examples/storybook/package.json new file mode 100644 index 000000000..eb85790a9 --- /dev/null +++ b/examples/storybook/package.json @@ -0,0 +1,44 @@ +{ + "name": "storybook-example", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview", + "storybook": "storybook dev -p 6006", + "build-storybook": "storybook build" + }, + "dependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@argos-ci/cli": "^1.0.9", + "@storybook/addon-essentials": "^7.6.12", + "@storybook/addon-interactions": "^7.6.12", + "@storybook/addon-links": "^7.6.12", + "@storybook/addon-onboarding": "^1.0.11", + "@storybook/blocks": "^7.6.12", + "@storybook/react": "^7.6.12", + "@storybook/react-vite": "^7.6.12", + "@storybook/test": "^7.6.12", + "@types/react": "^18.2.43", + "@types/react-dom": "^18.2.17", + "@typescript-eslint/eslint-plugin": "^6.14.0", + "@typescript-eslint/parser": "^6.14.0", + "@vitejs/plugin-react": "^4.2.1", + "eslint": "^8.55.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.4.5", + "eslint-plugin-storybook": "^0.6.15", + "http-server": "^14.1.1", + "puppeteer": "^21.11.0", + "storybook": "^7.6.12", + "storycap": "^4.2.0", + "typescript": "^5.2.2", + "vite": "^5.0.8" + } +} diff --git a/examples/storybook/public/vite.svg b/examples/storybook/public/vite.svg new file mode 100644 index 000000000..e7b8dfb1b --- /dev/null +++ b/examples/storybook/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/storybook/src/App.css b/examples/storybook/src/App.css new file mode 100644 index 000000000..b9d355df2 --- /dev/null +++ b/examples/storybook/src/App.css @@ -0,0 +1,42 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #646cffaa); +} +.logo.react:hover { + filter: drop-shadow(0 0 2em #61dafbaa); +} + +@keyframes logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +@media (prefers-reduced-motion: no-preference) { + a:nth-of-type(2) .logo { + animation: logo-spin infinite 20s linear; + } +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} diff --git a/examples/storybook/src/App.tsx b/examples/storybook/src/App.tsx new file mode 100644 index 000000000..52ea980f3 --- /dev/null +++ b/examples/storybook/src/App.tsx @@ -0,0 +1,35 @@ +import { useState } from "react"; +import reactLogo from "./assets/react.svg"; +import viteLogo from "/vite.svg"; +import "./App.css"; + +function App() { + const [count, setCount] = useState(0); + + return ( + <> +
+ + Vite logo + + + React logo + +
+

Vite + React

+
+ +

+ Edit src/App.tsx and save to test HMR +

+
+

+ Click on the Vite and React logos to learn more +

+ + ); +} + +export default App; diff --git a/examples/storybook/src/assets/react.svg b/examples/storybook/src/assets/react.svg new file mode 100644 index 000000000..6c87de9bb --- /dev/null +++ b/examples/storybook/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/storybook/src/index.css b/examples/storybook/src/index.css new file mode 100644 index 000000000..6119ad9a8 --- /dev/null +++ b/examples/storybook/src/index.css @@ -0,0 +1,68 @@ +:root { + font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/examples/storybook/src/main.tsx b/examples/storybook/src/main.tsx new file mode 100644 index 000000000..966f17a4b --- /dev/null +++ b/examples/storybook/src/main.tsx @@ -0,0 +1,10 @@ +import React from "react"; +import ReactDOM from "react-dom/client"; +import App from "./App.tsx"; +import "./index.css"; + +ReactDOM.createRoot(document.getElementById("root")!).render( + + + +); diff --git a/examples/storybook/src/stories/Button.stories.ts b/examples/storybook/src/stories/Button.stories.ts new file mode 100644 index 000000000..5e29e9ac6 --- /dev/null +++ b/examples/storybook/src/stories/Button.stories.ts @@ -0,0 +1,50 @@ +import type { Meta, StoryObj } from "@storybook/react"; + +import { Button } from "./Button"; + +// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export +const meta = { + title: "Example/Button", + component: Button, + parameters: { + // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout + layout: "centered", + }, + // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs + tags: ["autodocs"], + // More on argTypes: https://storybook.js.org/docs/api/argtypes + argTypes: { + backgroundColor: { control: "color" }, + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args +export const Primary: Story = { + args: { + primary: true, + label: "Button", + }, +}; + +export const Secondary: Story = { + args: { + label: "Button", + }, +}; + +export const Large: Story = { + args: { + size: "large", + label: "Button", + }, +}; + +export const Small: Story = { + args: { + size: "small", + label: "Button", + }, +}; diff --git a/examples/storybook/src/stories/Button.tsx b/examples/storybook/src/stories/Button.tsx new file mode 100644 index 000000000..040db6511 --- /dev/null +++ b/examples/storybook/src/stories/Button.tsx @@ -0,0 +1,52 @@ +import React from "react"; +import "./button.css"; + +interface ButtonProps { + /** + * Is this the principal call to action on the page? + */ + primary?: boolean; + /** + * What background color to use + */ + backgroundColor?: string; + /** + * How large should the button be? + */ + size?: "small" | "medium" | "large"; + /** + * Button contents + */ + label: string; + /** + * Optional click handler + */ + onClick?: () => void; +} + +/** + * Primary UI component for user interaction + */ +export const Button = ({ + primary = false, + size = "medium", + backgroundColor, + label, + ...props +}: ButtonProps) => { + const mode = primary + ? "storybook-button--primary" + : "storybook-button--secondary"; + return ( + + ); +}; diff --git a/examples/storybook/src/stories/Configure.mdx b/examples/storybook/src/stories/Configure.mdx new file mode 100644 index 000000000..717600a28 --- /dev/null +++ b/examples/storybook/src/stories/Configure.mdx @@ -0,0 +1,369 @@ +import { Meta } from "@storybook/blocks"; + +import Github from "./assets/github.svg"; +import Discord from "./assets/discord.svg"; +import Youtube from "./assets/youtube.svg"; +import Tutorials from "./assets/tutorials.svg"; +import Styling from "./assets/styling.png"; +import Context from "./assets/context.png"; +import Assets from "./assets/assets.png"; +import Docs from "./assets/docs.png"; +import Share from "./assets/share.png"; +import FigmaPlugin from "./assets/figma-plugin.png"; +import Testing from "./assets/testing.png"; +import Accessibility from "./assets/accessibility.png"; +import Theming from "./assets/theming.png"; +import AddonLibrary from "./assets/addon-library.png"; + +export const RightArrow = () => ( + + + +); + + + +
+
+ # Configure your project + + Because Storybook works separately from your app, you'll need to configure it for your specific stack and setup. Below, explore guides for configuring Storybook with popular frameworks and tools. If you get stuck, learn how you can ask for help from our community. + +
+
+
+ A wall of logos representing different styling technologies +

Add styling and CSS

+

Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.

+ Learn more +
+
+ An abstraction representing the composition of data for a component +

Provide context and mocking

+

Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.

+ Learn more +
+
+ A representation of typography and image assets +
+

Load assets and resources

+

To link static files (like fonts) to your projects and stories, use the + `staticDirs` configuration option to specify folders to load when + starting Storybook.

+ Learn more +
+
+
+
+
+
+ # Do more with Storybook + + Now that you know the basics, let's explore other parts of Storybook that will improve your experience. This list is just to get you started. You can customise Storybook in many ways to fit your needs. + +
+ +
+
+
+ A screenshot showing the autodocs tag being set, pointing a docs page being generated +

Autodocs

+

Auto-generate living, + interactive reference documentation from your components and stories.

+ Learn more +
+
+ A browser window showing a Storybook being published to a chromatic.com URL +

Publish to Chromatic

+

Publish your Storybook to review and collaborate with your entire team.

+ Learn more +
+
+ Windows showing the Storybook plugin in Figma +

Figma Plugin

+

Embed your stories into Figma to cross-reference the design and live + implementation in one place.

+ Learn more +
+
+ Screenshot of tests passing and failing +

Testing

+

Use stories to test a component in all its variations, no matter how + complex.

+ Learn more +
+
+ Screenshot of accessibility tests passing and failing +

Accessibility

+

Automatically test your components for a11y issues as you develop.

+ Learn more +
+
+ Screenshot of Storybook in light and dark mode +

Theming

+

Theme Storybook's UI to personalize it to your project.

+ Learn more +
+
+
+
+
+
+

Addons

+

Integrate your tools with Storybook to connect workflows.

+ Discover all addons +
+
+ Integrate your tools with Storybook to connect workflows. +
+
+ +
+
+ Github logo + Join our contributors building the future of UI development. + + Star on GitHub +
+
+ Discord logo +
+ Get support and chat with frontend developers. + + Join Discord server +
+
+
+ Youtube logo +
+ Watch tutorials, feature previews and interviews. + + Watch on YouTube +
+
+
+ A book +

Follow guided walkthroughs on for key workflows.

+ + Discover tutorials +
+ +
+ + diff --git a/examples/storybook/src/stories/Header.stories.ts b/examples/storybook/src/stories/Header.stories.ts new file mode 100644 index 000000000..61cf98aa0 --- /dev/null +++ b/examples/storybook/src/stories/Header.stories.ts @@ -0,0 +1,27 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import { Header } from './Header'; + +const meta = { + title: 'Example/Header', + component: Header, + // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs + tags: ['autodocs'], + parameters: { + // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout + layout: 'fullscreen', + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const LoggedIn: Story = { + args: { + user: { + name: 'Jane Doe', + }, + }, +}; + +export const LoggedOut: Story = {}; diff --git a/examples/storybook/src/stories/Header.tsx b/examples/storybook/src/stories/Header.tsx new file mode 100644 index 000000000..6ce992c6b --- /dev/null +++ b/examples/storybook/src/stories/Header.tsx @@ -0,0 +1,71 @@ +import React from "react"; + +import { Button } from "./Button"; +import "./header.css"; + +type User = { + name: string; +}; + +interface HeaderProps { + user?: User; + onLogin: () => void; + onLogout: () => void; + onCreateAccount: () => void; +} + +export const Header = ({ + user, + onLogin, + onLogout, + onCreateAccount, +}: HeaderProps) => ( +
+
+
+ + + + + + + +

Acme

+
+
+ {user ? ( + <> + + Welcome, {user.name}! + +
+
+
+); diff --git a/examples/storybook/src/stories/Page.stories.ts b/examples/storybook/src/stories/Page.stories.ts new file mode 100644 index 000000000..f7a06817f --- /dev/null +++ b/examples/storybook/src/stories/Page.stories.ts @@ -0,0 +1,32 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { within, userEvent, expect } from '@storybook/test'; + +import { Page } from './Page'; + +const meta = { + title: 'Example/Page', + component: Page, + parameters: { + // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout + layout: 'fullscreen', + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const LoggedOut: Story = {}; + +// More on interaction testing: https://storybook.js.org/docs/writing-tests/interaction-testing +export const LoggedIn: Story = { + play: async ({ canvasElement }) => { + const canvas = within(canvasElement); + const loginButton = canvas.getByRole('button', { name: /Log in/i }); + await expect(loginButton).toBeInTheDocument(); + await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = canvas.getByRole('button', { name: /Log out/i }); + await expect(logoutButton).toBeInTheDocument(); + }, +}; diff --git a/examples/storybook/src/stories/Page.tsx b/examples/storybook/src/stories/Page.tsx new file mode 100644 index 000000000..3a9df5456 --- /dev/null +++ b/examples/storybook/src/stories/Page.tsx @@ -0,0 +1,91 @@ +import React from "react"; + +import { Header } from "./Header"; +import "./page.css"; + +type User = { + name: string; +}; + +export const Page: React.FC = () => { + const [user, setUser] = React.useState(); + + return ( +
+
setUser({ name: "Jane Doe" })} + onLogout={() => setUser(undefined)} + onCreateAccount={() => setUser({ name: "Jane Doe" })} + /> + +
+

Pages in Storybook

+

+ We recommend building UIs with a{" "} + + component-driven + {" "} + process starting with atomic components and ending with pages. +

+

+ Render pages with mock data. This makes it easy to build and review + page states without needing to navigate to them in your app. Here are + some handy patterns for managing page data in Storybook: +

+
    +
  • + Use a higher-level connected component. Storybook helps you compose + such data from the "args" of child component stories +
  • +
  • + Assemble data in the page component from your services. You can mock + these services out using Storybook. +
  • +
+

+ Get a guided tutorial on component-driven development at{" "} + + Storybook tutorials + + . Read more in the{" "} + + docs + + . +

+
+ Tip Adjust the width of the canvas with + the{" "} + + + + + + Viewports addon in the toolbar +
+
+
+ ); +}; diff --git a/examples/storybook/src/stories/assets/accessibility.png b/examples/storybook/src/stories/assets/accessibility.png new file mode 100644 index 000000000..6ffe6feab Binary files /dev/null and b/examples/storybook/src/stories/assets/accessibility.png differ diff --git a/examples/storybook/src/stories/assets/accessibility.svg b/examples/storybook/src/stories/assets/accessibility.svg new file mode 100644 index 000000000..a3288830e --- /dev/null +++ b/examples/storybook/src/stories/assets/accessibility.svg @@ -0,0 +1,5 @@ + + Accessibility + + + \ No newline at end of file diff --git a/examples/storybook/src/stories/assets/addon-library.png b/examples/storybook/src/stories/assets/addon-library.png new file mode 100644 index 000000000..95deb38a8 Binary files /dev/null and b/examples/storybook/src/stories/assets/addon-library.png differ diff --git a/examples/storybook/src/stories/assets/assets.png b/examples/storybook/src/stories/assets/assets.png new file mode 100644 index 000000000..cfba6817a Binary files /dev/null and b/examples/storybook/src/stories/assets/assets.png differ diff --git a/examples/storybook/src/stories/assets/avif-test-image.avif b/examples/storybook/src/stories/assets/avif-test-image.avif new file mode 100644 index 000000000..530709bc1 Binary files /dev/null and b/examples/storybook/src/stories/assets/avif-test-image.avif differ diff --git a/examples/storybook/src/stories/assets/context.png b/examples/storybook/src/stories/assets/context.png new file mode 100644 index 000000000..e5cd249a2 Binary files /dev/null and b/examples/storybook/src/stories/assets/context.png differ diff --git a/examples/storybook/src/stories/assets/discord.svg b/examples/storybook/src/stories/assets/discord.svg new file mode 100644 index 000000000..1204df998 --- /dev/null +++ b/examples/storybook/src/stories/assets/discord.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/storybook/src/stories/assets/docs.png b/examples/storybook/src/stories/assets/docs.png new file mode 100644 index 000000000..a749629df Binary files /dev/null and b/examples/storybook/src/stories/assets/docs.png differ diff --git a/examples/storybook/src/stories/assets/figma-plugin.png b/examples/storybook/src/stories/assets/figma-plugin.png new file mode 100644 index 000000000..8f79b08cd Binary files /dev/null and b/examples/storybook/src/stories/assets/figma-plugin.png differ diff --git a/examples/storybook/src/stories/assets/github.svg b/examples/storybook/src/stories/assets/github.svg new file mode 100644 index 000000000..158e0268a --- /dev/null +++ b/examples/storybook/src/stories/assets/github.svg @@ -0,0 +1,3 @@ + + + diff --git a/examples/storybook/src/stories/assets/share.png b/examples/storybook/src/stories/assets/share.png new file mode 100644 index 000000000..8097a3707 Binary files /dev/null and b/examples/storybook/src/stories/assets/share.png differ diff --git a/examples/storybook/src/stories/assets/styling.png b/examples/storybook/src/stories/assets/styling.png new file mode 100644 index 000000000..d341e8263 Binary files /dev/null and b/examples/storybook/src/stories/assets/styling.png differ diff --git a/examples/storybook/src/stories/assets/testing.png b/examples/storybook/src/stories/assets/testing.png new file mode 100644 index 000000000..d4ac39a0c Binary files /dev/null and b/examples/storybook/src/stories/assets/testing.png differ diff --git a/examples/storybook/src/stories/assets/theming.png b/examples/storybook/src/stories/assets/theming.png new file mode 100644 index 000000000..1535eb9b8 Binary files /dev/null and b/examples/storybook/src/stories/assets/theming.png differ diff --git a/examples/storybook/src/stories/assets/tutorials.svg b/examples/storybook/src/stories/assets/tutorials.svg new file mode 100644 index 000000000..4b2fc7c44 --- /dev/null +++ b/examples/storybook/src/stories/assets/tutorials.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/examples/storybook/src/stories/assets/youtube.svg b/examples/storybook/src/stories/assets/youtube.svg new file mode 100644 index 000000000..33a3a61f6 --- /dev/null +++ b/examples/storybook/src/stories/assets/youtube.svg @@ -0,0 +1,4 @@ + + + + diff --git a/examples/storybook/src/stories/button.css b/examples/storybook/src/stories/button.css new file mode 100644 index 000000000..663afa404 --- /dev/null +++ b/examples/storybook/src/stories/button.css @@ -0,0 +1,30 @@ +.storybook-button { + font-family: "Nunito Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight: 700; + border: 0; + border-radius: 3em; + cursor: pointer; + display: inline-block; + line-height: 1; +} +.storybook-button--primary { + color: white; + background-color: #1ea7fd; +} +.storybook-button--secondary { + color: #333; + background-color: transparent; + box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset; +} +.storybook-button--small { + font-size: 12px; + padding: 10px 16px; +} +.storybook-button--medium { + font-size: 14px; + padding: 11px 20px; +} +.storybook-button--large { + font-size: 16px; + padding: 12px 24px; +} diff --git a/examples/storybook/src/stories/header.css b/examples/storybook/src/stories/header.css new file mode 100644 index 000000000..d418c42ce --- /dev/null +++ b/examples/storybook/src/stories/header.css @@ -0,0 +1,32 @@ +.storybook-header { + font-family: "Nunito Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + border-bottom: 1px solid rgba(0, 0, 0, 0.1); + padding: 15px 20px; + display: flex; + align-items: center; + justify-content: space-between; +} + +.storybook-header svg { + display: inline-block; + vertical-align: top; +} + +.storybook-header h1 { + font-weight: 700; + font-size: 20px; + line-height: 1; + margin: 6px 0 6px 10px; + display: inline-block; + vertical-align: top; +} + +.storybook-header button + button { + margin-left: 10px; +} + +.storybook-header .welcome { + color: #333; + font-size: 14px; + margin-right: 10px; +} diff --git a/examples/storybook/src/stories/page.css b/examples/storybook/src/stories/page.css new file mode 100644 index 000000000..32fc9ecdc --- /dev/null +++ b/examples/storybook/src/stories/page.css @@ -0,0 +1,69 @@ +.storybook-page { + font-family: "Nunito Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + line-height: 24px; + padding: 48px 20px; + margin: 0 auto; + max-width: 600px; + color: #333; +} + +.storybook-page h2 { + font-weight: 700; + font-size: 32px; + line-height: 1; + margin: 0 0 4px; + display: inline-block; + vertical-align: top; +} + +.storybook-page p { + margin: 1em 0; +} + +.storybook-page a { + text-decoration: none; + color: #1ea7fd; +} + +.storybook-page ul { + padding-left: 30px; + margin: 1em 0; +} + +.storybook-page li { + margin-bottom: 8px; +} + +.storybook-page .tip { + display: inline-block; + border-radius: 1em; + font-size: 11px; + line-height: 12px; + font-weight: 700; + background: #e7fdd8; + color: #66bf3c; + padding: 4px 12px; + margin-right: 10px; + vertical-align: top; +} + +.storybook-page .tip-wrapper { + font-size: 13px; + line-height: 20px; + margin-top: 40px; + margin-bottom: 40px; +} + +.storybook-page .tip-wrapper svg { + display: inline-block; + height: 12px; + width: 12px; + margin-right: 4px; + vertical-align: top; + margin-top: 3px; +} + +.storybook-page .tip-wrapper svg path { + fill: #1ea7fd; +} diff --git a/examples/storybook/src/vite-env.d.ts b/examples/storybook/src/vite-env.d.ts new file mode 100644 index 000000000..11f02fe2a --- /dev/null +++ b/examples/storybook/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/storybook/tsconfig.json b/examples/storybook/tsconfig.json new file mode 100644 index 000000000..a7fc6fbf2 --- /dev/null +++ b/examples/storybook/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/examples/storybook/tsconfig.node.json b/examples/storybook/tsconfig.node.json new file mode 100644 index 000000000..42872c59f --- /dev/null +++ b/examples/storybook/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/examples/storybook/vite.config.ts b/examples/storybook/vite.config.ts new file mode 100644 index 000000000..9cc50ead1 --- /dev/null +++ b/examples/storybook/vite.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +});