@mbao01/ui 0.0.2 → 0.0.6

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 CHANGED
@@ -1,5 +1,3 @@
1
- [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
2
-
3
1
  So here it is, I have gotten really bored creating UI component from scratch for the many projects I work on.
4
2
  It is high time I have a unified component library - so here it is.
5
3
  I have built this to be highly opinionated on certain libraries I love to use like typescript, tailwind, date-fns, and react.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/ui",
3
3
  "private": false,
4
- "version": "0.0.2",
4
+ "version": "0.0.6",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -13,12 +13,12 @@
13
13
  "library"
14
14
  ],
15
15
  "main": "./src/index.ts",
16
- "types": "./dist/index.d.ts",
16
+ "types": "dist/types/index.d.ts",
17
17
  "files": [
18
+ "src",
18
19
  "plugin.js",
19
20
  "plugin.d.ts",
20
- "src/**/*.ts",
21
- "dist/**/*.d.ts"
21
+ "dist/types"
22
22
  ],
23
23
  "sideEffects": false,
24
24
  "scripts": {
@@ -82,5 +82,5 @@
82
82
  "tailwindcss": "^3.4.0",
83
83
  "typescript": "^5.2.2"
84
84
  },
85
- "gitHead": "befbd919a67ae1084ad5ef64cf4cc1ced6f848e2"
85
+ "gitHead": "064ceb1c2cc52de66fde849a6289c3fc98cf33bf"
86
86
  }
@@ -0,0 +1,40 @@
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
32
+ className="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-[inherit]"
33
+ data-testid="loading"
34
+ >
35
+ <span className="loading loading-spinner" />
36
+ </span>
37
+ ) : null}
38
+ </button>
39
+ );
40
+ };
@@ -0,0 +1,12 @@
1
+ import c from 'clsx';
2
+ import { createElement } from 'react';
3
+ import { type TextProps } from './types';
4
+ import { getTextClasses } from './constants';
5
+
6
+ export const Text = ({ as = 'span', size, variant, children, className }: TextProps) => {
7
+ return createElement(
8
+ as,
9
+ { className: c(getTextClasses({ size, variant }), className) },
10
+ children
11
+ );
12
+ };
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./components/Button";
2
+ export * from "./components/Text";
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './src/index'
@@ -1,2 +0,0 @@
1
- import { type ButtonProps } from "./types";
2
- export declare const Button: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,19 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export { Button } from "./Button";
@@ -1,12 +0,0 @@
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>;
@@ -1,4 +0,0 @@
1
- import { type TextProps } from './types';
2
- export declare const Text: ({ as, size, variant, children, className }: TextProps) => import("react").DetailedReactHTMLElement<{
3
- className: string;
4
- }, HTMLElement>;
@@ -1,17 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import type { TextSize, TextVariant } from './types';
2
- export declare const getTextClasses: ({ size, variant }: {
3
- size?: TextSize | undefined;
4
- variant?: TextVariant | undefined;
5
- }) => string;
@@ -1 +0,0 @@
1
- export { Text } from './Text';
@@ -1,10 +0,0 @@
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
- };
@@ -1 +0,0 @@
1
- export * from "./components/Button";
@@ -1,3 +0,0 @@
1
- import type { Config } from "tailwindcss";
2
- declare const config: Config;
3
- export default config;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;
File without changes
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;
@@ -1,77 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
-
3
- import { Button } from './Button';
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: Button,
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 Button>;
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
- variant: 'default',
25
- label: 'Button',
26
- },
27
- };
28
-
29
- export const PrimaryButton: Story = {
30
- args: {
31
- variant: 'primary',
32
- label: 'Button',
33
- },
34
- };
35
-
36
- export const WideButton: Story = {
37
- args: {
38
- wide: true,
39
- label: 'Wide Button',
40
- },
41
- };
42
-
43
- export const TinyButton: Story = {
44
- args: {
45
- size: 'xs',
46
- label: 'Tiny',
47
- },
48
- };
49
-
50
- export const OutlineButton: Story = {
51
- args: {
52
- outline: true,
53
- label: 'Click me!',
54
- },
55
- };
56
-
57
- export const DisabledButton: Story = {
58
- args: {
59
- disabled: true,
60
- label: 'Click me?',
61
- },
62
- };
63
-
64
- export const LoadingButton: Story = {
65
- args: {
66
- loading: true,
67
- label: 'Loading',
68
- },
69
- };
70
-
71
- export const BlockButton: Story = {
72
- args: {
73
- disabled: true,
74
- className: 'btn-block',
75
- label: 'Block Button',
76
- },
77
- };
@@ -1,47 +0,0 @@
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
- };
package/src/vite-env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />