@creativecodeco/ui 0.4.2 → 0.6.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/lib/hooks/use-safe-button-props.hook.d.ts +3 -3
- package/lib/theme/css/accordion.css +9 -0
- package/lib/theme/css/badge.css +45 -0
- package/lib/theme/css/button.css +4 -2
- package/lib/theme/css/main.css +2 -0
- package/lib/theme/main.css +1094 -286
- package/lib/types/ui/components/accordion.types.d.ts +12 -0
- package/lib/types/ui/components/accordion.types.js +1 -0
- package/lib/types/ui/components/badge.types.d.ts +12 -0
- package/lib/types/ui/components/badge.types.js +1 -0
- package/lib/types/ui/components/button.types.d.ts +4 -1
- package/lib/types/ui/components/index.d.ts +2 -0
- package/lib/ui/components/accordion/accordion.component.d.ts +3 -0
- package/lib/ui/components/accordion/accordion.component.js +12 -0
- package/lib/ui/components/accordion/index.d.ts +2 -0
- package/lib/ui/components/accordion/index.js +2 -0
- package/lib/ui/components/badge/badge.component.d.ts +3 -0
- package/lib/ui/components/badge/badge.component.js +19 -0
- package/lib/ui/components/badge/index.d.ts +2 -0
- package/lib/ui/components/badge/index.js +2 -0
- package/lib/ui/components/button/button.component.js +4 -3
- package/lib/ui/components/index.d.ts +2 -0
- package/lib/ui/components/index.js +2 -0
- package/package.json +25 -25
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface AccordionType {
|
|
3
|
+
name: string;
|
|
4
|
+
iconType?: 'arrow' | 'plus';
|
|
5
|
+
join?: boolean;
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
options: AccordionOption[];
|
|
8
|
+
}
|
|
9
|
+
export interface AccordionOption {
|
|
10
|
+
header: React.ReactElement;
|
|
11
|
+
body: React.ReactElement;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ColorType, SizeType } from '../../../types';
|
|
3
|
+
import type { IconType } from 'react-icons';
|
|
4
|
+
import type { PositionType } from '../../../types';
|
|
5
|
+
export interface BadgeType {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
color?: ColorType;
|
|
8
|
+
outline?: boolean;
|
|
9
|
+
size?: SizeType;
|
|
10
|
+
icon?: IconType;
|
|
11
|
+
iconPosition?: PositionType;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { ColorButtonType, SizeType } from '../../../types';
|
|
2
|
+
import type { BadgeType, ColorButtonType, SizeType } from '../../../types';
|
|
3
3
|
import type { IconType } from 'react-icons';
|
|
4
4
|
import type { PositionType } from '../../../types';
|
|
5
5
|
export interface ButtonType extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -11,5 +11,8 @@ export interface ButtonType extends React.ButtonHTMLAttributes<HTMLButtonElement
|
|
|
11
11
|
iconPosition?: PositionType;
|
|
12
12
|
loading?: boolean;
|
|
13
13
|
loadingLabel?: string;
|
|
14
|
+
withBadge?: boolean;
|
|
15
|
+
badge?: React.ReactNode;
|
|
16
|
+
badgeProps?: Omit<BadgeType, 'children' | 'size'>;
|
|
14
17
|
}
|
|
15
18
|
export type ButtonRef = HTMLButtonElement;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import cls from 'classnames';
|
|
3
|
+
const Accordion = ({ name, join, options, iconType = 'arrow', multiple }) => {
|
|
4
|
+
return (_jsx("div", { className: cls('flex flex-wrap', {
|
|
5
|
+
'join join-vertical w-full': join,
|
|
6
|
+
'gap-2': !join
|
|
7
|
+
}), children: options.map(({ header, body }, index) => (_jsxs("div", { className: cls('collapse bg-base-200', {
|
|
8
|
+
[`accordion-type-${iconType}`]: iconType,
|
|
9
|
+
'join-item border border-base-300': join
|
|
10
|
+
}), children: [_jsx("input", { type: multiple ? 'checkbox' : 'radio', name: name }), _jsx("div", { className: 'collapse-title text-xl font-medium', children: header }), _jsx("div", { className: 'collapse-content', children: body })] }, index))) }));
|
|
11
|
+
};
|
|
12
|
+
export default Accordion;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import cls from 'classnames';
|
|
4
|
+
const Badge = ({ children, color, icon: Icon, iconPosition = 'left', outline, size = 'md' }) => {
|
|
5
|
+
const newIcon = useMemo(() => {
|
|
6
|
+
if (!Icon) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
return _jsx(Icon, {});
|
|
10
|
+
}, [Icon]);
|
|
11
|
+
return (_jsxs("div", { className: cls('badge', {
|
|
12
|
+
[`badge-color-${color}`]: !outline && color,
|
|
13
|
+
[`badge-${color}`]: outline && color,
|
|
14
|
+
'badge-outline': outline,
|
|
15
|
+
[`badge-size-${size}`]: size !== 'md',
|
|
16
|
+
'gap-2': Icon
|
|
17
|
+
}), children: [iconPosition === 'left' && newIcon, children, iconPosition === 'right' && newIcon] }));
|
|
18
|
+
};
|
|
19
|
+
export default Badge;
|
|
@@ -16,10 +16,11 @@ const Button = forwardRef(({ children, isLink, color, outline, size = 'md', icon
|
|
|
16
16
|
}
|
|
17
17
|
return (_jsxs(_Fragment, { children: [iconPosition === 'left' && newIcon, children, iconPosition === 'right' && newIcon] }));
|
|
18
18
|
}, [loading, loadingLabel, iconPosition, children, newIcon]);
|
|
19
|
-
return (_jsx("button", { ref: ref, className: cls('
|
|
19
|
+
return (_jsx("button", { ref: ref, className: cls('btn', {
|
|
20
20
|
'button-link': isLink,
|
|
21
|
-
'
|
|
22
|
-
[`
|
|
21
|
+
'btn-outline': !isLink && outline,
|
|
22
|
+
[`btn-${color}`]: outline && color,
|
|
23
|
+
[`button-color-${color}`]: !outline && color,
|
|
23
24
|
[`button-size-${size}`]: size !== 'md',
|
|
24
25
|
'button-loading': loading
|
|
25
26
|
}), ...safeProps, children: content }));
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"framework design",
|
|
11
11
|
"design system"
|
|
12
12
|
],
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.6.0",
|
|
14
14
|
"homepage": "https://github.com/creativecodeco/ui",
|
|
15
15
|
"author": {
|
|
16
16
|
"name": "John Toro",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"main": "lib/index.js",
|
|
21
21
|
"source": "src/index.ts",
|
|
22
22
|
"scripts": {
|
|
23
|
-
"dev": "npm run storybook",
|
|
23
|
+
"dev": "npm run build; npm run storybook",
|
|
24
24
|
"dev:css": "postcss src/theme/main.css -o lib/theme/main.css --watch",
|
|
25
25
|
"build": "rm -rf lib; tsc -p tsconfig.build.json; npm run build:alias; npm run build:css",
|
|
26
26
|
"build:alias": "tsc-alias -p tsconfig.build.json",
|
|
@@ -48,42 +48,42 @@
|
|
|
48
48
|
"usehooks-ts": "2.9.1"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"postcss": "8.4.
|
|
52
|
-
"postcss-import": "16.0.
|
|
51
|
+
"postcss": "8.4.35",
|
|
52
|
+
"postcss-import": "16.0.1",
|
|
53
53
|
"react": "18.2.0",
|
|
54
54
|
"react-hook-form": "7.50.1",
|
|
55
55
|
"tailwindcss": "3.4.1",
|
|
56
|
-
"usehooks-ts": "2.
|
|
56
|
+
"usehooks-ts": "2.15.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@babel/core": "7.
|
|
60
|
-
"@babel/preset-env": "7.
|
|
59
|
+
"@babel/core": "7.24.0",
|
|
60
|
+
"@babel/preset-env": "7.24.0",
|
|
61
61
|
"@babel/preset-react": "7.23.3",
|
|
62
62
|
"@babel/preset-typescript": "7.23.3",
|
|
63
63
|
"@jest/globals": "29.7.0",
|
|
64
|
-
"@storybook/addon-essentials": "7.6.
|
|
65
|
-
"@storybook/addon-interactions": "7.6.
|
|
66
|
-
"@storybook/addon-links": "7.6.
|
|
67
|
-
"@storybook/addon-mdx-gfm": "7.6.
|
|
68
|
-
"@storybook/blocks": "7.6.
|
|
69
|
-
"@storybook/react": "7.6.
|
|
70
|
-
"@storybook/react-webpack5": "7.6.
|
|
71
|
-
"@storybook/test": "7.6.
|
|
64
|
+
"@storybook/addon-essentials": "7.6.17",
|
|
65
|
+
"@storybook/addon-interactions": "7.6.17",
|
|
66
|
+
"@storybook/addon-links": "7.6.17",
|
|
67
|
+
"@storybook/addon-mdx-gfm": "7.6.17",
|
|
68
|
+
"@storybook/blocks": "7.6.17",
|
|
69
|
+
"@storybook/react": "7.6.17",
|
|
70
|
+
"@storybook/react-webpack5": "7.6.17",
|
|
71
|
+
"@storybook/test": "7.6.17",
|
|
72
72
|
"@testing-library/dom": "9.3.4",
|
|
73
73
|
"@testing-library/jest-dom": "6.4.2",
|
|
74
74
|
"@testing-library/react": "14.2.1",
|
|
75
75
|
"@testing-library/user-event": "14.5.2",
|
|
76
76
|
"@types/jest": "29.5.12",
|
|
77
|
-
"@types/node": "20.11.
|
|
78
|
-
"@types/react": "18.2.
|
|
79
|
-
"@types/react-dom": "18.2.
|
|
77
|
+
"@types/node": "20.11.24",
|
|
78
|
+
"@types/react": "18.2.61",
|
|
79
|
+
"@types/react-dom": "18.2.19",
|
|
80
80
|
"@typescript-eslint/eslint-plugin": "6.21.0",
|
|
81
81
|
"autoprefixer": "10.4.17",
|
|
82
|
-
"chromatic": "
|
|
82
|
+
"chromatic": "11.0.0",
|
|
83
83
|
"classnames": "2.5.1",
|
|
84
84
|
"cpx2": "7.0.1",
|
|
85
|
-
"daisyui": "4.
|
|
86
|
-
"eslint": "8.
|
|
85
|
+
"daisyui": "4.7.2",
|
|
86
|
+
"eslint": "8.57.0",
|
|
87
87
|
"eslint-config-prettier": "9.1.0",
|
|
88
88
|
"eslint-config-standard": "17.1.0",
|
|
89
89
|
"eslint-config-standard-react": "13.0.0",
|
|
@@ -96,9 +96,9 @@
|
|
|
96
96
|
"eslint-plugin-promise": "6.1.1",
|
|
97
97
|
"eslint-plugin-react": "7.33.2",
|
|
98
98
|
"eslint-plugin-standard": "5.0.0",
|
|
99
|
-
"eslint-plugin-storybook": "0.
|
|
100
|
-
"eslint-plugin-unused-imports": "3.
|
|
101
|
-
"husky": "9.0.
|
|
99
|
+
"eslint-plugin-storybook": "0.8.0",
|
|
100
|
+
"eslint-plugin-unused-imports": "3.1.0",
|
|
101
|
+
"husky": "9.0.11",
|
|
102
102
|
"jest": "29.7.0",
|
|
103
103
|
"jest-environment-jsdom": "29.7.0",
|
|
104
104
|
"jest-junit": "16.0.0",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"prop-types": "15.8.1",
|
|
109
109
|
"react-dom": "18.2.0",
|
|
110
110
|
"react-icons": "5.0.1",
|
|
111
|
-
"storybook": "7.6.
|
|
111
|
+
"storybook": "7.6.17",
|
|
112
112
|
"storybook-addon-themes": "6.1.0",
|
|
113
113
|
"string-width": "7.1.0",
|
|
114
114
|
"ts-jest": "29.1.2",
|