Skip to content

Commit

Permalink
Loading button (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaltoroc authored Jan 23, 2024
1 parent 23a4761 commit 37daabb
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import React from 'react';
import type { Preview } from '@storybook/react';
import { themes } from '@storybook/theming';

import '../lib/theme/main.css';
import { CreativeCodeUIProvider } from '../lib';

import '../lib/theme/main.css';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
Expand Down
10 changes: 8 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<!-- markdownlint-configure-file { "MD024": { "allow_different_nesting": true } } -->
# Changelog

## v0.4.0 - Radio (Jan 22 - 2024)
## v0.4.1 - Button (Jan 22 - 2024)

### 📶 Changes

- Button loading

## v0.4.0 - Button (Jan 22 - 2024)

### 👾 Feature

- Button

### 🐛 Changes
### 📶 Changes

- Storybook table info
- Fix chromatic show controls
Expand Down
132 changes: 68 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"framework design",
"design system"
],
"version": "0.4.0",
"version": "0.4.1",
"homepage": "https://github.com/creativecodeco/ui",
"author": {
"name": "John Toro",
Expand Down Expand Up @@ -70,14 +70,14 @@
"@storybook/react-webpack5": "7.6.10",
"@storybook/test": "7.6.10",
"@testing-library/dom": "9.3.4",
"@testing-library/jest-dom": "6.2.0",
"@testing-library/jest-dom": "6.2.1",
"@testing-library/react": "14.1.2",
"@testing-library/user-event": "14.5.2",
"@types/jest": "29.5.11",
"@types/node": "20.11.5",
"@types/react": "18.2.48",
"@types/react-dom": "18.2.18",
"@typescript-eslint/eslint-plugin": "6.19.0",
"@typescript-eslint/eslint-plugin": "6.19.1",
"autoprefixer": "10.4.17",
"chromatic": "10.3.1",
"classnames": "2.5.1",
Expand Down
4 changes: 2 additions & 2 deletions src/docs/versions.docs.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Markdown, Meta } from '@storybook/blocks';

import Readme from '../../Changelog.md?raw';
import Changelog from '../../Changelog.md?raw';

<Meta title='@creativecodeco-ui' name='Versions' />

<Markdown>{Readme}</Markdown>
<Markdown>{Changelog}</Markdown>
7 changes: 5 additions & 2 deletions src/hooks/use-safe-button-props.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import type { ButtonEvent, ButtonEventHandler } from '@/types';
export default function useSafeButtonProps({
onClick,
onSubmit,
loading,
...props
}: React.ComponentPropsWithoutRef<'button'>) {
}: React.ComponentPropsWithoutRef<'button'> & {
loading?: boolean;
}) {
const wrapper = useCallback(
(callback: ButtonEventHandler, event: ButtonEvent) => {
!props.disabled && callback(event);
!props.disabled && !loading && callback(event);
},
[props.disabled]
);
Expand Down
4 changes: 4 additions & 0 deletions src/theme/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
}
}

&-loading {
@apply pointer-events-none cursor-default;
}

&:focus,
&:hover,
&:active {
Expand Down
1 change: 1 addition & 0 deletions src/theme/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
@import './button.css';
@import './checkbox.css';
@import './radio.css';
@import './span.css';
@import './text-box.css';
5 changes: 5 additions & 0 deletions src/theme/span.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.span {
&-loading {
@apply loading loading-spinner;
}
}
2 changes: 2 additions & 0 deletions src/types/ui/components/button.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface ButtonType
size?: SizeType;
icon?: IconType;
iconPosition?: PositionType;
loading?: boolean;
loadingLabel?: string;
}

export type ButtonRef = HTMLButtonElement;
Loading

0 comments on commit 37daabb

Please sign in to comment.