Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
totraev committed Nov 11, 2024
0 parents commit b6471c9
Show file tree
Hide file tree
Showing 115 changed files with 9,045 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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?

1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
.storybook/
public/
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"plugins": ["prettier-plugin-tailwindcss"],
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"printWidth": 120,
"bracketSpacing": true,
"endOfLine": "lf"
}
25 changes: 25 additions & 0 deletions .storybook/components/ThemeableDocContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useMemo, useState, useEffect } from "react";
import * as React from "react";
import { addons } from "@storybook/preview-api";
import { DocsContainer, DocsContainerProps } from "@storybook/addon-docs";
import { themes } from "@storybook/theming";
import { DARK_MODE_EVENT_NAME } from "storybook-dark-mode";

const channel = addons.getChannel();

export default function ThemeableDocContainer(props: DocsContainerProps) {
const [isDark, setDark] = useState(false);

const activeTheme = useMemo(
() => (isDark ? { ...themes.dark, appPreviewBg: "#222425" } : themes.light),
[isDark]
);

useEffect(() => {
channel.on(DARK_MODE_EVENT_NAME, setDark);

return () => channel.removeListener(DARK_MODE_EVENT_NAME, setDark);
}, [setDark]);

return <DocsContainer {...props} theme={activeTheme} />;
}
17 changes: 17 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-onboarding",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
"storybook-dark-mode",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
};
export default config;
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 { themes } from "@storybook/theming";

addons.setConfig({
theme: themes.light,
});
30 changes: 30 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Preview } from "@storybook/react";
import { themes } from "@storybook/theming";

import ThemeableDocContainer from "./components/ThemeableDocContainer";

import "../src/index.css";

const preview: Preview = {
parameters: {
darkMode: {
current: "light",
darkClass: "dark",
lightClass: "light",
dark: { ...themes.dark, appPreviewBg: "#222425" },
light: themes.light,
stylePreview: true,
},
docs: {
container: ThemeableDocContainer,
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
28 changes: 28 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";
import prettier from "eslint-config-prettier";
import tailwind from "eslint-plugin-tailwindcss";

export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
...tailwind.configs["flat/recommended"],
prettier,
],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
},
);
Loading

0 comments on commit b6471c9

Please sign in to comment.