@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.
@@ -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;
@@ -1,2 +1,4 @@
1
+ export type * from './accordion.types';
1
2
  export type * from './avatar.types';
3
+ export type * from './badge.types';
2
4
  export type * from './button.types';
@@ -0,0 +1,3 @@
1
+ import type { AccordionType } from '../../../types';
2
+ declare const Accordion: ({ name, join, options, iconType, multiple }: AccordionType) => import("react/jsx-runtime").JSX.Element;
3
+ export default Accordion;
@@ -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,2 @@
1
+ import Accordion from './accordion.component';
2
+ export { Accordion };
@@ -0,0 +1,2 @@
1
+ import Accordion from './accordion.component';
2
+ export { Accordion };
@@ -0,0 +1,3 @@
1
+ import type { BadgeType } from '../../../types';
2
+ declare const Badge: ({ children, color, icon: Icon, iconPosition, outline, size }: BadgeType) => import("react/jsx-runtime").JSX.Element;
3
+ export default Badge;
@@ -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;
@@ -0,0 +1,2 @@
1
+ import Badge from './badge.component';
2
+ export { Badge };
@@ -0,0 +1,2 @@
1
+ import Badge from './badge.component';
2
+ export { 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('button', {
19
+ return (_jsx("button", { ref: ref, className: cls('btn', {
20
20
  'button-link': isLink,
21
- 'button-outline': !isLink && outline,
22
- [`button-color-${color}`]: !isLink && color,
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 }));
@@ -1,2 +1,4 @@
1
+ export * from './accordion';
1
2
  export * from './avatar';
3
+ export * from './badge';
2
4
  export * from './button';
@@ -1,2 +1,4 @@
1
+ export * from './accordion';
1
2
  export * from './avatar';
3
+ export * from './badge';
2
4
  export * from './button';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "framework design",
11
11
  "design system"
12
12
  ],
13
- "version": "0.4.2",
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.34",
52
- "postcss-import": "16.0.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.13.0"
56
+ "usehooks-ts": "2.15.1"
57
57
  },
58
58
  "devDependencies": {
59
- "@babel/core": "7.23.9",
60
- "@babel/preset-env": "7.23.9",
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.12",
65
- "@storybook/addon-interactions": "7.6.12",
66
- "@storybook/addon-links": "7.6.12",
67
- "@storybook/addon-mdx-gfm": "7.6.12",
68
- "@storybook/blocks": "7.6.12",
69
- "@storybook/react": "7.6.12",
70
- "@storybook/react-webpack5": "7.6.12",
71
- "@storybook/test": "7.6.12",
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.16",
78
- "@types/react": "18.2.55",
79
- "@types/react-dom": "18.2.18",
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": "10.7.1",
82
+ "chromatic": "11.0.0",
83
83
  "classnames": "2.5.1",
84
84
  "cpx2": "7.0.1",
85
- "daisyui": "4.6.1",
86
- "eslint": "8.56.0",
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.6.15",
100
- "eslint-plugin-unused-imports": "3.0.0",
101
- "husky": "9.0.10",
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.12",
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",