create-rslib 0.8.0 → 0.9.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.
- package/dist/index.js +64 -5
- package/package.json +4 -4
- package/template-[node-dual]-[]-ts/package.json +1 -1
- package/template-[node-dual]-[vitest]-ts/package.json +1 -1
- package/template-[node-esm]-[]-ts/package.json +1 -1
- package/template-[node-esm]-[vitest]-ts/package.json +1 -1
- package/template-[react]-[]-ts/package.json +1 -1
- package/template-[react]-[storybook,vitest]-js/package.json +1 -1
- package/template-[react]-[storybook,vitest]-ts/package.json +2 -2
- package/template-[react]-[storybook]-js/package.json +1 -1
- package/template-[react]-[storybook]-ts/package.json +2 -2
- package/template-[react]-[vitest]-ts/package.json +1 -1
- package/template-[vue]-[]-js/package.json +27 -0
- package/template-[vue]-[]-js/rslib.config.ts +15 -0
- package/template-[vue]-[]-js/src/Button.vue +43 -0
- package/template-[vue]-[]-js/src/index.js +1 -0
- package/template-[vue]-[]-js/src/style.css +34 -0
- package/template-[vue]-[]-ts/package.json +29 -0
- package/template-[vue]-[]-ts/rslib.config.ts +15 -0
- package/template-[vue]-[]-ts/src/Button.vue +35 -0
- package/template-[vue]-[]-ts/src/index.ts +1 -0
- package/template-[vue]-[]-ts/src/style.css +34 -0
- package/template-[vue]-[]-ts/tsconfig.json +25 -0
- package/template-[vue]-[storybook,vitest]-js/.storybook/main.js +37 -0
- package/template-[vue]-[storybook,vitest]-js/.storybook/preview.js +12 -0
- package/template-[vue]-[storybook,vitest]-js/package.json +46 -0
- package/template-[vue]-[storybook,vitest]-js/rslib.config.ts +15 -0
- package/template-[vue]-[storybook,vitest]-js/src/Button.vue +43 -0
- package/template-[vue]-[storybook,vitest]-js/src/index.js +1 -0
- package/template-[vue]-[storybook,vitest]-js/src/style.css +34 -0
- package/template-[vue]-[storybook,vitest]-js/stories/Button.stories.js +50 -0
- package/template-[vue]-[storybook,vitest]-js/tests/index.test.js +16 -0
- package/template-[vue]-[storybook,vitest]-js/vitest.config.js +13 -0
- package/template-[vue]-[storybook,vitest]-js/vitest.setup.js +1 -0
- package/template-[vue]-[storybook,vitest]-ts/.storybook/main.ts +38 -0
- package/template-[vue]-[storybook,vitest]-ts/.storybook/preview.ts +12 -0
- package/template-[vue]-[storybook,vitest]-ts/package.json +48 -0
- package/template-[vue]-[storybook,vitest]-ts/rslib.config.ts +15 -0
- package/template-[vue]-[storybook,vitest]-ts/src/Button.vue +35 -0
- package/template-[vue]-[storybook,vitest]-ts/src/index.ts +1 -0
- package/template-[vue]-[storybook,vitest]-ts/src/style.css +34 -0
- package/template-[vue]-[storybook,vitest]-ts/stories/Button.stories.js +50 -0
- package/template-[vue]-[storybook,vitest]-ts/tests/index.test.ts +16 -0
- package/template-[vue]-[storybook,vitest]-ts/tsconfig.json +25 -0
- package/template-[vue]-[storybook,vitest]-ts/vitest.config.js +13 -0
- package/template-[vue]-[storybook,vitest]-ts/vitest.setup.js +1 -0
- package/template-[vue]-[storybook]-js/.storybook/main.js +37 -0
- package/template-[vue]-[storybook]-js/.storybook/preview.js +12 -0
- package/template-[vue]-[storybook]-js/package.json +40 -0
- package/template-[vue]-[storybook]-js/rslib.config.ts +15 -0
- package/template-[vue]-[storybook]-js/src/Button.vue +43 -0
- package/template-[vue]-[storybook]-js/src/index.js +1 -0
- package/template-[vue]-[storybook]-js/src/style.css +34 -0
- package/template-[vue]-[storybook]-js/stories/Button.stories.js +50 -0
- package/template-[vue]-[storybook]-ts/.storybook/main.ts +38 -0
- package/template-[vue]-[storybook]-ts/.storybook/preview.ts +12 -0
- package/template-[vue]-[storybook]-ts/package.json +42 -0
- package/template-[vue]-[storybook]-ts/rslib.config.ts +15 -0
- package/template-[vue]-[storybook]-ts/src/Button.vue +35 -0
- package/template-[vue]-[storybook]-ts/src/index.ts +1 -0
- package/template-[vue]-[storybook]-ts/src/style.css +34 -0
- package/template-[vue]-[storybook]-ts/stories/Button.stories.js +50 -0
- package/template-[vue]-[storybook]-ts/tsconfig.json +25 -0
- package/template-[vue]-[vitest]-js/package.json +33 -0
- package/template-[vue]-[vitest]-js/rslib.config.ts +15 -0
- package/template-[vue]-[vitest]-js/src/Button.vue +43 -0
- package/template-[vue]-[vitest]-js/src/index.js +1 -0
- package/template-[vue]-[vitest]-js/src/style.css +34 -0
- package/template-[vue]-[vitest]-js/tests/index.test.js +16 -0
- package/template-[vue]-[vitest]-js/vitest.config.js +13 -0
- package/template-[vue]-[vitest]-js/vitest.setup.js +1 -0
- package/template-[vue]-[vitest]-ts/package.json +35 -0
- package/template-[vue]-[vitest]-ts/rslib.config.ts +15 -0
- package/template-[vue]-[vitest]-ts/src/Button.vue +35 -0
- package/template-[vue]-[vitest]-ts/src/index.ts +1 -0
- package/template-[vue]-[vitest]-ts/src/style.css +34 -0
- package/template-[vue]-[vitest]-ts/tests/index.test.ts +16 -0
- package/template-[vue]-[vitest]-ts/tsconfig.json +25 -0
- package/template-[vue]-[vitest]-ts/vitest.config.js +13 -0
- package/template-[vue]-[vitest]-ts/vitest.setup.js +1 -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,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,16 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/vue';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import Button from '../src/Button.vue';
|
|
4
|
+
|
|
5
|
+
test('The button should have correct background color', async () => {
|
|
6
|
+
render(Button, {
|
|
7
|
+
props: {
|
|
8
|
+
backgroundColor: '#ccc',
|
|
9
|
+
label: 'Demo Button',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
const button = screen.getByText('Demo Button');
|
|
13
|
+
expect(button).toHaveStyle({
|
|
14
|
+
backgroundColor: '#ccc',
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="vitest/config" />
|
|
2
|
+
|
|
3
|
+
import pluginVue from '@vitejs/plugin-vue';
|
|
4
|
+
import { defineConfig } from 'vitest/config';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
// Configure Vitest (https://vitest.dev/config/)
|
|
8
|
+
test: {
|
|
9
|
+
environment: 'jsdom',
|
|
10
|
+
setupFiles: './vitest.setup.js',
|
|
11
|
+
},
|
|
12
|
+
plugins: [pluginVue()],
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { dirname, join } from 'node:path';
|
|
2
|
+
import type { StorybookConfig } from 'storybook-vue3-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) {
|
|
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
|
+
{
|
|
23
|
+
name: getAbsolutePath('storybook-addon-rslib'),
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
framework: {
|
|
27
|
+
name: getAbsolutePath('storybook-vue3-rsbuild'),
|
|
28
|
+
options: {},
|
|
29
|
+
},
|
|
30
|
+
docs: {
|
|
31
|
+
autodocs: 'tag',
|
|
32
|
+
},
|
|
33
|
+
typescript: {
|
|
34
|
+
check: true,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default config;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rslib-vue-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
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "rslib build && vue-tsc",
|
|
17
|
+
"build:storybook": "storybook build",
|
|
18
|
+
"dev": "rslib build --watch",
|
|
19
|
+
"storybook": "storybook dev",
|
|
20
|
+
"test": "vitest run"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@rsbuild/core": "1.3.14",
|
|
24
|
+
"@rslib/core": "workspace:*",
|
|
25
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
26
|
+
"@storybook/addon-interactions": "^8.6.12",
|
|
27
|
+
"@storybook/addon-links": "^8.6.12",
|
|
28
|
+
"@storybook/addon-onboarding": "^8.6.12",
|
|
29
|
+
"@storybook/blocks": "^8.6.12",
|
|
30
|
+
"@storybook/test": "^8.6.12",
|
|
31
|
+
"@storybook/vue3": "^8.6.12",
|
|
32
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
33
|
+
"@testing-library/vue": "^8.1.0",
|
|
34
|
+
"@vitejs/plugin-vue": "^5.2.3",
|
|
35
|
+
"jsdom": "^26.1.0",
|
|
36
|
+
"rsbuild-plugin-unplugin-vue": "^0.1.0",
|
|
37
|
+
"storybook": "^8.6.12",
|
|
38
|
+
"storybook-addon-rslib": "^1.0.1",
|
|
39
|
+
"storybook-vue3-rsbuild": "^1.0.1",
|
|
40
|
+
"typescript": "^5.8.3",
|
|
41
|
+
"vitest": "^3.1.2",
|
|
42
|
+
"vue": "^3.2.0",
|
|
43
|
+
"vue-tsc": "^2.2.10"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"vue": "^3.2.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from '@rslib/core';
|
|
2
|
+
import { pluginUnpluginVue } from 'rsbuild-plugin-unplugin-vue';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
lib: [
|
|
6
|
+
{
|
|
7
|
+
bundle: false,
|
|
8
|
+
format: 'esm',
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
output: {
|
|
12
|
+
target: 'web',
|
|
13
|
+
},
|
|
14
|
+
plugins: [pluginUnpluginVue()],
|
|
15
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import './style.css';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
primary?: boolean;
|
|
7
|
+
backgroundColor?: string;
|
|
8
|
+
size?: 'small' | 'medium' | 'large';
|
|
9
|
+
label: string;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
primary = false,
|
|
15
|
+
backgroundColor = undefined,
|
|
16
|
+
size = 'medium',
|
|
17
|
+
label,
|
|
18
|
+
onClick = undefined,
|
|
19
|
+
} = defineProps<Props>();
|
|
20
|
+
|
|
21
|
+
const mode = computed(() =>
|
|
22
|
+
primary ? 'demo-button--primary' : 'demo-button--secondary',
|
|
23
|
+
);
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
:class="['demo-button', `demo-button--${size}`, mode]"
|
|
30
|
+
:style="{ backgroundColor }"
|
|
31
|
+
@click="onClick"
|
|
32
|
+
>
|
|
33
|
+
{{ label }}
|
|
34
|
+
</button>
|
|
35
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Button } from './Button.vue';
|
|
@@ -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,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,16 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/vue';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import Button from '../src/Button.vue';
|
|
4
|
+
|
|
5
|
+
test('The button should have correct background color', async () => {
|
|
6
|
+
render(Button, {
|
|
7
|
+
props: {
|
|
8
|
+
backgroundColor: '#ccc',
|
|
9
|
+
label: 'Demo Button',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
const button = screen.getByText('Demo Button');
|
|
13
|
+
expect(button).toHaveStyle({
|
|
14
|
+
backgroundColor: '#ccc',
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["DOM", "ES2020"],
|
|
4
|
+
"jsx": "preserve",
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"jsxImportSource": "vue",
|
|
8
|
+
"useDefineForClassFields": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"outDir": "dist",
|
|
11
|
+
"emitDeclarationOnly": true,
|
|
12
|
+
|
|
13
|
+
/* modules */
|
|
14
|
+
"module": "ESNext",
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"moduleResolution": "bundler",
|
|
18
|
+
|
|
19
|
+
/* type checking */
|
|
20
|
+
"strict": true,
|
|
21
|
+
"noUnusedLocals": true,
|
|
22
|
+
"noUnusedParameters": true
|
|
23
|
+
},
|
|
24
|
+
"include": ["src"]
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="vitest/config" />
|
|
2
|
+
|
|
3
|
+
import pluginVue from '@vitejs/plugin-vue';
|
|
4
|
+
import { defineConfig } from 'vitest/config';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
// Configure Vitest (https://vitest.dev/config/)
|
|
8
|
+
test: {
|
|
9
|
+
environment: 'jsdom',
|
|
10
|
+
setupFiles: './vitest.setup.js',
|
|
11
|
+
},
|
|
12
|
+
plugins: [pluginVue()],
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
{
|
|
22
|
+
name: getAbsolutePath('storybook-addon-rslib'),
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
framework: {
|
|
26
|
+
name: getAbsolutePath('storybook-vue3-rsbuild'),
|
|
27
|
+
options: {},
|
|
28
|
+
},
|
|
29
|
+
docs: {
|
|
30
|
+
autodocs: 'tag',
|
|
31
|
+
},
|
|
32
|
+
typescript: {
|
|
33
|
+
check: true,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default config;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rslib-vue-js",
|
|
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
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "rslib build",
|
|
17
|
+
"build:storybook": "storybook build",
|
|
18
|
+
"dev": "rslib build --watch",
|
|
19
|
+
"storybook": "storybook dev"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@rsbuild/core": "1.3.14",
|
|
23
|
+
"@rslib/core": "workspace:*",
|
|
24
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
25
|
+
"@storybook/addon-interactions": "^8.6.12",
|
|
26
|
+
"@storybook/addon-links": "^8.6.12",
|
|
27
|
+
"@storybook/addon-onboarding": "^8.6.12",
|
|
28
|
+
"@storybook/blocks": "^8.6.12",
|
|
29
|
+
"@storybook/test": "^8.6.12",
|
|
30
|
+
"@storybook/vue3": "^8.6.12",
|
|
31
|
+
"rsbuild-plugin-unplugin-vue": "^0.1.0",
|
|
32
|
+
"storybook": "^8.6.12",
|
|
33
|
+
"storybook-addon-rslib": "^1.0.1",
|
|
34
|
+
"storybook-vue3-rsbuild": "^1.0.1",
|
|
35
|
+
"vue": "^3.2.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"vue": "^3.2.0"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from '@rslib/core';
|
|
2
|
+
import { pluginUnpluginVue } from 'rsbuild-plugin-unplugin-vue';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
lib: [
|
|
6
|
+
{
|
|
7
|
+
bundle: false,
|
|
8
|
+
format: 'esm',
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
output: {
|
|
12
|
+
target: 'web',
|
|
13
|
+
},
|
|
14
|
+
plugins: [pluginUnpluginVue()],
|
|
15
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import './style.css';
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
primary = false,
|
|
7
|
+
backgroundColor,
|
|
8
|
+
size = 'medium',
|
|
9
|
+
label,
|
|
10
|
+
onClick,
|
|
11
|
+
} = defineProps({
|
|
12
|
+
primary: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
},
|
|
15
|
+
backgroundColor: {
|
|
16
|
+
type: String,
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
type: String,
|
|
20
|
+
},
|
|
21
|
+
label: {
|
|
22
|
+
type: String,
|
|
23
|
+
},
|
|
24
|
+
onClick: {
|
|
25
|
+
type: Function,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const mode = computed(() =>
|
|
30
|
+
primary ? 'demo-button--primary' : 'demo-button--secondary',
|
|
31
|
+
);
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
:class="['demo-button', `demo-button--${size}`, mode]"
|
|
38
|
+
:style="{ backgroundColor }"
|
|
39
|
+
@click="onClick"
|
|
40
|
+
>
|
|
41
|
+
{{ label }}
|
|
42
|
+
</button>
|
|
43
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Button } from './Button.vue';
|
|
@@ -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,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
|
+
};
|