2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Added new package for admin-x settings

refs https://github.com/TryGhost/Team/issues/3151

- adds a new vite + typescript + storybook + TW package for setting up admin settings in react with base config that works with Ghost monorepo
- includes base components/design system for new settings UI
- adds eslint rule config to the package to match rest of Ghost codebase
- this is an experimental package as we figure out the best patterns for new admin packages in Ghost monorepo

Co-authored-by: Peter Zimon <zimo@ghost.org>
This commit is contained in:
Rishabh 2023-05-16 11:53:36 +05:30 committed by Rishabh Garg
parent 2a16b1427d
commit 3d6fb0d6b1
60 changed files with 4710 additions and 84 deletions

4
.gitignore vendored
View file

@ -138,3 +138,7 @@ Caddyfile
# Typescript build artifacts
/ghost/*/tsconfig.tsbuildinfo
# Admin X
/ghost/admin-x-settings/dist
/ghost/admin-x-settings/dist-ssr

View file

@ -0,0 +1,42 @@
/* eslint-env node */
module.exports = {
root: true,
extends: [
'react-app',
'plugin:ghost/browser',
'plugin:react/recommended'
],
plugins: [
'ghost',
'tailwindcss'
],
rules: {
// sort multiple import lines into alphabetical groups
'ghost/sort-imports-es6-autofix/sort-imports-es6': ['error', {
memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple']
}],
// suppress errors for missing 'import React' in JSX files, as we don't need it
'react/react-in-jsx-scope': 'off',
// ignore prop-types for now
'react/prop-types': 'off',
// custom react rules
'react/jsx-sort-props': ['error', {
reservedFirst: true,
callbacksLast: true,
shorthandLast: true,
locale: 'en'
}],
'react/button-has-type': 'error',
'react/no-array-index-key': 'error',
'tailwindcss/classnames-order': ['error', {config: 'tailwind.config.cjs'}],
'tailwindcss/enforces-negative-arbitrary-values': ['warn', {config: 'tailwind.config.cjs'}],
'tailwindcss/enforces-shorthand': ['warn', {config: 'tailwind.config.cjs'}],
'tailwindcss/migration-from-tailwind-2': ['warn', {config: 'tailwind.config.cjs'}],
'tailwindcss/no-arbitrary-value': 'off',
'tailwindcss/no-custom-classname': 'off',
'tailwindcss/no-contradicting-classname': ['error', {config: 'tailwind.config.cjs'}]
}
};

View file

@ -0,0 +1,27 @@
import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
{
name: '@storybook/addon-styling',
},
],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
staticDirs: ['../public/fonts'],
async viteFinal(config, options) {
config.resolve.alias = {
crypto: require.resolve('rollup-plugin-node-builtins'),
}
return config;
},
};
export default config;

View file

@ -0,0 +1,16 @@
import '../src/styles/index.css';
import type { Preview } from "@storybook/react";
const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};
export default preview;

View file

@ -0,0 +1,48 @@
# Admin X Settings
Experimental re-write of Ghost Admin Settings in React
## Development
### Pre-requisites
- Run `yarn` in Ghost monorepo root
- Run `yarn` in this directory
### Running the development version
Run `yarn dev` to start the development server to test/develop the settings standalone. This will generate a demo site from the `index.html` file which renders the app and makes it available on http://localhost:5173
### Running inside Admin
To test/develop inside of Admin you can run `yarn preview` then in Ghost set your `adminX` value in `config.local.json` to `http://localhost:4173/admin-x-settings.umd.js` and load Admin as usual. Replace Ghost Admin's `settings` url with `settings-x` to load the new settings.
```json
{
...
"adminX": {
"url": "http://localhost:4173/admin-x-settings.umd.js"
}
}
```
`yarn preview` by itself only serves the library files, it's possible ro run `yarn build --watch` in a separate terminal tab to have auto-rebuild whilst developing.
## Usage
## Develop
This is a monorepo package.
Follow the instructions for the top-level repo.
1. `git clone` this repo & `cd` into it as usual
2. Run `yarn` to install top-level dependencies.
## Test
- `yarn lint` run just eslint
- `yarn test` run lint and tests

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Settings - Admin</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View file

@ -0,0 +1,73 @@
{
"name": "@tryghost/admin-x-settings",
"version": "0.0.0",
"repository": "https://github.com/TryGhost/Ghost/tree/main/packages/admin-x-settings",
"author": "Ghost Foundation",
"private": true,
"type": "module",
"files": [
"LICENSE",
"README.md",
"dist/"
],
"main": "./dist/admin-x-settings.umd.cjs",
"module": "./dist/admin-x-settings.js",
"exports": {
".": {
"import": "./dist/admin-x-settings.js",
"require": "./dist/admin-x-settings.umd.cjs"
}
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "yarn run lint:js",
"lint:js": "eslint --ext .js,.ts,.cjs,.tsx --cache src test",
"preview": "vite preview",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"preship": "yarn lint",
"ship": "STATUS=$(git status --porcelain); echo $STATUS; if [ -z \"$STATUS\" ]; then yarn version; fi",
"postship": "git push ${GHOST_UPSTREAM:-origin} --follow-tags && npm publish",
"prepublishOnly": "yarn build"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@storybook/addon-essentials": "7.0.9",
"@storybook/addon-interactions": "7.0.9",
"@storybook/addon-links": "7.0.9",
"@storybook/addon-styling": "1.0.6",
"@storybook/blocks": "7.0.9",
"@storybook/react": "7.0.9",
"@storybook/react-vite": "7.0.9",
"@storybook/testing-library": "0.1.0",
"@tailwindcss/forms": "0.5.3",
"@tailwindcss/line-clamp": "0.4.4",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.11",
"@typescript-eslint/eslint-plugin": "5.57.1",
"@typescript-eslint/parser": "5.57.1",
"@vitejs/plugin-react": "4.0.0",
"autoprefixer": "10.4.14",
"eslint": "8.38.0",
"eslint-config-react-app": "7.0.1",
"eslint-plugin-ghost": "2.18.0",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-react-refresh": "0.3.4",
"eslint-plugin-tailwindcss": "3.11.0",
"postcss": "8.4.23",
"prop-types": "15.8.1",
"rollup-plugin-node-builtins": "2.1.2",
"storybook": "7.0.9",
"tailwindcss": "3.3.2",
"typescript": "5.0.2",
"vite": "4.3.2",
"stylelint": "15.6.1",
"vite-plugin-svgr": "3.2.0",
"vitest": "0.31.0"
}
}

View file

@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

Binary file not shown.

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,31 @@
import Settings from './components/Settings';
import Sidebar from './components/Sidebar';
function App() {
return (
<div>
<button
className="fixed left-6 top-4 text-sm font-bold text-black"
type="button"
onClick={() => window.history.back()}
>
&larr; Done
</button>
{/* Main container */}
<div className="mx-auto flex max-w-[1080px] flex-col px-[5vmin] py-[12vmin] md:flex-row md:items-start md:gap-x-10 md:py-[8vmin]">
{/* Sidebar */}
<div className="relative grow-0 md:sticky md:top-[8vmin] md:basis-[240px]">
<h1 className="font-inter text-5xl">Settings</h1>
<Sidebar />
</div>
<div className="flex-auto pt-[3vmin] md:pt-[72px]">
<Settings />
</div>
</div>
</div>
);
}
export default App;

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -0,0 +1,13 @@
import React from 'react';
import GeneralSettings from './settings/general/GeneralSettings';
const Settings: React.FC = () => {
return (
<>
<GeneralSettings />
</>
);
};
export default Settings;

View file

@ -0,0 +1,48 @@
import React from 'react';
import SettingNavItem from './design-system/settings/SettingNavItem';
import SettingNavSection from './design-system/settings/SettingNavSection';
const Sidebar: React.FC = () => {
return (
<div className="mt-6 hidden md:block">
<SettingNavSection name="General">
<SettingNavItem name="Title and description" />
<SettingNavItem name="Timezone" />
<SettingNavItem name="Publication language" />
<SettingNavItem name="Meta data" />
<SettingNavItem name="Twitter card" />
<SettingNavItem name="Facebook card" />
<SettingNavItem name="Social accounts" />
<SettingNavItem name="Make this site private" />
<SettingNavItem name="Users and permissions" />
</SettingNavSection>
<SettingNavSection name="Site">
<SettingNavItem name="Branding and design" />
<SettingNavItem name="Navigation" />
</SettingNavSection>
<SettingNavSection name="Membership">
<SettingNavItem name="Portal" />
<SettingNavItem name="Access" />
<SettingNavItem name="Tiers" />
<SettingNavItem name="Analytics" />
</SettingNavSection>
<SettingNavSection name="Email newsletters">
<SettingNavItem name="Newsletter sending" />
<SettingNavItem name="Newsletters" />
<SettingNavItem name="Default recipients" />
</SettingNavSection>
<SettingNavSection name="Advanced">
<SettingNavItem name="Integrations" />
<SettingNavItem name="Code injection" />
<SettingNavItem name="Labs" />
<SettingNavItem name="History" />
</SettingNavSection>
</div>
);
};
export default Sidebar;

View file

@ -0,0 +1,44 @@
import type {Meta, StoryObj} from '@storybook/react';
import {ExampleButton} from './ExampleButton';
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta = {
title: 'Experimental / Example Button',
component: ExampleButton,
tags: ['autodocs'],
argTypes: {
backgroundColor: {control: 'color'}
}
} satisfies Meta<typeof ExampleButton>;
export default meta;
type Story = StoryObj<typeof meta>;
// More on writing stories with args: https://storybook.js.org/docs/react/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'
}
};

View file

@ -0,0 +1,47 @@
import './button.css';
interface ExampleButtonProps {
/**
* 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 ExampleButton = ({
primary = false,
size = 'medium',
backgroundColor,
label,
...props
}: ExampleButtonProps) => {
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
return (
<button
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
style={{backgroundColor}}
type="button"
{...props}
>
{label}
</button>
);
};

View file

@ -0,0 +1,26 @@
import {Header} from './Header';
import type {Meta, StoryObj} from '@storybook/react';
const meta = {
title: 'Experimental / Header',
component: Header,
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
tags: ['autodocs'],
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
layout: 'fullscreen'
}
} satisfies Meta<typeof Header>;
export default meta;
type Story = StoryObj<typeof meta>;
export const LoggedIn: Story = {
args: {
user: {
name: 'Jane Doe'
}
}
};
export const LoggedOut: Story = {};

View file

@ -0,0 +1,54 @@
import './header.css';
import {ExampleButton} from './ExampleButton';
type User = {
name: string;
};
interface HeaderProps {
user?: User;
onLogin: () => void;
onLogout: () => void;
onCreateAccount: () => void;
}
export const Header = ({user, onLogin, onLogout, onCreateAccount}: HeaderProps) => (
<header>
<div className="wrapper">
<div>
<svg height="32" viewBox="0 0 32 32" width="32" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fillRule="evenodd">
<path
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
fill="#FFF"
/>
<path
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
fill="#555AB9"
/>
<path
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
fill="#91BAF8"
/>
</g>
</svg>
<h1>Acme</h1>
</div>
<div>
{user ? (
<>
<span className="welcome">
Welcome, <b>{user.name}</b>!
</span>
<ExampleButton label="Log out" size="small" onClick={onLogout} />
</>
) : (
<>
<ExampleButton label="Log in" size="small" onClick={onLogin} />
<ExampleButton label="Sign up" size="small" primary onClick={onCreateAccount} />
</>
)}
</div>
</div>
</header>
);

View file

@ -0,0 +1,213 @@
import { Meta } from '@storybook/blocks';
import Code from './assets/code-brackets.svg';
import Colors from './assets/colors.svg';
import Comments from './assets/comments.svg';
import Direction from './assets/direction.svg';
import Flow from './assets/flow.svg';
import Plugin from './assets/plugin.svg';
import Repo from './assets/repo.svg';
import StackAlt from './assets/stackalt.svg';
<Meta title="Example/Introduction" />
<style>
{`
.subheading {
--mediumdark: '#999999';
font-weight: 700;
font-size: 13px;
color: #999;
letter-spacing: 6px;
line-height: 24px;
text-transform: uppercase;
margin-bottom: 12px;
margin-top: 40px;
}
.link-list {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr 1fr;
row-gap: 10px;
}
@media (min-width: 620px) {
.link-list {
row-gap: 20px;
column-gap: 20px;
grid-template-columns: 1fr 1fr;
}
}
@media all and (-ms-high-contrast:none) {
.link-list {
display: -ms-grid;
-ms-grid-columns: 1fr 1fr;
-ms-grid-rows: 1fr 1fr;
}
}
.link-item {
display: block;
padding: 20px;
border: 1px solid #00000010;
border-radius: 5px;
transition: background 150ms ease-out, border 150ms ease-out, transform 150ms ease-out;
color: #333333;
display: flex;
align-items: flex-start;
}
.link-item:hover {
border-color: #1EA7FD50;
transform: translate3d(0, -3px, 0);
box-shadow: rgba(0, 0, 0, 0.08) 0 3px 10px 0;
}
.link-item:active {
border-color: #1EA7FD;
transform: translate3d(0, 0, 0);
}
.link-item strong {
font-weight: 700;
display: block;
margin-bottom: 2px;
}
.link-item img {
height: 40px;
width: 40px;
margin-right: 15px;
flex: none;
}
.link-item span,
.link-item p {
margin: 0;
font-size: 14px;
line-height: 20px;
}
.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;
}
.tip-wrapper {
font-size: 13px;
line-height: 20px;
margin-top: 40px;
margin-bottom: 40px;
}
.tip-wrapper code {
font-size: 12px;
display: inline-block;
}
`}
</style>
# Welcome to Storybook
Storybook helps you build UI components in isolation from your app's business logic, data, and context.
That makes it easy to develop hard-to-reach states. Save these UI states as **stories** to revisit during development, testing, or QA.
Browse example stories now by navigating to them in the sidebar.
View their code in the `stories` directory to learn how they work.
We recommend building UIs with a [**component-driven**](https://componentdriven.org) process starting with atomic components and ending with pages.
<div className="subheading">Configure</div>
<div className="link-list">
<a
className="link-item"
href="https://storybook.js.org/docs/react/addons/addon-types"
target="_blank"
>
<img src={Plugin} alt="plugin" />
<span>
<strong>Presets for popular tools</strong>
Easy setup for TypeScript, SCSS and more.
</span>
</a>
<a
className="link-item"
href="https://storybook.js.org/docs/react/configure/webpack"
target="_blank"
>
<img src={StackAlt} alt="Build" />
<span>
<strong>Build configuration</strong>
How to customize webpack and Babel
</span>
</a>
<a
className="link-item"
href="https://storybook.js.org/docs/react/configure/styling-and-css"
target="_blank"
>
<img src={Colors} alt="colors" />
<span>
<strong>Styling</strong>
How to load and configure CSS libraries
</span>
</a>
<a
className="link-item"
href="https://storybook.js.org/docs/react/get-started/setup#configure-storybook-for-your-stack"
target="_blank"
>
<img src={Flow} alt="flow" />
<span>
<strong>Data</strong>
Providers and mocking for data libraries
</span>
</a>
</div>
<div className="subheading">Learn</div>
<div className="link-list">
<a className="link-item" href="https://storybook.js.org/docs" target="_blank">
<img src={Repo} alt="repo" />
<span>
<strong>Storybook documentation</strong>
Configure, customize, and extend
</span>
</a>
<a className="link-item" href="https://storybook.js.org/tutorials/" target="_blank">
<img src={Direction} alt="direction" />
<span>
<strong>In-depth guides</strong>
Best practices from leading teams
</span>
</a>
<a className="link-item" href="https://github.com/storybookjs/storybook" target="_blank">
<img src={Code} alt="code" />
<span>
<strong>GitHub project</strong>
View the source and add issues
</span>
</a>
<a className="link-item" href="https://discord.gg/storybook" target="_blank">
<img src={Comments} alt="comments" />
<span>
<strong>Discord chat</strong>
Chat with maintainers and the community
</span>
</a>
</div>
<div className="tip-wrapper">
<span className="tip">Tip</span>Edit the Markdown in{' '}
<code>stories/Introduction.stories.mdx</code>
</div>

View file

@ -0,0 +1,29 @@
import {userEvent, within} from '@storybook/testing-library';
import type {Meta, StoryObj} from '@storybook/react';
import {Page} from './Page';
const meta = {
title: 'Experimental / Page',
component: Page,
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
layout: 'fullscreen'
}
} satisfies Meta<typeof Page>;
export default meta;
type Story = StoryObj<typeof meta>;
export const LoggedOut: Story = {};
// More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing
export const LoggedIn: Story = {
play: async ({canvasElement}) => {
const canvas = within(canvasElement);
const loginButton = await canvas.getByRole('button', {
name: /Log in/i
});
await userEvent.click(loginButton);
}
};

View file

@ -0,0 +1,73 @@
import React from 'react';
import './page.css';
import {Header} from './Header';
type User = {
name: string;
};
export const Page: React.FC = () => {
const [user, setUser] = React.useState<User>();
return (
<article>
<Header
user={user}
onCreateAccount={() => setUser({name: 'Jane Doe'})}
onLogin={() => setUser({name: 'Jane Doe'})}
onLogout={() => setUser(undefined)}
/>
<section>
<h2>Pages in Storybook</h2>
<p>
We recommend building UIs with a{' '}
<a href="https://componentdriven.org" rel="noopener noreferrer" target="_blank">
<strong>component-driven</strong>
</a>{' '}
process starting with atomic components and ending with pages.
</p>
<p>
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:
</p>
<ul>
<li>
Use a higher-level connected component. Storybook helps you compose such data from the
&quot;args&quot; of child component stories
</li>
<li>
Assemble data in the page component from your services. You can mock these services out
using Storybook.
</li>
</ul>
<p>
Get a guided tutorial on component-driven development at{' '}
<a href="https://storybook.js.org/tutorials/" rel="noopener noreferrer" target="_blank">
Storybook tutorials
</a>
. Read more in the{' '}
<a href="https://storybook.js.org/docs" rel="noopener noreferrer" target="_blank">
docs
</a>
.
</p>
<div className="tip-wrapper">
<span className="tip">Tip</span> Adjust the width of the canvas with the{' '}
<svg height="10" viewBox="0 0 12 12" width="10" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fillRule="evenodd">
<path
d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z"
fill="#999"
id="a"
/>
</g>
</svg>
Viewports addon in the toolbar
</div>
</section>
</article>
);
};

View file

@ -0,0 +1,37 @@
import Task from './Task';
const story = {
component: Task,
title: 'Experimental / Task',
tags: ['autodocs']
};
export default story;
export const Default = {
args: {
task: {
id: '1',
title: 'Test task',
state: 'TASK_INBOX'
}
}
};
export const Pinned = {
args: {
task: {
...Default.args.task,
state: 'TASK_PINNED'
}
}
};
export const Archived = {
args: {
task: {
...Default.args.task,
state: 'TASK_ARCHIVED'
}
}
};

View file

@ -0,0 +1,64 @@
import React from 'react';
interface Props {
task: {
id: string,
title: string,
state: string,
}
onArchiveTask: (id: string) => void,
onPinTask: (id: string) => void,
}
const Task: React.FC<Props> = ({task: {id, title, state}, onArchiveTask, onPinTask}) => {
return (
<div className={`list-item ${state}`}>
<label
aria-label={title}
className="checkbox"
htmlFor="title"
>
<input
checked={state === 'TASK_ARCHIVED'}
disabled={true}
id={`archiveTask-${id}`}
name="checked"
type="checkbox"
/>
<span
className="checkbox-custom"
onClick={() => onArchiveTask(id)}
/>
</label>
<label
aria-label={title}
className="title"
htmlFor="title"
>
<input
name="title"
placeholder="Input title"
readOnly={true}
type="text"
value={title}
/>
</label>
{state !== 'TASK_ARCHIVED' && (
<button
key={`pinTask-${id}`}
aria-label={`pinTask-${id}`}
className="pin-button"
id={`pinTask-${id}`}
type="button"
onClick={() => onPinTask(id)}
>
<span className={`icon-star`} />
</button>
)}
</div>
);
};
export default Task;

View file

@ -0,0 +1,46 @@
import TaskList from './Tasklist';
import * as TaskStories from './Task.stories';
const story = {
component: TaskList,
title: 'Experimental / Task List',
decorators: [(_story: any) => <div style={{padding: '3rem'}}>{_story()}</div>],
tags: ['autodocs']
};
export default story;
export const Default = {
args: {
tasks: [
{...TaskStories.Default.args.task, id: '1', title: 'Task 1'},
{...TaskStories.Default.args.task, id: '2', title: 'Task 2'},
{...TaskStories.Default.args.task, id: '3', title: 'Task 3'},
{...TaskStories.Default.args.task, id: '4', title: 'Task 4'}
]
}
};
export const WithPinnedTasks = {
args: {
tasks: [
...Default.args.tasks.slice(0, 3),
{id: '6', title: 'Task 6 (pinned)', state: 'TASK_PINNED'}
]
}
};
export const Loading = {
args: {
tasks: [],
loading: true
}
};
export const Empty = {
args: {
...Loading.args,
loading: false
}
};

View file

@ -0,0 +1,38 @@
import React from 'react';
import Task from './Task';
interface Props {
loading: boolean,
tasks: Array<{
id: string,
title: string,
state: string,
}>,
onArchiveTask: (id: string) => void,
onPinTask: (id: string) => void,
}
const TaskList: React.FC<Props> = ({loading, tasks, onPinTask, onArchiveTask}) => {
const events = {
onPinTask,
onArchiveTask
};
if (loading) {
return <div>Loading</div>;
}
if (tasks.length === 0) {
return <div>empty</div>;
}
return (
<div>
{tasks.map(task => (
<Task key={task.id} task={task} {...events} />
))}
</div>
);
};
export default TaskList;

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" version="1.1" viewBox="0 0 48 48"><title>illustration/code-brackets</title><g id="illustration/code-brackets" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><path id="Combined-Shape" fill="#87E6E5" d="M11.4139325,12 C11.7605938,12 12,12.5059743 12,13.3779712 L12,17.4951758 L6.43502246,23.3839989 C5.85499251,23.9978337 5.85499251,25.0021663 6.43502246,25.6160011 L12,31.5048242 L12,35.6220288 C12,36.4939606 11.7605228,37 11.4139325,37 C11.2725831,37 11.1134406,36.9158987 10.9453839,36.7379973 L0.435022463,25.6160011 C-0.145007488,25.0021663 -0.145007488,23.9978337 0.435022463,23.3839989 L10.9453839,12.2620027 C11.1134051,12.0841663 11.2725831,12 11.4139325,12 Z M36.5860675,12 C36.7274169,12 36.8865594,12.0841013 37.0546161,12.2620027 L47.5649775,23.3839989 C48.1450075,23.9978337 48.1450075,25.0021663 47.5649775,25.6160011 L37.0546161,36.7379973 C36.8865949,36.9158337 36.7274169,37 36.5860675,37 C36.2394062,37 36,36.4940257 36,35.6220288 L36,31.5048242 L41.5649775,25.6160011 C42.1450075,25.0021663 42.1450075,23.9978337 41.5649775,23.3839989 L36,17.4951758 L36,13.3779712 C36,12.5060394 36.2394772,12 36.5860675,12 Z"/><rect id="Rectangle-7-Copy-5" width="35.57" height="4" x="5.009" y="22.662" fill="#A0DB77" rx="2" transform="translate(22.793959, 24.662305) rotate(-75.000000) translate(-22.793959, -24.662305)"/></g></svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.3 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" version="1.1" viewBox="0 0 48 48"><title>illustration/comments</title><g id="illustration/comments" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><path id="Path" fill="#96D07C" d="M2.52730803,17.9196415 C2.44329744,17.9745167 2.36370847,18.000488 2.29303375,18.000488 C2.1197031,18.000488 2,17.8443588 2,17.5752855 L2,4 C2,1.790861 3.790861,3.23296945e-13 6,3.23296945e-13 L33.9995117,3.23296945e-13 C36.2086507,3.23296945e-13 37.9995117,1.790861 37.9995117,4 L37.9995117,9.999512 C37.9995117,12.208651 36.2086507,13.999512 33.9995117,13.999512 L8,13.999512 C7.83499225,13.999512 7.6723181,13.9895206 7.51254954,13.9701099 L2.52730803,17.9196415 Z"/><path id="Path" fill="#73E1E0" d="M7.51066,44.9703679 L2.52730803,47.9186655 C2.44329744,47.9735407 2.36370847,47.999512 2.29303375,47.999512 C2.1197031,47.999512 2,47.8433828 2,47.5743095 L2,35 C2,32.790861 3.790861,31 6,31 L26,31 C28.209139,31 30,32.790861 30,35 L30,41 C30,43.209139 28.209139,45 26,45 L8,45 C7.8343417,45 7.67103544,44.9899297 7.51066,44.9703679 Z"/><path id="Path" fill="#FFD476" d="M46,19.5 L46,33.0747975 C46,33.3438708 45.8802969,33.5 45.7069663,33.5 C45.6362915,33.5 45.5567026,33.4740287 45.472692,33.4191535 L40.4887103,29.4704446 C40.3285371,29.489956 40.1654415,29.5 40,29.5 L18,29.5 C15.790861,29.5 14,27.709139 14,25.5 L14,19.5 C14,17.290861 15.790861,15.5 18,15.5 L42,15.5 C44.209139,15.5 46,17.290861 46,19.5 Z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" version="1.1" viewBox="0 0 48 48"><title>illustration/direction</title><g id="illustration/direction" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><path id="Combined-Shape" fill="#FFD476" d="M23.4917015,33.6030641 L2.93840258,31.4321033 C2.38917316,31.3740904 1.99096346,30.8818233 2.04897631,30.3325939 C2.0747515,30.0885705 2.18934861,29.8625419 2.37095722,29.6975265 L34.2609105,0.721285325 C34.6696614,0.349881049 35.3021022,0.38015648 35.6735064,0.788907393 C35.9232621,1.06377731 36.0001133,1.45442096 35.8730901,1.80341447 L24.5364357,32.9506164 C24.3793473,33.3822133 23.9484565,33.6513092 23.4917015,33.6030641 L23.4917015,33.6030641 Z"/><path id="Combined-Shape-Copy" fill="#FFC445" d="M24.3163597,33.2881029 C24.0306575,33.0138462 23.9337246,32.5968232 24.069176,32.2246735 L35.091923,1.9399251 C35.2266075,1.56988243 35.5659249,1.31333613 35.9586669,1.28460955 C36.5094802,1.24432106 36.9886628,1.65818318 37.0289513,2.20899647 L40.2437557,46.1609256 C40.2644355,46.4436546 40.1641446,46.7218752 39.9678293,46.9263833 C39.5853672,47.3248067 38.9523344,47.3377458 38.5539111,46.9552837 L24.3163597,33.2881029 L24.3163597,33.2881029 Z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" version="1.1" viewBox="0 0 48 48"><title>illustration/flow</title><g id="illustration/flow" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><path id="Combined-Shape" fill="#79C9FC" fill-rule="nonzero" d="M30,29 C32.7614237,29 35,26.7614237 35,24 C35,14.6111593 27.3888407,7 18,7 C8.61115925,7 1,14.6111593 1,24 C1,33.3888407 8.61115925,41 18,41 C19.3333404,41 20.6447683,40.8466238 21.9154603,40.5471706 C19.5096374,39.3319645 17.5510566,37.8612875 16.0456579,36.1314815 C14.1063138,33.9030427 12.769443,31.0725999 12.0293806,27.6556449 C11.360469,26.565281 11,25.3082308 11,24 C11,20.1340068 14.1340068,17 18,17 C21.8659932,17 25,20.1340068 25,24 C25,26.125 27.7040312,29 30,29 Z"/><path id="Combined-Shape-Copy" fill="#FFC445" fill-rule="nonzero" d="M42,29 C44.7614237,29 47,26.7614237 47,24 C47,14.6111593 39.3888407,7 30,7 C20.6111593,7 13,14.6111593 13,24 C13,33.3888407 20.6111593,41 30,41 C31.3333404,41 32.6447683,40.8466238 33.9154603,40.5471706 C31.5096374,39.3319645 29.4051056,37.9781963 28.0456579,36.1314815 C26.0625,33.4375 23,27.1875 23,24 C23,20.1340068 26.1340068,17 30,17 C33.8659932,17 37,20.1340068 37,24 C37.02301,26.3435241 39.7040312,29 42,29 Z" transform="translate(30.000000, 24.000000) scale(-1, -1) translate(-30.000000, -24.000000)"/></g></svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" version="1.1" viewBox="0 0 48 48"><title>illustration/plugin</title><g id="illustration/plugin" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><path id="Combined-Shape" fill="#79C9FC" d="M26,15.3994248 C26,15.4091303 26,15.4188459 26,15.4285714 L26,21.4694881 C25.8463595,21.4969567 25.6941676,21.51275 25.5873784,21.51275 C25.4974117,21.51275 25.4230979,21.4768034 25.377756,21.4206259 L25.2660784,21.2822603 L25.1317423,21.1657666 C24.2436317,20.3956144 23.100098,19.9633214 21.895551,19.9633214 C19.2039137,19.9633214 17,22.1075558 17,24.7804643 C17,27.4533728 19.2039137,29.5976071 21.895551,29.5976071 C23.1972122,29.5976071 24.3149423,29.2878193 25.1231445,28.3613697 C25.4542273,27.9818463 25.568273,27.9073214 25.5873784,27.9073214 C25.681532,27.9073214 25.8352452,27.9239643 26,27.9524591 L26,32.5714286 C26,32.5811541 26,32.5908697 26,32.6005752 L26,33 C26,35.209139 24.209139,37 22,37 L4,37 C1.790861,37 0,35.209139 0,33 L0,15 C0,12.790861 1.790861,11 4,11 L22,11 C24.209139,11 26,12.790861 26,15 L26,15.3994248 Z"/><path id="Path" fill="#87E6E5" d="M27.9998779,32.5714286 C27.9998779,33.3604068 28.6572726,34 29.4682101,34 L46.5315458,34 C47.3424832,34 47.9998779,33.3604068 47.9998779,32.5714286 L47.9998779,15.4285714 C47.9998779,14.6395932 47.3424832,14 46.5315458,14 L29.4682101,14 C28.6572726,14 27.9998779,14.6395932 27.9998779,15.4285714 L27.9998779,21.8355216 C27.9334367,22.2650514 27.8567585,22.6454496 27.746391,22.8084643 C27.4245309,23.2838571 26.2402709,23.51275 25.5873784,23.51275 C24.8705773,23.51275 24.2322714,23.1857725 23.8214379,22.6767605 C23.3096996,22.2329909 22.6349941,21.9633214 21.895551,21.9633214 C20.2963823,21.9633214 19,23.2245992 19,24.7804643 C19,26.3363293 20.2963823,27.5976071 21.895551,27.5976071 C22.5398535,27.5976071 23.2399343,27.477727 23.6160247,27.0466112 C24.1396029,26.4464286 24.7367044,25.9073214 25.5873784,25.9073214 C26.2402709,25.9073214 27.5912951,26.1766031 27.8226692,26.6116071 C27.8819199,26.7230038 27.9403239,26.921677 27.9998779,27.1556219 L27.9998779,32.5714286 Z"/></g></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" version="1.1" viewBox="0 0 48 48"><title>illustration/repo</title><g id="illustration/repo" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><path id="Rectangle-62-Copy" fill="#B7F0EF" d="M27.2217723,9.04506931 L41.2217723,6.2682098 C43.3886973,5.83840648 45.4937616,7.2466219 45.9235649,9.41354696 C45.9743993,9.66983721 46,9.93049166 46,10.1917747 L46,32.581381 C46,34.4904961 44.650862,36.1335143 42.7782277,36.5049459 L28.7782277,39.2818054 C26.6113027,39.7116087 24.5062384,38.3033933 24.0764351,36.1364682 C24.0256007,35.880178 24,35.6195235 24,35.3582405 L24,12.9686342 C24,11.0595191 25.349138,9.4165009 27.2217723,9.04506931 Z" opacity=".7"/><path id="Combined-Shape" fill="#87E6E5" d="M6.77822775,6.2682098 L20.7782277,9.04506931 C22.650862,9.4165009 24,11.0595191 24,12.9686342 L24,35.3582405 C24,37.5673795 22.209139,39.3582405 20,39.3582405 C19.738717,39.3582405 19.4780625,39.3326398 19.2217723,39.2818054 L5.22177225,36.5049459 C3.34913798,36.1335143 2,34.4904961 2,32.581381 L2,10.1917747 C2,7.98263571 3.790861,6.19177471 6,6.19177471 C6.26128305,6.19177471 6.5219375,6.21737537 6.77822775,6.2682098 Z"/><path id="Rectangle-63-Copy-2" fill="#61C1FD" d="M22,10 C23.1666667,10.2291667 24.0179036,10.625 24.5537109,11.1875 C25.0895182,11.75 25.5716146,12.875 26,14.5625 C26,29.3020833 26,37.5208333 26,39.21875 C26,40.9166667 26.4241536,42.9583333 27.2724609,45.34375 L24.5537109,41.875 L22.9824219,45.34375 C22.327474,43.1979167 22,41.2291667 22,39.4375 C22,37.6458333 22,27.8333333 22,10 Z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" version="1.1" viewBox="0 0 48 48"><title>illustration/stackalt</title><g id="illustration/stackalt" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><path id="Combined-Shape" fill="#FFAE00" d="M23.8628277,0 L23.8628277,48 L3.32291648,36.2491883 L3.32155653,11.9499781 L23.8628277,0 Z M23.8670509,0 L44.408322,11.9499781 L44.4069621,36.2491883 L23.8670509,48 L23.8670509,0 Z" opacity=".196"/><path id="Rectangle-46-Copy-3" fill="#66BF3C" d="M15.8232279,19.1155258 L24.7368455,21.4714881 C29.6053842,22.7582937 33.4077423,26.5606518 34.694548,31.4291905 L37.0505103,40.3428082 C37.6150232,42.4786032 36.3412474,44.6676353 34.2054524,45.2321482 C33.5569474,45.4035549 32.87575,45.4091235 32.2245294,45.2483418 L23.3459013,43.0562718 C18.2976962,41.809906 14.3561301,37.8683399 13.1097642,32.8201348 L10.9176943,23.9415066 C10.3881737,21.7967682 11.6975664,19.6288529 13.8423049,19.0993322 C14.4935255,18.9385505 15.1747229,18.9441191 15.8232279,19.1155258 Z" opacity=".5" transform="translate(23.999997, 32.166058) rotate(-45.000000) translate(-23.999997, -32.166058)"/><path id="Rectangle-46-Copy-2" fill="#FFAE00" d="M15.8232279,11.2216893 L24.7368455,13.5776516 C29.6053842,14.8644572 33.4077423,18.6668153 34.694548,23.5353541 L37.0505103,32.4489717 C37.6150232,34.5847667 36.3412474,36.7737988 34.2054524,37.3383117 C33.5569474,37.5097184 32.87575,37.515287 32.2245294,37.3545053 L23.3459013,35.1624353 C18.2976962,33.9160695 14.3561301,29.9745034 13.1097642,24.9262983 L10.9176943,16.0476701 C10.3881737,13.9029317 11.6975664,11.7350164 13.8423049,11.2054957 C14.4935255,11.044714 15.1747229,11.0502826 15.8232279,11.2216893 Z" opacity=".5" transform="translate(23.999997, 24.272222) rotate(-45.000000) translate(-23.999997, -24.272222)"/><path id="Rectangle-46-Copy" fill="#FC521F" d="M15.8232279,3.32785281 L24.7368455,5.68381509 C29.6053842,6.97062075 33.4077423,10.7729788 34.694548,15.6415176 L37.0505103,24.5551352 C37.6150232,26.6909302 36.3412474,28.8799623 34.2054524,29.4444752 C33.5569474,29.6158819 32.87575,29.6214505 32.2245294,29.4606688 L23.3459013,27.2685988 C18.2976962,26.022233 14.3561301,22.0806669 13.1097642,17.0324618 L10.9176943,8.15383364 C10.3881737,6.00909519 11.6975664,3.84117987 13.8423049,3.31165925 C14.4935255,3.15087753 15.1747229,3.15644615 15.8232279,3.32785281 Z" opacity=".5" transform="translate(23.999997, 16.378385) rotate(-45.000000) translate(-23.999997, -16.378385)"/></g></svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -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;
}

View file

@ -0,0 +1,32 @@
.wrapper {
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;
}
svg {
display: inline-block;
vertical-align: top;
}
h1 {
font-weight: 700;
font-size: 20px;
line-height: 1;
margin: 6px 0 6px 10px;
display: inline-block;
vertical-align: top;
}
button + button {
margin-left: 10px;
}
.welcome {
color: #333;
font-size: 14px;
margin-right: 10px;
}

View file

@ -0,0 +1,69 @@
section {
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;
}
section h2 {
font-weight: 700;
font-size: 32px;
line-height: 1;
margin: 0 0 4px;
display: inline-block;
vertical-align: top;
}
section p {
margin: 1em 0;
}
section a {
text-decoration: none;
color: #1ea7fd;
}
section ul {
padding-left: 30px;
margin: 1em 0;
}
section li {
margin-bottom: 8px;
}
section .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;
}
section .tip-wrapper {
font-size: 13px;
line-height: 20px;
margin-top: 40px;
margin-bottom: 40px;
}
section .tip-wrapper svg {
display: inline-block;
height: 12px;
width: 12px;
margin-right: 4px;
vertical-align: top;
margin-top: 3px;
}
section .tip-wrapper svg path {
fill: #1ea7fd;
}

View file

@ -0,0 +1,48 @@
import type {Meta, StoryObj} from '@storybook/react';
import Button from './Button';
import {ButtonColors} from './Button';
const meta = {
title: 'Global / Button',
component: Button,
tags: ['autodocs']
} satisfies Meta<typeof Button>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {
label: 'Button'
}
};
export const Black: Story = {
args: {
label: 'Button',
color: ButtonColors.Black
}
};
export const Green: Story = {
args: {
label: 'Button',
color: ButtonColors.Green
}
};
export const Red: Story = {
args: {
label: 'Button',
color: ButtonColors.Red
}
};
export const Link: Story = {
args: {
label: 'Button',
color: ButtonColors.Green,
link: true
}
};

View file

@ -0,0 +1,60 @@
import React from 'react';
export interface ButtonColorsType {
Clear: string;
Black: string;
Green: string;
Red: string;
}
export const ButtonColors: ButtonColorsType = {
Clear: 'Clear',
Black: 'Black',
Green: 'Green',
Red: 'Red'
};
export interface ButtonProps {
label: string;
color?: string;
fullWidth?: boolean;
link?: boolean;
}
const Button: React.FC<ButtonProps> = ({
label,
color,
fullWidth,
link,
...props
}) => {
let buttonColor: string;
const fontWeight: string = (link || (color !== ButtonColors.Clear && color)) ? 'font-bold' : 'font-medium';
const padding: string = !link ? 'px-4 h-9' : '';
switch (color) {
case ButtonColors.Black:
buttonColor = link ? 'text-black' : 'bg-black text-white';
break;
case ButtonColors.Green:
buttonColor = link ? 'text-green' : 'bg-green text-white';
break;
case ButtonColors.Red:
buttonColor = link ? 'text-red' : 'bg-red text-white';
break;
default:
buttonColor = link ? 'text-black' : 'bg-transparent text-black';
break;
}
return (
<button
className={`flex items-center justify-center rounded-sm text-sm ${padding} ${fontWeight} ${fullWidth && !link ? 'w-full' : ''} ${buttonColor} `}
type="button"
{...props}
>
{label}
</button>
);
};
export default Button;

View file

@ -0,0 +1,50 @@
import type {Meta, StoryObj} from '@storybook/react';
import ButtonGroup from './ButtonGroup';
import {ButtonColors} from './Button';
const ButtonGroupMeta = {
title: 'Global / Button group',
component: ButtonGroup,
tags: ['autodocs']
} satisfies Meta<typeof ButtonGroup>;
export default ButtonGroupMeta;
type Story = StoryObj<typeof ButtonGroupMeta>;
const defaultButtons = [
{
label: 'Cancel',
color: ButtonColors.Clear
},
{
label: 'Save',
color: ButtonColors.Black
}
];
export const Default: Story = {
args: {
buttons: defaultButtons,
link: false
}
};
const linkButtons = [
{
label: 'Cancel',
color: ButtonColors.Clear
},
{
label: 'Save',
color: ButtonColors.Green
}
];
export const LinkButtons: Story = {
args: {
buttons: linkButtons,
link: true
}
};

View file

@ -0,0 +1,22 @@
import Button from './Button';
import React from 'react';
interface ButtonGroupProps {
buttons: Array<{
label: string,
color?: string,
}>;
link?: boolean;
}
const ButtonGroup: React.FC<ButtonGroupProps> = ({buttons, link}) => {
return (
<div className={`flex items-center ${link ? 'gap-5' : 'gap-2'}`}>
{buttons.map(({color, label}) => (
<Button key={color} color={color} label={label} link={link} />
))}
</div>
);
};
export default ButtonGroup;

View file

@ -0,0 +1,40 @@
import React from 'react';
interface SettingGroupProps {
state?: 'view' | 'edit' | 'unsaved' | 'error' | 'new';
children?: React.ReactNode;
}
const SettingGroup: React.FC<SettingGroupProps> = ({state, children}) => {
let styles = '';
switch (state) {
case 'edit':
styles = 'border-grey-400';
break;
case 'unsaved':
styles = 'border-yellow';
break;
case 'error':
styles = 'border-red';
break;
case 'new':
styles = 'border-purple';
break;
default:
styles = 'border-grey-200';
break;
}
return (
<div className={`rounded border p-5 md:p-7 ${styles}`}>
{children}
</div>
);
};
export default SettingGroup;

View file

@ -0,0 +1,21 @@
import React from 'react';
interface Props {
title: string;
description?: React.ReactNode;
children?: React.ReactNode;
}
const SettingGroupHeader: React.FC<Props> = ({title, description, children}) => {
return (
<div className="flex items-start justify-between">
<div>
<h5>{title}</h5>
{description && <p className="text-sm">{description}</p>}
</div>
{children}
</div>
);
};
export default SettingGroupHeader;

View file

@ -0,0 +1,13 @@
import React from 'react';
interface Props {
name: string;
}
const SettingNavItem: React.FC<Props> = ({name}) => {
return (
<li><a className="block px-0 py-1 text-sm" href="_blank">{name}</a></li>
);
};
export default SettingNavItem;

View file

@ -0,0 +1,22 @@
import React from 'react';
import SettingSectionHeader from './SettingSectionHeader';
interface Props {
name?: string;
children?: React.ReactNode;
}
const SettingNavSection: React.FC<Props> = ({name, children}) => {
return (
<>
{name && <SettingSectionHeader name={name} />}
{children &&
<ul className="mb-10 mt-[-8px]">
{children}
</ul>
}
</>
);
};
export default SettingNavSection;

View file

@ -0,0 +1,22 @@
import React from 'react';
import SettingSectionHeader from './SettingSectionHeader';
interface Props {
name?: string;
children?: React.ReactNode;
}
const SettingSection: React.FC<Props> = ({name, children}) => {
return (
<>
{name && <SettingSectionHeader name={name} />}
{children &&
<div className="mb-[100px] flex flex-col gap-9">
{children}
</div>
}
</>
);
};
export default SettingSection;

View file

@ -0,0 +1,13 @@
import React from 'react';
interface Props {
name: string;
}
const SettingSectionHeader: React.FC<Props> = ({name}) => {
return (
<h2 className="text-grey-700 mb-4 text-xs font-semibold uppercase tracking-normal">{name}</h2>
);
};
export default SettingSectionHeader;

View file

@ -0,0 +1,20 @@
import React from 'react';
import PublicationLanguage from './PublicationLanguage';
import SettingSection from '../../design-system/settings/SettingSection';
import TimeZone from './TimeZone';
import TitleAndDescription from './TitleAndDescription';
const GeneralSettings: React.FC = () => {
return (
<>
<SettingSection name="General">
<TitleAndDescription />
<TimeZone />
<PublicationLanguage />
</SettingSection>
</>
);
};
export default GeneralSettings;

View file

@ -0,0 +1,27 @@
import ButtonGroup from '../../design-system/globals/ButtonGroup';
import React from 'react';
import SettingGroup from '../../design-system/settings/SettingGroup';
import SettingGroupHeader from '../../design-system/settings/SettingGroupHeader';
import {ButtonColors} from '../../design-system/globals/Button';
const PublicationLanguage: React.FC = () => {
const buttons = [
{
label: 'Edit',
color: ButtonColors.Green
}
];
return (
<SettingGroup>
<SettingGroupHeader
description="Set the language/locale which is used on your site"
title="Publication Language"
>
<ButtonGroup buttons={buttons} link={true} />
</SettingGroupHeader>
</SettingGroup>
);
};
export default PublicationLanguage;

View file

@ -0,0 +1,27 @@
import ButtonGroup from '../../design-system/globals/ButtonGroup';
import React from 'react';
import SettingGroup from '../../design-system/settings/SettingGroup';
import SettingGroupHeader from '../../design-system/settings/SettingGroupHeader';
import {ButtonColors} from '../../design-system/globals/Button';
const TimeZone: React.FC = () => {
const buttons = [
{
label: 'Edit',
color: ButtonColors.Green
}
];
return (
<SettingGroup>
<SettingGroupHeader
description="Set the time and date of your publication, used for all published posts"
title="Site timezone"
>
<ButtonGroup buttons={buttons} link={true} />
</SettingGroupHeader>
</SettingGroup>
);
};
export default TimeZone;

View file

@ -0,0 +1,27 @@
import ButtonGroup from '../../design-system/globals/ButtonGroup';
import React from 'react';
import SettingGroup from '../../design-system/settings/SettingGroup';
import SettingGroupHeader from '../../design-system/settings/SettingGroupHeader';
import {ButtonColors} from '../../design-system/globals/Button';
const TitleAndDescription: React.FC = () => {
const buttons = [
{
label: 'Edit',
color: ButtonColors.Green
}
];
return (
<SettingGroup>
<SettingGroupHeader
description="The details used to identify your publication around the web"
title="Title & description"
>
<ButtonGroup buttons={buttons} link={true} />
</SettingGroupHeader>
</SettingGroup>
);
};
export default TitleAndDescription;

View file

@ -0,0 +1,6 @@
import './styles/index.css';
import App from './App.tsx';
export {
App as AdminXApp
};

View file

@ -0,0 +1,10 @@
import './styles/index.css';
import App from './App.tsx';
import React from 'react';
import ReactDOM from 'react-dom/client';
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
);

View file

@ -0,0 +1,61 @@
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
/* Defaults */
@layer base {
@font-face {
font-family: "Inter";
src: url("../../public/fonts/Inter.ttf") format("truetype-variations");
font-weight: 100 900;
}
body {
@apply text-black text-base leading-normal;
}
h1, h2, h3, h4, h5, h6 {
@apply font-bold tracking-tight leading-tighter;
}
h1 {
@apply text-4xl leading-supertight;
}
h2 {
@apply text-3xl;
}
h3 {
@apply text-2xl;
}
h4 {
@apply text-xl;
}
h5 {
@apply text-lg leading-tight;
}
h6 {
@apply text-md leading-normal;
}
}
:root {
font-size: 62.5%;
line-height: 1.5;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
html, body, #root {
width: 100%;
height: 100%;
}

View file

@ -0,0 +1 @@
/// <reference types="vite/client" />

View file

@ -0,0 +1,189 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
screens: {
sm: '480px',
md: '640px',
lg: '1024px',
xl: '1280px'
},
colors: {
transparent: 'transparent',
current: 'currentColor',
white: '#FFF',
black: '#15171A',
grey: {
DEFAULT: '#ABB4BE',
50: '#FAFAFB',
100: '#F4F5F6',
200: '#EBEEF0',
300: '#DDE1E5',
400: '#CED4D9',
500: '#AEB7C1',
600: '#95A1AD',
700: '#7C8B9A',
800: '#626D79',
900: '#394047',
},
green: {
DEFAULT: '#30CF43',
100: '#E1F9E4',
400: '#58DA67',
500: '#30CF43',
600: '#2AB23A',
},
blue: {
DEFAULT: '#14B8FF',
100: '#DBF4FF',
400: '#42C6FF',
500: '#14B8FF',
600: '#00A4EB',
},
purple: {
DEFAULT: '#8E42FF',
100: '#EDE0FF',
400: '#A366FF',
500: '#8E42FF',
600: '7B1FFF',
},
pink: {
DEFAULT: '#FB2D8D',
100: '#FFDFEE',
400: '#FF5CA8',
500: '#FB2D8D',
600: '#F70878',
},
red: {
DEFAULT: '#F50B23',
100: '#FFE0E0',
400: '#F9394C',
500: '#F50B23',
600: '#DC091E',
},
yellow: {
DEFAULT: '#FFB41F',
100: '#FFF1D6',
400: '#FFC247',
500: '#FFB41F',
600: '#F0A000',
},
lime: {
DEFAULT: '#B5FF18',
},
},
fontFamily: {
inter: "Inter",
sans: 'Inter, -apple-system, BlinkMacSystemFont, avenir next, avenir, helvetica neue, helvetica, ubuntu, roboto, noto, segoe ui, arial, sans-serif',
serif: 'Georgia, serif',
mono: 'Consolas, Liberation Mono, Menlo, Courier, monospace'
},
boxShadow: {
DEFAULT: '0 0 1px rgba(0,0,0,.05), 0 5px 18px rgba(0,0,0,.08)',
sm: '0 0 1px rgba(0,0,0,.12), 0 1px 6px rgba(0,0,0,0.03), 0 6px 10px -8px rgba(0,0,0,.1)',
md: '0 0 1px rgba(0,0,0,.05), 0 8px 28px rgba(0,0,0,.12)',
lg: '0 0 7px rgba(0, 0, 0, 0.08), 0 2.1px 2.2px -5px rgba(0, 0, 0, 0.011), 0 5.1px 5.3px -5px rgba(0, 0, 0, 0.016), 0 9.5px 10px -5px rgba(0, 0, 0, 0.02), 0 17px 17.9px -5px rgba(0, 0, 0, 0.024), 0 31.8px 33.4px -5px rgba(0, 0, 0, 0.029), 0 76px 80px -5px rgba(0, 0, 0, 0.04)',
xl: '0 2.8px 2.2px rgba(0, 0, 0, 0.02), 0 6.7px 5.3px rgba(0, 0, 0, 0.028), 0 12.5px 10px rgba(0, 0, 0, 0.035), 0 22.3px 17.9px rgba(0, 0, 0, 0.042), 0 41.8px 33.4px rgba(0, 0, 0, 0.05), 0 100px 80px rgba(0, 0, 0, 0.07)',
inner: 'inset 0 0 4px 0 rgb(0 0 0 / 0.08)',
none: '0 0 #0000',
},
extend: {
spacing: {
px: '1px',
0: '0px',
0.5: '0.2rem',
1: '0.4rem',
1.5: '0.6rem',
2: '0.8rem',
2.5: '1rem',
3: '1.2rem',
3.5: '1.4rem',
4: '1.6rem',
5: '2rem',
6: '2.4rem',
7: '2.8rem',
8: '3.2rem',
9: '3.6rem',
10: '4rem',
11: '4.4rem',
12: '4.8rem',
14: '5.6rem',
16: '6.4rem',
20: '8rem',
24: '9.6rem',
28: '11.2rem',
32: '12.8rem',
36: '14.4rem',
40: '16rem',
44: '17.6rem',
48: '19.2rem',
52: '20.8rem',
56: '22.4rem',
60: '24rem',
64: '25.6rem',
72: '28.8rem',
80: '32rem',
96: '38.4rem',
},
maxWidth: {
none: 'none',
0: '0rem',
xs: '32rem',
sm: '38.4rem',
md: '44.8rem',
lg: '51.2rem',
xl: '57.6rem',
'2xl': '67.2rem',
'3xl': '76.8rem',
'4xl': '89.6rem',
'5xl': '102.4rem',
'6xl': '115.2rem',
'7xl': '128rem',
'8xl': '140rem',
'9xl': '156rem',
full: '100%',
min: 'min-content',
max: 'max-content',
fit: 'fit-content',
prose: '65ch',
},
borderRadius: {
sm: '0.3rem',
DEFAULT: '0.4rem',
md: '0.6rem',
lg: '0.8rem',
xl: '1.2rem',
'2xl': '1.6rem',
'3xl': '2.4rem',
full: '9999px',
},
fontSize: {
'2xs': '1.05rem',
base: '1.5rem',
xs: '1.2rem',
sm: '1.35rem',
md: '1.5rem',
lg: '1.8rem',
xl: '2rem',
'2xl': '2.4rem',
'3xl': '3rem',
'4xl': '3.6rem',
'5xl': ['4.2rem', '1.15'],
'6xl': ['6rem', '1'],
'7xl': ['7.2rem', '1'],
'8xl': ['9.6rem', '1'],
'9xl': ['12.8rem', '1'],
},
lineHeight: {
base: '1.5em',
tight: '1.35em',
tighter: '1.25em',
supertight: '1.1em',
}
},
},
// plugins: [require('@tailwindcss/forms')],
}

View file

@ -0,0 +1,8 @@
const assert = require('assert');
describe('Hello world', function () {
it('Runs a test', function () {
// TODO: Write me!
assert.ok(require('../index'));
});
});

View file

@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"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" }]
}

View file

@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts", "package.json"]
}

View file

@ -0,0 +1,60 @@
import pkg from './package.json';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
import {defineConfig} from 'vitest/config';
import {resolve} from 'path';
const outputFileName = pkg.name[0] === '@' ? pkg.name.slice(pkg.name.indexOf('/') + 1) : pkg.name;
// https://vitejs.dev/config/
export default (function viteConfig() {
return defineConfig({
plugins: [
svgr(),
react()
],
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.VITEST_SEGFAULT_RETRY': 3
},
build: {
minify: true,
sourcemap: true,
cssCodeSplit: true,
lib: {
entry: resolve(__dirname, 'src/index.tsx'),
name: pkg.name,
fileName(format) {
if (format === 'umd') {
return `${outputFileName}.umd.js`;
}
return `${outputFileName}.js`;
}
},
rollupOptions: {
external: ['react', 'react-dom'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM'
}
}
},
commonjsOptions: {
include: [/packages/, /node_modules/]
}
},
test: {
globals: true, // required for @testing-library/jest-dom extensions
environment: 'jsdom',
setupFiles: './test/test-setup.js',
include: ['./test/unit/*'],
testTimeout: process.env.TIMEOUT ? parseInt(process.env.TIMEOUT) : 10000,
...(process.env.CI && { // https://github.com/vitest-dev/vitest/issues/1674
minThreads: 1,
maxThreads: 2
})
}
});
});

2880
yarn.lock

File diff suppressed because it is too large Load diff