create-rslib 0.0.15 → 0.0.16

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 (111) hide show
  1. package/dist/index.js +141 -9
  2. package/package.json +10 -7
  3. package/template-[node-dual]-[]-js/src/index.js +1 -0
  4. package/{template-node-dual-ts → template-[node-dual]-[]-ts}/package.json +1 -0
  5. package/template-[node-dual]-[]-ts/src/index.ts +1 -0
  6. package/{template-node-dual-ts → template-[node-dual]-[]-ts}/tsconfig.json +1 -2
  7. package/template-[node-dual]-[vitest]-js/package.json +25 -0
  8. package/template-[node-dual]-[vitest]-js/rslib.config.mjs +15 -0
  9. package/template-[node-dual]-[vitest]-js/src/index.js +1 -0
  10. package/template-[node-dual]-[vitest]-js/tests/index.test.js +7 -0
  11. package/template-[node-dual]-[vitest]-js/vitest.config.js +8 -0
  12. package/template-[node-dual]-[vitest]-ts/package.json +29 -0
  13. package/template-[node-dual]-[vitest]-ts/rslib.config.ts +16 -0
  14. package/template-[node-dual]-[vitest]-ts/src/index.ts +1 -0
  15. package/template-[node-dual]-[vitest]-ts/tests/index.test.ts +7 -0
  16. package/{template-node-esm-ts → template-[node-dual]-[vitest]-ts}/tsconfig.json +1 -2
  17. package/template-[node-dual]-[vitest]-ts/vitest.config.ts +6 -0
  18. package/template-[node-esm]-[]-js/src/index.js +1 -0
  19. package/{template-node-esm-ts → template-[node-esm]-[]-ts}/package.json +1 -0
  20. package/template-[node-esm]-[]-ts/src/index.ts +1 -0
  21. package/template-[node-esm]-[]-ts/tsconfig.json +15 -0
  22. package/template-[node-esm]-[vitest]-js/package.json +23 -0
  23. package/template-[node-esm]-[vitest]-js/rslib.config.mjs +11 -0
  24. package/template-[node-esm]-[vitest]-js/src/index.js +1 -0
  25. package/template-[node-esm]-[vitest]-js/tests/index.test.js +7 -0
  26. package/template-[node-esm]-[vitest]-js/vitest.config.js +8 -0
  27. package/template-[node-esm]-[vitest]-ts/package.json +27 -0
  28. package/template-[node-esm]-[vitest]-ts/rslib.config.ts +12 -0
  29. package/template-[node-esm]-[vitest]-ts/src/index.ts +1 -0
  30. package/template-[node-esm]-[vitest]-ts/tests/index.test.ts +7 -0
  31. package/template-[node-esm]-[vitest]-ts/tsconfig.json +15 -0
  32. package/template-[node-esm]-[vitest]-ts/vitest.config.ts +6 -0
  33. package/template-[react]-[]-js/package.json +27 -0
  34. package/template-[react]-[]-js/rslib.config.mjs +23 -0
  35. package/template-[react]-[]-js/src/Button.jsx +22 -0
  36. package/template-[react]-[]-js/src/button.css +34 -0
  37. package/template-[react]-[]-js/src/index.jsx +1 -0
  38. package/template-[react]-[]-ts/package.json +31 -0
  39. package/template-[react]-[]-ts/rslib.config.ts +24 -0
  40. package/template-[react]-[]-ts/src/Button.tsx +30 -0
  41. package/template-[react]-[]-ts/src/button.css +34 -0
  42. package/template-[react]-[]-ts/src/index.tsx +1 -0
  43. package/template-[react]-[]-ts/tsconfig.json +14 -0
  44. package/template-[react]-[storybook,vitest]-js/.storybook/main.js +36 -0
  45. package/template-[react]-[storybook,vitest]-js/.storybook/preview.js +12 -0
  46. package/template-[react]-[storybook,vitest]-js/package.json +45 -0
  47. package/template-[react]-[storybook,vitest]-js/rslib.config.mjs +23 -0
  48. package/template-[react]-[storybook,vitest]-js/src/Button.jsx +22 -0
  49. package/template-[react]-[storybook,vitest]-js/src/button.css +34 -0
  50. package/template-[react]-[storybook,vitest]-js/src/index.jsx +1 -0
  51. package/template-[react]-[storybook,vitest]-js/stories/Button.stories.jsx +50 -0
  52. package/template-[react]-[storybook,vitest]-js/tests/index.test.jsx +12 -0
  53. package/template-[react]-[storybook,vitest]-js/vitest.config.js +11 -0
  54. package/template-[react]-[storybook,vitest]-js/vitest.setup.js +1 -0
  55. package/template-[react]-[storybook,vitest]-ts/.storybook/main.ts +37 -0
  56. package/template-[react]-[storybook,vitest]-ts/.storybook/preview.ts +14 -0
  57. package/template-[react]-[storybook,vitest]-ts/package.json +49 -0
  58. package/template-[react]-[storybook,vitest]-ts/rslib.config.ts +24 -0
  59. package/template-[react]-[storybook,vitest]-ts/src/Button.tsx +30 -0
  60. package/template-[react]-[storybook,vitest]-ts/src/button.css +34 -0
  61. package/template-[react]-[storybook,vitest]-ts/src/index.tsx +1 -0
  62. package/template-[react]-[storybook,vitest]-ts/stories/Button.stories.ts +52 -0
  63. package/template-[react]-[storybook,vitest]-ts/tests/index.test.tsx +12 -0
  64. package/template-[react]-[storybook,vitest]-ts/tsconfig.json +14 -0
  65. package/template-[react]-[storybook,vitest]-ts/vitest.config.ts +9 -0
  66. package/template-[react]-[storybook,vitest]-ts/vitest.setup.ts +1 -0
  67. package/template-[react]-[storybook]-js/.storybook/main.js +36 -0
  68. package/template-[react]-[storybook]-js/.storybook/preview.js +12 -0
  69. package/template-[react]-[storybook]-js/package.json +40 -0
  70. package/template-[react]-[storybook]-js/rslib.config.mjs +23 -0
  71. package/template-[react]-[storybook]-js/src/Button.jsx +22 -0
  72. package/template-[react]-[storybook]-js/src/button.css +34 -0
  73. package/template-[react]-[storybook]-js/src/index.jsx +1 -0
  74. package/template-[react]-[storybook]-js/stories/Button.stories.jsx +50 -0
  75. package/template-[react]-[storybook]-ts/.storybook/main.ts +37 -0
  76. package/template-[react]-[storybook]-ts/.storybook/preview.ts +14 -0
  77. package/template-[react]-[storybook]-ts/package.json +44 -0
  78. package/template-[react]-[storybook]-ts/rslib.config.ts +24 -0
  79. package/template-[react]-[storybook]-ts/src/Button.tsx +30 -0
  80. package/template-[react]-[storybook]-ts/src/button.css +34 -0
  81. package/template-[react]-[storybook]-ts/src/index.tsx +1 -0
  82. package/template-[react]-[storybook]-ts/stories/Button.stories.ts +52 -0
  83. package/template-[react]-[storybook]-ts/tsconfig.json +14 -0
  84. package/template-[react]-[vitest]-js/package.json +32 -0
  85. package/template-[react]-[vitest]-js/rslib.config.mjs +23 -0
  86. package/template-[react]-[vitest]-js/src/Button.jsx +22 -0
  87. package/template-[react]-[vitest]-js/src/button.css +34 -0
  88. package/template-[react]-[vitest]-js/src/index.jsx +1 -0
  89. package/template-[react]-[vitest]-js/tests/index.test.jsx +12 -0
  90. package/template-[react]-[vitest]-js/vitest.config.js +11 -0
  91. package/template-[react]-[vitest]-js/vitest.setup.js +1 -0
  92. package/template-[react]-[vitest]-ts/package.json +36 -0
  93. package/template-[react]-[vitest]-ts/rslib.config.ts +24 -0
  94. package/template-[react]-[vitest]-ts/src/Button.tsx +30 -0
  95. package/template-[react]-[vitest]-ts/src/button.css +34 -0
  96. package/template-[react]-[vitest]-ts/src/index.tsx +1 -0
  97. package/template-[react]-[vitest]-ts/tests/index.test.tsx +12 -0
  98. package/template-[react]-[vitest]-ts/tsconfig.json +14 -0
  99. package/template-[react]-[vitest]-ts/vitest.config.ts +9 -0
  100. package/template-[react]-[vitest]-ts/vitest.setup.ts +1 -0
  101. package/template-common/README.md +1 -1
  102. package/template-node-dual-js/src/index.js +0 -3
  103. package/template-node-dual-ts/src/index.ts +0 -3
  104. package/template-node-esm-js/src/index.js +0 -3
  105. package/template-node-esm-ts/src/index.ts +0 -3
  106. /package/{template-node-dual-js → template-[node-dual]-[]-js}/package.json +0 -0
  107. /package/{template-node-dual-js → template-[node-dual]-[]-js}/rslib.config.mjs +0 -0
  108. /package/{template-node-dual-ts → template-[node-dual]-[]-ts}/rslib.config.ts +0 -0
  109. /package/{template-node-esm-js → template-[node-esm]-[]-js}/package.json +0 -0
  110. /package/{template-node-esm-js → template-[node-esm]-[]-js}/rslib.config.mjs +0 -0
  111. /package/{template-node-esm-ts → template-[node-esm]-[]-ts}/rslib.config.ts +0 -0
@@ -0,0 +1,34 @@
1
+ .demo-button {
2
+ font-weight: 700;
3
+ border: 0;
4
+ border-radius: 3em;
5
+ cursor: pointer;
6
+ display: inline-block;
7
+ line-height: 1;
8
+ }
9
+
10
+ .demo-button--primary {
11
+ color: white;
12
+ background-color: #1ea7fd;
13
+ }
14
+
15
+ .demo-button--secondary {
16
+ color: #333;
17
+ background-color: transparent;
18
+ box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
19
+ }
20
+
21
+ .demo-button--small {
22
+ font-size: 12px;
23
+ padding: 10px 16px;
24
+ }
25
+
26
+ .demo-button--medium {
27
+ font-size: 14px;
28
+ padding: 11px 20px;
29
+ }
30
+
31
+ .demo-button--large {
32
+ font-size: 16px;
33
+ padding: 12px 24px;
34
+ }
@@ -0,0 +1 @@
1
+ export { Button } from './Button';
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "rslib-react-ts",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js"
9
+ }
10
+ },
11
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "rslib build",
18
+ "dev": "rslib build --watch"
19
+ },
20
+ "devDependencies": {
21
+ "@rsbuild/plugin-react": "^1.0.6",
22
+ "@rslib/core": "workspace:*",
23
+ "@types/react": "^18.3.12",
24
+ "react": "^18.3.1",
25
+ "typescript": "^5.6.3"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=16.9.0",
29
+ "react-dom": ">=16.9.0"
30
+ }
31
+ }
@@ -0,0 +1,24 @@
1
+ import { pluginReact } from '@rsbuild/plugin-react';
2
+ import { defineConfig } from '@rslib/core';
3
+
4
+ export default defineConfig({
5
+ source: {
6
+ entry: {
7
+ index: ['./src/**'],
8
+ },
9
+ },
10
+ lib: [
11
+ {
12
+ bundle: false,
13
+ dts: true,
14
+ format: 'esm',
15
+ },
16
+ ],
17
+ plugins: [
18
+ pluginReact({
19
+ swcReactOptions: {
20
+ runtime: 'classic',
21
+ },
22
+ }),
23
+ ],
24
+ });
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import './button.css';
3
+
4
+ interface ButtonProps {
5
+ primary?: boolean;
6
+ backgroundColor?: string;
7
+ size?: 'small' | 'medium' | 'large';
8
+ label: string;
9
+ onClick?: () => void;
10
+ }
11
+
12
+ export const Button = ({
13
+ primary = false,
14
+ size = 'medium',
15
+ backgroundColor,
16
+ label,
17
+ ...props
18
+ }: ButtonProps) => {
19
+ const mode = primary ? 'demo-button--primary' : 'demo-button--secondary';
20
+ return (
21
+ <button
22
+ type="button"
23
+ className={['demo-button', `demo-button--${size}`, mode].join(' ')}
24
+ style={{ backgroundColor }}
25
+ {...props}
26
+ >
27
+ {label}
28
+ </button>
29
+ );
30
+ };
@@ -0,0 +1,34 @@
1
+ .demo-button {
2
+ font-weight: 700;
3
+ border: 0;
4
+ border-radius: 3em;
5
+ cursor: pointer;
6
+ display: inline-block;
7
+ line-height: 1;
8
+ }
9
+
10
+ .demo-button--primary {
11
+ color: white;
12
+ background-color: #1ea7fd;
13
+ }
14
+
15
+ .demo-button--secondary {
16
+ color: #333;
17
+ background-color: transparent;
18
+ box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
19
+ }
20
+
21
+ .demo-button--small {
22
+ font-size: 12px;
23
+ padding: 10px 16px;
24
+ }
25
+
26
+ .demo-button--medium {
27
+ font-size: 14px;
28
+ padding: 11px 20px;
29
+ }
30
+
31
+ .demo-button--large {
32
+ font-size: 16px;
33
+ padding: 12px 24px;
34
+ }
@@ -0,0 +1 @@
1
+ export { Button } from './Button';
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["DOM", "ES2021"],
4
+ "module": "ESNext",
5
+ "jsx": "react",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "isolatedModules": true,
9
+ "resolveJsonModule": true,
10
+ "moduleResolution": "bundler",
11
+ "useDefineForClassFields": true
12
+ },
13
+ "include": ["src"]
14
+ }
@@ -0,0 +1,36 @@
1
+ import { dirname, join } from 'node:path';
2
+
3
+ /**
4
+ * This function is used to resolve the absolute path of a package.
5
+ * It is needed in projects that use Yarn PnP or are set up within a monorepo.
6
+ */
7
+ function getAbsolutePath(value) {
8
+ return dirname(require.resolve(join(value, 'package.json')));
9
+ }
10
+
11
+ const config = {
12
+ stories: [
13
+ '../stories/**/*.mdx',
14
+ '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
15
+ ],
16
+ addons: [
17
+ '@storybook/addon-onboarding',
18
+ '@storybook/addon-links',
19
+ '@storybook/addon-essentials',
20
+ '@storybook/addon-interactions',
21
+ 'storybook-addon-rslib',
22
+ ],
23
+ framework: {
24
+ name: getAbsolutePath('storybook-react-rsbuild'),
25
+ options: {},
26
+ },
27
+ docs: {
28
+ autodocs: 'tag',
29
+ },
30
+ typescript: {
31
+ reactDocgen: 'react-docgen-typescript',
32
+ check: true,
33
+ },
34
+ };
35
+
36
+ export default config;
@@ -0,0 +1,12 @@
1
+ const preview = {
2
+ parameters: {
3
+ controls: {
4
+ matchers: {
5
+ color: /(background|color)$/i,
6
+ date: /Date$/i,
7
+ },
8
+ },
9
+ },
10
+ };
11
+
12
+ export default preview;
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "rslib-react-js",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./dist/index.js"
8
+ }
9
+ },
10
+ "module": "./dist/index.js",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "rslib build",
16
+ "build:storybook": "storybook build",
17
+ "dev": "rslib build --watch",
18
+ "storybook": "storybook dev",
19
+ "test": "vitest run"
20
+ },
21
+ "devDependencies": {
22
+ "@rsbuild/core": "~1.0.19",
23
+ "@rsbuild/plugin-react": "^1.0.6",
24
+ "@rslib/core": "workspace:*",
25
+ "@storybook/addon-essentials": "^8.3.6",
26
+ "@storybook/addon-interactions": "^8.3.6",
27
+ "@storybook/addon-links": "^8.3.6",
28
+ "@storybook/addon-onboarding": "^8.3.6",
29
+ "@storybook/blocks": "^8.3.6",
30
+ "@storybook/react": "^8.3.6",
31
+ "@storybook/test": "^8.3.6",
32
+ "@testing-library/jest-dom": "^6.6.3",
33
+ "@testing-library/react": "^16.0.1",
34
+ "jsdom": "^25.0.1",
35
+ "react": "^18.3.1",
36
+ "storybook": "^8.3.6",
37
+ "storybook-addon-rslib": "^0.1.2",
38
+ "storybook-react-rsbuild": "^0.1.2",
39
+ "vitest": "^2.1.4"
40
+ },
41
+ "peerDependencies": {
42
+ "react": ">=16.9.0",
43
+ "react-dom": ">=16.9.0"
44
+ }
45
+ }
@@ -0,0 +1,23 @@
1
+ import { pluginReact } from '@rsbuild/plugin-react';
2
+ import { defineConfig } from '@rslib/core';
3
+
4
+ export default defineConfig({
5
+ source: {
6
+ entry: {
7
+ index: ['./src/**'],
8
+ },
9
+ },
10
+ lib: [
11
+ {
12
+ bundle: false,
13
+ format: 'esm',
14
+ },
15
+ ],
16
+ plugins: [
17
+ pluginReact({
18
+ swcReactOptions: {
19
+ runtime: 'classic',
20
+ },
21
+ }),
22
+ ],
23
+ });
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import './button.css';
3
+
4
+ export const Button = ({
5
+ primary = false,
6
+ size = 'medium',
7
+ backgroundColor,
8
+ label,
9
+ ...props
10
+ }) => {
11
+ const mode = primary ? 'demo-button--primary' : 'demo-button--secondary';
12
+ return (
13
+ <button
14
+ type="button"
15
+ className={['demo-button', `demo-button--${size}`, mode].join(' ')}
16
+ style={{ backgroundColor }}
17
+ {...props}
18
+ >
19
+ {label}
20
+ </button>
21
+ );
22
+ };
@@ -0,0 +1,34 @@
1
+ .demo-button {
2
+ font-weight: 700;
3
+ border: 0;
4
+ border-radius: 3em;
5
+ cursor: pointer;
6
+ display: inline-block;
7
+ line-height: 1;
8
+ }
9
+
10
+ .demo-button--primary {
11
+ color: white;
12
+ background-color: #1ea7fd;
13
+ }
14
+
15
+ .demo-button--secondary {
16
+ color: #333;
17
+ background-color: transparent;
18
+ box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
19
+ }
20
+
21
+ .demo-button--small {
22
+ font-size: 12px;
23
+ padding: 10px 16px;
24
+ }
25
+
26
+ .demo-button--medium {
27
+ font-size: 14px;
28
+ padding: 11px 20px;
29
+ }
30
+
31
+ .demo-button--large {
32
+ font-size: 16px;
33
+ padding: 12px 24px;
34
+ }
@@ -0,0 +1 @@
1
+ export { Button } from './Button';
@@ -0,0 +1,50 @@
1
+ import { fn } from '@storybook/test';
2
+ import { Button } from '../src/Button';
3
+
4
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
5
+ const meta = {
6
+ title: 'Example/Button',
7
+ component: Button,
8
+ parameters: {
9
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
10
+ layout: 'centered',
11
+ },
12
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
13
+ tags: ['autodocs'],
14
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
15
+ argTypes: {
16
+ backgroundColor: { control: 'color' },
17
+ },
18
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
19
+ args: { onClick: fn() },
20
+ };
21
+
22
+ export default meta;
23
+
24
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
25
+ export const Primary = {
26
+ args: {
27
+ primary: true,
28
+ label: 'Button',
29
+ },
30
+ };
31
+
32
+ export const Secondary = {
33
+ args: {
34
+ label: 'Button',
35
+ },
36
+ };
37
+
38
+ export const Large = {
39
+ args: {
40
+ size: 'large',
41
+ label: 'Button',
42
+ },
43
+ };
44
+
45
+ export const Small = {
46
+ args: {
47
+ size: 'small',
48
+ label: 'Button',
49
+ },
50
+ };
@@ -0,0 +1,12 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import React from 'react';
3
+ import { expect, test } from 'vitest';
4
+ import { Button } from '../src/Button';
5
+
6
+ test('The button should have correct background color', async () => {
7
+ render(<Button backgroundColor="#ccc" label="Demo Button" />);
8
+ const button = screen.getByText('Demo Button');
9
+ expect(button).toHaveStyle({
10
+ backgroundColor: '#ccc',
11
+ });
12
+ });
@@ -0,0 +1,11 @@
1
+ /// <reference types="vitest/config" />
2
+
3
+ import { defineConfig } from 'vitest/config';
4
+
5
+ export default defineConfig({
6
+ // Configure Vitest (https://vitest.dev/config/)
7
+ test: {
8
+ environment: 'jsdom',
9
+ setupFiles: './vitest.setup.js',
10
+ },
11
+ });
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom/vitest';
@@ -0,0 +1,37 @@
1
+ import { dirname, join } from 'node:path';
2
+ import type { StorybookConfig } from 'storybook-react-rsbuild';
3
+
4
+ /**
5
+ * This function is used to resolve the absolute path of a package.
6
+ * It is needed in projects that use Yarn PnP or are set up within a monorepo.
7
+ */
8
+ function getAbsolutePath(value: string): any {
9
+ return dirname(require.resolve(join(value, 'package.json')));
10
+ }
11
+
12
+ const config: StorybookConfig = {
13
+ stories: [
14
+ '../stories/**/*.mdx',
15
+ '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
16
+ ],
17
+ addons: [
18
+ '@storybook/addon-onboarding',
19
+ '@storybook/addon-links',
20
+ '@storybook/addon-essentials',
21
+ '@storybook/addon-interactions',
22
+ 'storybook-addon-rslib',
23
+ ],
24
+ framework: {
25
+ name: getAbsolutePath('storybook-react-rsbuild'),
26
+ options: {},
27
+ },
28
+ docs: {
29
+ autodocs: 'tag',
30
+ },
31
+ typescript: {
32
+ reactDocgen: 'react-docgen-typescript',
33
+ check: true,
34
+ },
35
+ };
36
+
37
+ export default config;
@@ -0,0 +1,14 @@
1
+ import type { Preview } from '@storybook/react';
2
+
3
+ const preview: Preview = {
4
+ parameters: {
5
+ controls: {
6
+ matchers: {
7
+ color: /(background|color)$/i,
8
+ date: /Date$/i,
9
+ },
10
+ },
11
+ },
12
+ };
13
+
14
+ export default preview;
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "rslib-react-ts",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js"
9
+ }
10
+ },
11
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "rslib build",
18
+ "build:storybook": "storybook build",
19
+ "dev": "rslib build --watch",
20
+ "storybook": "storybook dev",
21
+ "test": "vitest run"
22
+ },
23
+ "devDependencies": {
24
+ "@rsbuild/core": "~1.0.19",
25
+ "@rsbuild/plugin-react": "^1.0.6",
26
+ "@rslib/core": "workspace:*",
27
+ "@storybook/addon-essentials": "^8.3.6",
28
+ "@storybook/addon-interactions": "^8.3.6",
29
+ "@storybook/addon-links": "^8.3.6",
30
+ "@storybook/addon-onboarding": "^8.3.6",
31
+ "@storybook/blocks": "^8.3.6",
32
+ "@storybook/react": "^8.3.6",
33
+ "@storybook/test": "^8.3.6",
34
+ "@testing-library/jest-dom": "^6.6.3",
35
+ "@testing-library/react": "^16.0.1",
36
+ "@types/react": "^18.3.12",
37
+ "jsdom": "^25.0.1",
38
+ "react": "^18.3.1",
39
+ "storybook": "^8.3.6",
40
+ "storybook-addon-rslib": "^0.1.2",
41
+ "storybook-react-rsbuild": "^0.1.2",
42
+ "typescript": "^5.6.3",
43
+ "vitest": "^2.1.4"
44
+ },
45
+ "peerDependencies": {
46
+ "react": ">=16.9.0",
47
+ "react-dom": ">=16.9.0"
48
+ }
49
+ }
@@ -0,0 +1,24 @@
1
+ import { pluginReact } from '@rsbuild/plugin-react';
2
+ import { defineConfig } from '@rslib/core';
3
+
4
+ export default defineConfig({
5
+ source: {
6
+ entry: {
7
+ index: ['./src/**'],
8
+ },
9
+ },
10
+ lib: [
11
+ {
12
+ bundle: false,
13
+ dts: true,
14
+ format: 'esm',
15
+ },
16
+ ],
17
+ plugins: [
18
+ pluginReact({
19
+ swcReactOptions: {
20
+ runtime: 'classic',
21
+ },
22
+ }),
23
+ ],
24
+ });
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import './button.css';
3
+
4
+ interface ButtonProps {
5
+ primary?: boolean;
6
+ backgroundColor?: string;
7
+ size?: 'small' | 'medium' | 'large';
8
+ label: string;
9
+ onClick?: () => void;
10
+ }
11
+
12
+ export const Button = ({
13
+ primary = false,
14
+ size = 'medium',
15
+ backgroundColor,
16
+ label,
17
+ ...props
18
+ }: ButtonProps) => {
19
+ const mode = primary ? 'demo-button--primary' : 'demo-button--secondary';
20
+ return (
21
+ <button
22
+ type="button"
23
+ className={['demo-button', `demo-button--${size}`, mode].join(' ')}
24
+ style={{ backgroundColor }}
25
+ {...props}
26
+ >
27
+ {label}
28
+ </button>
29
+ );
30
+ };
@@ -0,0 +1,34 @@
1
+ .demo-button {
2
+ font-weight: 700;
3
+ border: 0;
4
+ border-radius: 3em;
5
+ cursor: pointer;
6
+ display: inline-block;
7
+ line-height: 1;
8
+ }
9
+
10
+ .demo-button--primary {
11
+ color: white;
12
+ background-color: #1ea7fd;
13
+ }
14
+
15
+ .demo-button--secondary {
16
+ color: #333;
17
+ background-color: transparent;
18
+ box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
19
+ }
20
+
21
+ .demo-button--small {
22
+ font-size: 12px;
23
+ padding: 10px 16px;
24
+ }
25
+
26
+ .demo-button--medium {
27
+ font-size: 14px;
28
+ padding: 11px 20px;
29
+ }
30
+
31
+ .demo-button--large {
32
+ font-size: 16px;
33
+ padding: 12px 24px;
34
+ }
@@ -0,0 +1 @@
1
+ export { Button } from './Button';