Skip to content

Commit aacea36

Browse files
authored
Badge (#22)
1 parent f498802 commit aacea36

19 files changed

Lines changed: 577 additions & 26 deletions

Changelog.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
<!-- markdownlint-configure-file { "MD024": false } -->
22
# Changelog
33

4+
## v0.6.0 - Badge
5+
6+
### 👾 Feature
7+
8+
- Badge
9+
10+
### 📶 Changes
11+
12+
- Update changelog
13+
- Button Outline Color
14+
- Button Badge
15+
16+
## v0.5.0 - Accordion
17+
18+
### 👾 Feature
19+
20+
- Accordion
21+
422
## v0.4.2 - Text Box (Jan 22 - 2024)
523

624
### 📶 Changes

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"framework design",
1111
"design system"
1212
],
13-
"version": "0.5.0",
13+
"version": "0.6.0",
1414
"homepage": "https://github.com/creativecodeco/ui",
1515
"author": {
1616
"name": "John Toro",
@@ -74,8 +74,8 @@
7474
"@testing-library/react": "14.2.1",
7575
"@testing-library/user-event": "14.5.2",
7676
"@types/jest": "29.5.12",
77-
"@types/node": "20.11.21",
78-
"@types/react": "18.2.60",
77+
"@types/node": "20.11.24",
78+
"@types/react": "18.2.61",
7979
"@types/react-dom": "18.2.19",
8080
"@typescript-eslint/eslint-plugin": "6.21.0",
8181
"autoprefixer": "10.4.17",

src/theme/badge.css

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.badge {
2+
&-size {
3+
&-lg {
4+
@apply badge-lg;
5+
}
6+
7+
&-sm {
8+
@apply badge-sm;
9+
}
10+
11+
&-xs {
12+
@apply badge-xs;
13+
}
14+
}
15+
16+
&-color {
17+
&-primary {
18+
@apply badge-primary;
19+
}
20+
21+
&-secondary {
22+
@apply badge-secondary;
23+
}
24+
25+
&-accent {
26+
@apply badge-accent;
27+
}
28+
29+
&-success {
30+
@apply badge-success;
31+
}
32+
33+
&-warning {
34+
@apply badge-warning;
35+
}
36+
37+
&-info {
38+
@apply badge-info;
39+
}
40+
41+
&-error {
42+
@apply badge-error;
43+
}
44+
}
45+
}

src/theme/button.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.button {
2-
@apply btn;
3-
42
&-link {
53
@apply btn-link;
64
}
@@ -41,6 +39,10 @@
4139
&-error {
4240
@apply btn-error;
4341
}
42+
43+
&-ghost {
44+
@apply btn-ghost;
45+
}
4446
}
4547

4648
&-size {

src/theme/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
@import './accordion.css';
66
@import './avatar.css';
7+
@import './badge.css';
78
@import './button.css';
89
@import './checkbox.css';
910
@import './radio.css';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { ColorType, SizeType } from '@/types';
2+
import type { IconType } from 'react-icons';
3+
import type { PositionType } from '@/types';
4+
5+
export interface BadgeType {
6+
children: React.ReactNode;
7+
8+
color?: ColorType;
9+
outline?: boolean;
10+
size?: SizeType;
11+
icon?: IconType;
12+
iconPosition?: PositionType;
13+
}

src/types/ui/components/button.types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ColorButtonType, SizeType } from '@/types';
1+
import type { BadgeType, ColorButtonType, SizeType } from '@/types';
22
import type { IconType } from 'react-icons';
33
import type { PositionType } from '@/types';
44

@@ -13,6 +13,10 @@ export interface ButtonType
1313
iconPosition?: PositionType;
1414
loading?: boolean;
1515
loadingLabel?: string;
16+
17+
withBadge?: boolean;
18+
badge?: React.ReactNode;
19+
badgeProps?: Omit<BadgeType, 'children' | 'size'>;
1620
}
1721

1822
export type ButtonRef = HTMLButtonElement;

src/types/ui/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export type * from './accordion.types';
22
export type * from './avatar.types';
3+
export type * from './badge.types';
34
export type * from './button.types';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<Badge /> snapshot 1`] = `
4+
<div>
5+
<div
6+
class="badge"
7+
>
8+
Badge
9+
</div>
10+
</div>
11+
`;
12+
13+
exports[`<Badge /> snapshot all props 1`] = `
14+
<div>
15+
<div
16+
class="badge badge-primary badge-outline badge-size-lg gap-2"
17+
>
18+
Badge
19+
<svg
20+
fill="currentColor"
21+
height="1em"
22+
stroke="currentColor"
23+
stroke-width="0"
24+
viewBox="0 0 512 512"
25+
width="1em"
26+
xmlns="http://www.w3.org/2000/svg"
27+
>
28+
<path
29+
d="M157.52 272h36.96L176 218.78 157.52 272zM352 256c-13.23 0-24 10.77-24 24s10.77 24 24 24 24-10.77 24-24-10.77-24-24-24zM464 64H48C21.5 64 0 85.5 0 112v288c0 26.5 21.5 48 48 48h416c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM250.58 352h-16.94c-6.81 0-12.88-4.32-15.12-10.75L211.15 320h-70.29l-7.38 21.25A16 16 0 0 1 118.36 352h-16.94c-11.01 0-18.73-10.85-15.12-21.25L140 176.12A23.995 23.995 0 0 1 162.67 160h26.66A23.99 23.99 0 0 1 212 176.13l53.69 154.62c3.61 10.4-4.11 21.25-15.11 21.25zM424 336c0 8.84-7.16 16-16 16h-16c-4.85 0-9.04-2.27-11.98-5.68-8.62 3.66-18.09 5.68-28.02 5.68-39.7 0-72-32.3-72-72s32.3-72 72-72c8.46 0 16.46 1.73 24 4.42V176c0-8.84 7.16-16 16-16h16c8.84 0 16 7.16 16 16v160z"
30+
/>
31+
</svg>
32+
</div>
33+
</div>
34+
`;

0 commit comments

Comments
 (0)