@malik72org/storybook 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.storybook/main.ts +16 -0
  2. package/.storybook/preview.ts +32 -0
  3. package/.storybook/vitest.setup.ts +7 -0
  4. package/README.md +73 -0
  5. package/eslint.config.js +23 -0
  6. package/index.css +9 -0
  7. package/package.json +54 -0
  8. package/postcss.config.js +5 -0
  9. package/src/components/button/Button.stories.tsx +37 -0
  10. package/src/components/button/Button.tsx +13 -0
  11. package/src/components/inputwrapper/InputWrapper.tsx +20 -0
  12. package/src/components/textinput/TextInput.css +22 -0
  13. package/src/components/textinput/TextInput.stories.tsx +39 -0
  14. package/src/components/textinput/TextInput.tsx +41 -0
  15. package/src/index.ts +3 -0
  16. package/src/stories/Button.stories.ts +54 -0
  17. package/src/stories/Button.tsx +35 -0
  18. package/src/stories/Configure.mdx +364 -0
  19. package/src/stories/Header.stories.ts +34 -0
  20. package/src/stories/Header.tsx +55 -0
  21. package/src/stories/Page.stories.ts +33 -0
  22. package/src/stories/Page.tsx +73 -0
  23. package/src/stories/assets/accessibility.png +0 -0
  24. package/src/stories/assets/accessibility.svg +1 -0
  25. package/src/stories/assets/addon-library.png +0 -0
  26. package/src/stories/assets/assets.png +0 -0
  27. package/src/stories/assets/avif-test-image.avif +0 -0
  28. package/src/stories/assets/context.png +0 -0
  29. package/src/stories/assets/discord.svg +1 -0
  30. package/src/stories/assets/docs.png +0 -0
  31. package/src/stories/assets/figma-plugin.png +0 -0
  32. package/src/stories/assets/github.svg +1 -0
  33. package/src/stories/assets/share.png +0 -0
  34. package/src/stories/assets/styling.png +0 -0
  35. package/src/stories/assets/testing.png +0 -0
  36. package/src/stories/assets/theming.png +0 -0
  37. package/src/stories/assets/tutorials.svg +1 -0
  38. package/src/stories/assets/youtube.svg +1 -0
  39. package/src/stories/button.css +30 -0
  40. package/src/stories/header.css +32 -0
  41. package/src/stories/page.css +68 -0
  42. package/tsconfig.app.json +28 -0
  43. package/tsconfig.json +7 -0
  44. package/tsconfig.node.json +26 -0
  45. package/vite.config.ts +59 -0
  46. package/vitest.shims.d.ts +1 -0
@@ -0,0 +1,16 @@
1
+ import type { StorybookConfig } from '@storybook/react-vite';
2
+
3
+ const config: StorybookConfig = {
4
+ "stories": [
5
+ "../src/**/*.mdx",
6
+ "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
7
+ ],
8
+ "addons": [
9
+ "@chromatic-com/storybook",
10
+ "@storybook/addon-vitest",
11
+ "@storybook/addon-a11y",
12
+ "@storybook/addon-docs"
13
+ ],
14
+ "framework": "@storybook/react-vite"
15
+ };
16
+ export default config;
@@ -0,0 +1,32 @@
1
+ import type { Preview } from '@storybook/react-vite'
2
+ import "primereact/resources/themes/lara-light-blue/theme.css";
3
+ import "primereact/resources/primereact.min.css";
4
+ // import "primeicons/primeicons.css";
5
+ import '../../storybook/index.css';
6
+ const preview: Preview = {
7
+ parameters: {
8
+ backgrounds: {
9
+ values: [
10
+ { name: 'Maroon', value: '#0f0' },
11
+ { name: 'Red', value: '#f00' },
12
+ { name: 'Green', value: '#0f0' },
13
+ { name: 'Blue', value: '#00f' },
14
+ ]
15
+ },
16
+ controls: {
17
+ matchers: {
18
+ color: /(background|color)$/i,
19
+ date: /Date$/i,
20
+ },
21
+ },
22
+
23
+ a11y: {
24
+ // 'todo' - show a11y violations in the test UI only
25
+ // 'error' - fail CI on a11y violations
26
+ // 'off' - skip a11y checks entirely
27
+ test: 'todo'
28
+ }
29
+ },
30
+ };
31
+
32
+ export default preview;
@@ -0,0 +1,7 @@
1
+ import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
2
+ import { setProjectAnnotations } from '@storybook/react-vite';
3
+ import * as projectAnnotations from './preview';
4
+
5
+ // This is an important step to apply the right configuration when testing your stories.
6
+ // More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7
+ setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is currently not compatible with SWC. See [this issue](https://github.com/vitejs/vite-plugin-react/issues/428) for tracking the progress.
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+ ```
45
+
46
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import reactX from 'eslint-plugin-react-x'
51
+ import reactDom from 'eslint-plugin-react-dom'
52
+
53
+ export default defineConfig([
54
+ globalIgnores(['dist']),
55
+ {
56
+ files: ['**/*.{ts,tsx}'],
57
+ extends: [
58
+ // Other configs...
59
+ // Enable lint rules for React
60
+ reactX.configs['recommended-typescript'],
61
+ // Enable lint rules for React DOM
62
+ reactDom.configs.recommended,
63
+ ],
64
+ languageOptions: {
65
+ parserOptions: {
66
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
+ tsconfigRootDir: import.meta.dirname,
68
+ },
69
+ // other options...
70
+ },
71
+ },
72
+ ])
73
+ ```
@@ -0,0 +1,23 @@
1
+ // For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
2
+ import storybook from "eslint-plugin-storybook";
3
+
4
+ import js from '@eslint/js'
5
+ import globals from 'globals'
6
+ import reactHooks from 'eslint-plugin-react-hooks'
7
+ import reactRefresh from 'eslint-plugin-react-refresh'
8
+ import tseslint from 'typescript-eslint'
9
+ import { defineConfig, globalIgnores } from 'eslint/config'
10
+
11
+ export default defineConfig([globalIgnores(['dist']), {
12
+ files: ['**/*.{ts,tsx}'],
13
+ extends: [
14
+ js.configs.recommended,
15
+ tseslint.configs.recommended,
16
+ reactHooks.configs.flat.recommended,
17
+ reactRefresh.configs.vite,
18
+ ],
19
+ languageOptions: {
20
+ ecmaVersion: 2020,
21
+ globals: globals.browser,
22
+ },
23
+ }, ...storybook.configs["flat/recommended"]])
package/index.css ADDED
@@ -0,0 +1,9 @@
1
+ @import "tailwindcss";
2
+
3
+
4
+ :root {
5
+ --rhl-input-border-color: #000;
6
+ --rhl-input-border-thickness: 2px;
7
+ --rhl-input-focus-border-color: #0a0;
8
+ --rhl-input-error-border-color: #dc2626;
9
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@malik72org/storybook",
3
+ "private": false,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "lint": "eslint .",
10
+ "preview": "vite preview",
11
+ "storybook": "storybook dev -p 6006",
12
+ "build-storybook": "storybook build",
13
+ "prepare": "npm run build"
14
+ },
15
+ "peerDependencies": {
16
+ "primereact": "^10.9.7",
17
+ "react": "^19.2.0",
18
+ "react-dom": "^19.2.0"
19
+ },
20
+ "devDependencies": {
21
+ "@chromatic-com/storybook": "^5.0.1",
22
+ "@eslint/js": "^9.39.1",
23
+ "@storybook/addon-a11y": "^10.2.8",
24
+ "@storybook/addon-docs": "^10.2.8",
25
+ "@storybook/addon-onboarding": "^10.2.8",
26
+ "@storybook/addon-vitest": "^10.2.8",
27
+ "@storybook/react-vite": "^10.2.8",
28
+ "@tailwindcss/postcss": "^4.1.18",
29
+ "@types/node": "^24.10.1",
30
+ "@types/react": "^19.2.7",
31
+ "@types/react-dom": "^19.2.3",
32
+ "@vitejs/plugin-react-swc": "^4.2.2",
33
+ "@vitest/browser-playwright": "^4.0.18",
34
+ "@vitest/coverage-v8": "^4.0.18",
35
+ "ajv": "^8.13.0",
36
+ "eslint": "^9.39.1",
37
+ "eslint-plugin-react-hooks": "^7.0.1",
38
+ "eslint-plugin-react-refresh": "^0.4.24",
39
+ "eslint-plugin-storybook": "^10.2.8",
40
+ "globals": "^16.5.0",
41
+ "playwright": "^1.58.2",
42
+ "primereact": "^10.9.7",
43
+ "postcss": "^8.5.6",
44
+ "react": "^19.2.0",
45
+ "react-dom": "^19.2.0",
46
+ "storybook": "^10.2.8",
47
+ "tailwindcss": "^4.1.18",
48
+ "typescript": "~5.9.3",
49
+ "typescript-eslint": "^8.48.0",
50
+ "vite": "^7.3.1",
51
+ "vite-plugin-dts": "^4.5.4",
52
+ "vitest": "^4.0.18"
53
+ }
54
+ }
@@ -0,0 +1,5 @@
1
+ export default {
2
+ plugins: {
3
+ "@tailwindcss/postcss": {},
4
+ },
5
+ };
@@ -0,0 +1,37 @@
1
+ import type { StoryObj, Meta } from '@storybook/react-vite';
2
+ import { Button } from './Button';
3
+
4
+
5
+ type Story = StoryObj<Meta<typeof Button>>;
6
+
7
+ const meta = {
8
+ title: 'Inputs/Button',
9
+ component: Button,
10
+ tags: ['autodocs'],
11
+ } satisfies Meta<typeof Button>;
12
+
13
+ export default meta;
14
+
15
+
16
+ export const Dark: Story = {
17
+ args: {
18
+ label: 'Click me!',
19
+ onClick: () => alert('Button clicked me!')
20
+ },
21
+ };
22
+
23
+ export const Light = {
24
+ args: {
25
+ label: 'Secondary Button',
26
+ onClick: () => alert('Button clicked! me')
27
+ },
28
+ };
29
+
30
+ export const Maroon = {
31
+ args: {
32
+ label: 'Secondary Button',
33
+ onClick: () => alert('Button clicked me!')
34
+ },
35
+
36
+ }
37
+
@@ -0,0 +1,13 @@
1
+ interface ButtonProps {
2
+ label: string;
3
+ onClick: () => void;
4
+ }
5
+
6
+ export const Button: React.FC<ButtonProps> = ({ label, onClick }) => {
7
+ return (
8
+ <button onClick={onClick}
9
+ style={{ width: 'full' }}>
10
+ {label}
11
+ </button>
12
+ );
13
+ }
@@ -0,0 +1,20 @@
1
+ interface InputWrapperProps {
2
+ label?: string;
3
+ error?: string;
4
+ children: React.ReactNode;
5
+ labelClassName?: string;
6
+ errorClassName?: string;
7
+ wrapperClassName?: string;
8
+ }
9
+
10
+ export const InputWrapper: React.FC<InputWrapperProps> = ({
11
+ label, error, children, labelClassName, errorClassName, wrapperClassName,
12
+ }) => {
13
+ return (
14
+ <div className={`flex flex-col gap-1 ${wrapperClassName}`}>
15
+ {label && <label className={`${labelClassName}`}>{label}</label>}
16
+ {children}
17
+ {error && <small className={`p-error ${errorClassName}`}>{error}</small>}
18
+ </div>
19
+ );
20
+ }
@@ -0,0 +1,22 @@
1
+ .rhl-text-input {
2
+ border-color: var(--rhl-input-border-color, #d1d5db); /* default gray-300 */
3
+ border-width: var(--rhl-input-border-thickness, 1px);
4
+ border-style: solid;
5
+ padding: var(--rhl-input-padding, 0.5rem);
6
+ border-radius: var(--rhl-input-border-radius, 0.25rem);
7
+ }
8
+
9
+ .rhl-text-input:focus {
10
+ border-color: var(--rhl-input-focus-border-color, #3b82f6); /* blue-500 */
11
+ outline: none;
12
+ box-shadow: var(--rhl-input-focus-shadow, 0 0 0 2px rgba(59,130,246,0.2));
13
+ }
14
+
15
+ .rhl-text-input.rhl-invalid {
16
+ border-color: var(--rhl-input-error-border-color, #ef4444); /* red-500 */
17
+ }
18
+
19
+ .rhl-error {
20
+ color: var(--rhl-error-color, #ef4444);
21
+ font-size: 0.875rem;
22
+ }
@@ -0,0 +1,39 @@
1
+ import type { Meta, StoryFn } from "@storybook/react";
2
+ import { InputTextField } from "./TextInput";
3
+
4
+ export default {
5
+ title: "inputs/InputTextField",
6
+ component: InputTextField,
7
+ argTypes: {
8
+ onChange: { action: "changed" },
9
+ },
10
+ } as Meta;
11
+
12
+ const Template: StoryFn = (args) => <InputTextField {...args} />;
13
+
14
+ export const Default = Template.bind({});
15
+ Default.args = {
16
+ label: "Default Label",
17
+ placeholder: "Enter text here",
18
+ };
19
+
20
+ export const WithError = Template.bind({});
21
+ WithError.args = {
22
+ label: "Error Label",
23
+ placeholder: "Enter text here",
24
+ error: "This field is required",
25
+ };
26
+
27
+ export const WithValue = Template.bind({});
28
+ WithValue.args = {
29
+ label: "With Value",
30
+ value: "Pre-filled value",
31
+ placeholder: "Enter text here",
32
+ };
33
+
34
+ export const WithLabelClassName = Template.bind({});
35
+ WithLabelClassName.args = {
36
+ label: "With Label Class Name",
37
+ labelClassName: "text-red-500",
38
+ placeholder: "Enter text here",
39
+ };
@@ -0,0 +1,41 @@
1
+ import { InputText } from "primereact/inputtext";
2
+ import React from "react";
3
+ import { InputWrapper } from "../inputwrapper/InputWrapper";
4
+ import "./TextInput.css"
5
+
6
+ interface Props {
7
+ label?: string;
8
+ value?: string;
9
+ onChange?: (value: string) => void;
10
+ error?: string;
11
+ placeholder?: string;
12
+ labelClassName?: string;
13
+ errorClassName?: string;
14
+ wrapperClassName?: string;
15
+ inputClassName?: string;
16
+ }
17
+
18
+ export const InputTextField: React.FC<Props> = ({
19
+ label,
20
+ value,
21
+ onChange,
22
+ error,
23
+ placeholder,
24
+ labelClassName,
25
+ errorClassName,
26
+ wrapperClassName,
27
+ inputClassName,
28
+ }) => {
29
+ return (
30
+ <InputWrapper label={label} error={error} labelClassName={labelClassName} errorClassName={errorClassName} wrapperClassName={wrapperClassName}>
31
+ <InputText
32
+ value={value}
33
+ placeholder={placeholder}
34
+ onChange={(e: any) => onChange?.(e.target.value)}
35
+ className={`
36
+ rhl-text-input
37
+ ${error ? 'rhl-invalid' : ''} ${inputClassName}`}
38
+ />
39
+ </InputWrapper>
40
+ );
41
+ };
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './components/inputwrapper/InputWrapper';
2
+ export * from './components/textinput/TextInput';
3
+ export * from './components/button/Button';
@@ -0,0 +1,54 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+
3
+ import { fn } from 'storybook/test';
4
+
5
+ import { Button } from './Button';
6
+
7
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
8
+ const meta = {
9
+ title: 'Example/Button',
10
+ component: Button,
11
+ parameters: {
12
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
13
+ layout: 'centered',
14
+ },
15
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
16
+ tags: ['autodocs'],
17
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
18
+ argTypes: {
19
+ backgroundColor: { control: 'color' },
20
+ },
21
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args
22
+ args: { onClick: fn() },
23
+ } satisfies Meta<typeof Button>;
24
+
25
+ export default meta;
26
+ type Story = StoryObj<typeof meta>;
27
+
28
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
29
+ export const Primary: Story = {
30
+ args: {
31
+ primary: true,
32
+ label: 'Button',
33
+ },
34
+ };
35
+
36
+ export const Secondary: Story = {
37
+ args: {
38
+ label: 'Button',
39
+ },
40
+ };
41
+
42
+ export const Large: Story = {
43
+ args: {
44
+ size: 'large',
45
+ label: 'Button',
46
+ },
47
+ };
48
+
49
+ export const Small: Story = {
50
+ args: {
51
+ size: 'small',
52
+ label: 'Button',
53
+ },
54
+ };
@@ -0,0 +1,35 @@
1
+ import './button.css';
2
+
3
+ export interface ButtonProps {
4
+ /** Is this the principal call to action on the page? */
5
+ primary?: boolean;
6
+ /** What background color to use */
7
+ backgroundColor?: string;
8
+ /** How large should the button be? */
9
+ size?: 'small' | 'medium' | 'large';
10
+ /** Button contents */
11
+ label: string;
12
+ /** Optional click handler */
13
+ onClick?: () => void;
14
+ }
15
+
16
+ /** Primary UI component for user interaction */
17
+ export const Button = ({
18
+ primary = false,
19
+ size = 'medium',
20
+ backgroundColor,
21
+ label,
22
+ ...props
23
+ }: ButtonProps) => {
24
+ const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
25
+ return (
26
+ <button
27
+ type="button"
28
+ className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
29
+ style={{ backgroundColor }}
30
+ {...props}
31
+ >
32
+ {label}
33
+ </button>
34
+ );
35
+ };