@mbao01/ui 0.0.1 → 0.0.2
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/README.md +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/src/components/Button/Button.d.ts +2 -0
- package/dist/src/components/Button/Button.stories.d.ts +19 -0
- package/dist/src/components/Button/Button.test.d.ts +1 -0
- package/dist/src/components/Button/constants.d.ts +8 -0
- package/dist/src/components/Button/index.d.ts +1 -0
- package/dist/src/components/Button/types.d.ts +12 -0
- package/dist/src/components/Text/Text.d.ts +4 -0
- package/dist/src/components/Text/Text.stories.d.ts +17 -0
- package/dist/src/components/Text/Text.test.d.ts +1 -0
- package/dist/src/components/Text/constants.d.ts +5 -0
- package/dist/src/components/Text/index.d.ts +1 -0
- package/dist/src/components/Text/types.d.ts +10 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/tailwind.config.d.ts +3 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/vitest-setup.d.ts +0 -0
- package/dist/vitest.config.d.ts +2 -0
- package/package.json +18 -6
- package/src/components/Text/Text.stories.ts +47 -0
- package/src/components/Text/constants.ts +29 -0
- package/src/components/Text/index.ts +1 -0
- package/src/components/Text/types.ts +21 -0
- package/src/components/Button/Button.tsx +0 -37
- package/src/tailwind.css +0 -25
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](http://commitizen.github.io/cz-cli/)
|
|
2
|
+
|
|
1
3
|
So here it is, I have gotten really bored creating UI component from scratch for the many projects I work on.
|
|
2
4
|
It is high time I have a unified component library - so here it is.
|
|
3
5
|
I have built this to be highly opinionated on certain libraries I love to use like typescript, tailwind, date-fns, and react.
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './src/index'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
component: (props: import("./types").ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
parameters: {
|
|
5
|
+
layout: string;
|
|
6
|
+
};
|
|
7
|
+
tags: string[];
|
|
8
|
+
argTypes: {};
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
export declare const Default: Story;
|
|
13
|
+
export declare const PrimaryButton: Story;
|
|
14
|
+
export declare const WideButton: Story;
|
|
15
|
+
export declare const TinyButton: Story;
|
|
16
|
+
export declare const OutlineButton: Story;
|
|
17
|
+
export declare const DisabledButton: Story;
|
|
18
|
+
export declare const LoadingButton: Story;
|
|
19
|
+
export declare const BlockButton: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ButtonSize, ButtonVariant } from './types';
|
|
2
|
+
export declare const getButtonClasses: ({ size, wide, loading, outline, variant, }: {
|
|
3
|
+
size?: ButtonSize | undefined;
|
|
4
|
+
wide?: boolean | undefined;
|
|
5
|
+
loading?: boolean | undefined;
|
|
6
|
+
outline?: boolean | undefined;
|
|
7
|
+
variant?: ButtonVariant | undefined;
|
|
8
|
+
}) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button } from "./Button";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
|
+
export type ButtonVariant = 'default' | 'neutral' | 'primary' | 'secondary' | 'accent' | 'ghost' | 'link' | 'info' | 'success' | 'warning' | 'error';
|
|
4
|
+
export type ButtonProps = {
|
|
5
|
+
size?: ButtonSize;
|
|
6
|
+
wide?: boolean;
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
outline?: boolean;
|
|
10
|
+
variant?: ButtonVariant;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
} & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
component: ({ as, size, variant, children, className }: import("./types").TextProps) => import("react").DetailedReactHTMLElement<{
|
|
4
|
+
className: string;
|
|
5
|
+
}, HTMLElement>;
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
tags: string[];
|
|
10
|
+
argTypes: {};
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
type Story = StoryObj<typeof meta>;
|
|
14
|
+
export declare const Default: Story;
|
|
15
|
+
export declare const PrimaryText: Story;
|
|
16
|
+
export declare const TinyText: Story;
|
|
17
|
+
export declare const HeadingText: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Text } from './Text';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type TextSize = 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
|
|
2
|
+
export type TextTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'p' | 'span';
|
|
3
|
+
export type TextVariant = 'info' | 'error' | 'success' | 'warning' | 'primary' | 'secondary' | 'accent' | 'neutral';
|
|
4
|
+
export type TextProps = {
|
|
5
|
+
as?: TextTag;
|
|
6
|
+
size?: TextSize;
|
|
7
|
+
variant?: TextVariant;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./components/Button";
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbao01/ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
7
7
|
"license": "MIT",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"main": "./src/index.ts",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"files": [
|
|
18
|
-
"src",
|
|
19
18
|
"plugin.js",
|
|
20
19
|
"plugin.d.ts",
|
|
21
|
-
"
|
|
20
|
+
"src/**/*.ts",
|
|
21
|
+
"dist/**/*.d.ts"
|
|
22
22
|
],
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"scripts": {
|
|
@@ -26,7 +26,11 @@
|
|
|
26
26
|
"build": "tsc && vite build",
|
|
27
27
|
"build-storybook": "storybook build",
|
|
28
28
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
29
|
-
"preview": "vite preview"
|
|
29
|
+
"preview": "vite preview",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:ui": "vitest --ui",
|
|
32
|
+
"test:watch": "vitest",
|
|
33
|
+
"test:coverage": "vitest run --coverage"
|
|
30
34
|
},
|
|
31
35
|
"dependencies": {
|
|
32
36
|
"autoprefixer": "^10.4.16",
|
|
@@ -43,17 +47,23 @@
|
|
|
43
47
|
"@storybook/react": "^7.6.6",
|
|
44
48
|
"@storybook/react-vite": "^7.6.6",
|
|
45
49
|
"@storybook/test": "^7.6.6",
|
|
50
|
+
"@testing-library/jest-dom": "^6.1.6",
|
|
51
|
+
"@testing-library/react": "^14.1.2",
|
|
52
|
+
"@testing-library/user-event": "^14.5.2",
|
|
46
53
|
"@types/node": "^20.10.5",
|
|
47
54
|
"@types/react": "^18.2.43",
|
|
48
55
|
"@types/react-dom": "^18.2.17",
|
|
49
56
|
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
|
50
57
|
"@typescript-eslint/parser": "^6.14.0",
|
|
51
58
|
"@vitejs/plugin-react": "^4.2.1",
|
|
59
|
+
"@vitest/coverage-v8": "^1.1.1",
|
|
60
|
+
"@vitest/ui": "^1.1.1",
|
|
52
61
|
"eslint": "^8.55.0",
|
|
53
62
|
"eslint-plugin-react": "^7.33.2",
|
|
54
63
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
55
64
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
56
65
|
"eslint-plugin-storybook": "^0.6.15",
|
|
66
|
+
"jsdom": "^23.0.1",
|
|
57
67
|
"path": "^0.12.7",
|
|
58
68
|
"postcss": "^8.4.32",
|
|
59
69
|
"react": "^18.2.0",
|
|
@@ -62,7 +72,8 @@
|
|
|
62
72
|
"tailwindcss": "^3.4.0",
|
|
63
73
|
"typescript": "^5.2.2",
|
|
64
74
|
"vite": "^5.0.8",
|
|
65
|
-
"vite-plugin-dts": "^3.7.0"
|
|
75
|
+
"vite-plugin-dts": "^3.7.0",
|
|
76
|
+
"vitest": "^1.1.1"
|
|
66
77
|
},
|
|
67
78
|
"peerDependencies": {
|
|
68
79
|
"postcss": "^8.4.32",
|
|
@@ -70,5 +81,6 @@
|
|
|
70
81
|
"react-dom": "^18.2.0",
|
|
71
82
|
"tailwindcss": "^3.4.0",
|
|
72
83
|
"typescript": "^5.2.2"
|
|
73
|
-
}
|
|
84
|
+
},
|
|
85
|
+
"gitHead": "befbd919a67ae1084ad5ef64cf4cc1ced6f848e2"
|
|
74
86
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { Text } from './Text';
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
6
|
+
const meta = {
|
|
7
|
+
component: Text,
|
|
8
|
+
parameters: {
|
|
9
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
},
|
|
12
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
|
15
|
+
argTypes: {},
|
|
16
|
+
} satisfies Meta<typeof Text>;
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
children: 'Text',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const PrimaryText: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
variant: 'primary',
|
|
31
|
+
children: 'Primary text',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const TinyText: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
size: 'xs',
|
|
38
|
+
children: 'Tiny Text',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const HeadingText: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
as: 'h1',
|
|
45
|
+
children: 'Heading 1',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import c from 'clsx';
|
|
2
|
+
import type { TextSize, TextVariant } from './types';
|
|
3
|
+
|
|
4
|
+
const TEXT_SIZE = {
|
|
5
|
+
xs: c('text-xs'),
|
|
6
|
+
sm: c('text-sm'),
|
|
7
|
+
base: c('text-base'),
|
|
8
|
+
lg: c('text-lg'),
|
|
9
|
+
xl: c('text-xl'),
|
|
10
|
+
'2xl': c('text-2xl'),
|
|
11
|
+
'3xl': c('text-3xl'),
|
|
12
|
+
'4xl': c('text-4xl'),
|
|
13
|
+
'5xl': c('text-5xl'),
|
|
14
|
+
} satisfies Record<TextSize, string>;
|
|
15
|
+
|
|
16
|
+
const TEXT_VARIANT = {
|
|
17
|
+
info: c('text-info'),
|
|
18
|
+
error: c('text-error'),
|
|
19
|
+
success: c('text-success'),
|
|
20
|
+
warning: c('text-warning'),
|
|
21
|
+
primary: c('text-primary'),
|
|
22
|
+
secondary: c('text-secondary'),
|
|
23
|
+
accent: c('text-accent'),
|
|
24
|
+
neutral: c('text-neutral'),
|
|
25
|
+
} satisfies Record<TextVariant, string>;
|
|
26
|
+
|
|
27
|
+
export const getTextClasses = ({ size, variant }: { size?: TextSize; variant?: TextVariant }) => {
|
|
28
|
+
return c(TEXT_VARIANT[variant!], TEXT_SIZE[size!]);
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Text } from './Text';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type TextSize = 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
|
|
2
|
+
|
|
3
|
+
export type TextTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'p' | 'span';
|
|
4
|
+
|
|
5
|
+
export type TextVariant =
|
|
6
|
+
| 'info'
|
|
7
|
+
| 'error'
|
|
8
|
+
| 'success'
|
|
9
|
+
| 'warning'
|
|
10
|
+
| 'primary'
|
|
11
|
+
| 'secondary'
|
|
12
|
+
| 'accent'
|
|
13
|
+
| 'neutral';
|
|
14
|
+
|
|
15
|
+
export type TextProps = {
|
|
16
|
+
as?: TextTag;
|
|
17
|
+
size?: TextSize;
|
|
18
|
+
variant?: TextVariant;
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
className?: string;
|
|
21
|
+
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import c from "clsx";
|
|
2
|
-
import { getButtonClasses } from "./constants";
|
|
3
|
-
import { type ButtonProps } from "./types";
|
|
4
|
-
|
|
5
|
-
export const Button = (props: ButtonProps) => {
|
|
6
|
-
const {
|
|
7
|
-
className,
|
|
8
|
-
outline,
|
|
9
|
-
label,
|
|
10
|
-
disabled,
|
|
11
|
-
onClick,
|
|
12
|
-
loading,
|
|
13
|
-
variant,
|
|
14
|
-
size,
|
|
15
|
-
wide,
|
|
16
|
-
...rest
|
|
17
|
-
} = props;
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<button
|
|
21
|
-
{...rest}
|
|
22
|
-
onClick={onClick}
|
|
23
|
-
disabled={disabled}
|
|
24
|
-
className={c(
|
|
25
|
-
getButtonClasses({ size, wide, outline, variant, loading }),
|
|
26
|
-
className
|
|
27
|
-
)}
|
|
28
|
-
>
|
|
29
|
-
{label}
|
|
30
|
-
{loading ? (
|
|
31
|
-
<span className="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-[inherit]">
|
|
32
|
-
<span className="loading loading-spinner" />
|
|
33
|
-
</span>
|
|
34
|
-
) : null}
|
|
35
|
-
</button>
|
|
36
|
-
);
|
|
37
|
-
};
|
package/src/tailwind.css
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
@tailwind base;
|
|
2
|
-
@tailwind components;
|
|
3
|
-
@tailwind utilities;
|
|
4
|
-
|
|
5
|
-
.scroll-shadow {
|
|
6
|
-
background-image: linear-gradient(to top, white, white),
|
|
7
|
-
linear-gradient(to top, white, white),
|
|
8
|
-
linear-gradient(to top, rgba(100, 100, 100, 0.25), rgba(255, 255, 255, 0)),
|
|
9
|
-
linear-gradient(to bottom, rgba(100, 100, 100, 0.25), rgba(255, 255, 255, 0));
|
|
10
|
-
background-position: bottom center, top center, bottom center, top center;
|
|
11
|
-
background-color: white;
|
|
12
|
-
background-repeat: no-repeat;
|
|
13
|
-
background-size: 100% 12px, 100% 12px, 100% 10px, 100% 10px;
|
|
14
|
-
background-attachment: local, local, scroll, scroll;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
input[type=number]::-webkit-outer-spin-button,
|
|
18
|
-
input[type=number]::-webkit-inner-spin-button {
|
|
19
|
-
-webkit-appearance: none;
|
|
20
|
-
margin: 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
input[type=number] {
|
|
24
|
-
-moz-appearance: textfield;
|
|
25
|
-
}
|