Skip to content

Commit 4638ed1

Browse files
committed
✨ Add small badge type
1 parent 495ce1e commit 4638ed1

File tree

6 files changed

+44
-14
lines changed

6 files changed

+44
-14
lines changed

src/components/Badge/Badge.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface Props extends BadgeProps {}
88
const {
99
theme,
1010
hover,
11+
small,
1112
className,
1213
...rest
1314
} = Astro.props
@@ -16,6 +17,7 @@ const classes = [
1617
styles.badge,
1718
theme && styles[theme],
1819
hover && styles.hover,
20+
small && styles.small,
1921
className
2022
]
2123
---

src/components/Badge/Badge.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
export let theme: SvelteBadgeProps['theme'] = null
99
export let onClick: SvelteBadgeProps['onClick'] = null
1010
export let hover: SvelteBadgeProps['hover'] = false
11+
export let small: SvelteBadgeProps['small'] = false
1112
export let className: SvelteBadgeProps['className'] = ''
1213
1314
const classes = classNames([
1415
styles.badge,
1516
theme && styles[theme],
1617
(onClick || hover) && styles.hover,
18+
small && styles.small,
1719
className
1820
])
1921
</script>

src/components/Badge/Badge.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const Badge = ({
99
theme,
1010
onClick,
1111
hover,
12+
small,
1213
className,
1314
children,
1415
...rest
@@ -17,6 +18,7 @@ const Badge = ({
1718
styles.badge,
1819
theme && styles[theme],
1920
(onClick || hover) && styles.hover,
21+
small && styles.small,
2022
className
2123
])
2224

src/components/Badge/badge.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,8 @@
8383
@include typography(alert-fg);
8484
@include background(alert);
8585
}
86+
87+
&.small {
88+
@include spacing(py-xxs, px-xs);
89+
}
8690
}

src/components/Badge/badge.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ export type BadgeProps = {
88
| 'alert'
99
| null
1010
hover?: boolean
11+
small?: boolean
1112
className?: string
1213
[key: string]: any
1314
}
1415

1516
export type SvelteBadgeProps = {
16-
onClick?: (() => any) | null
17+
onClick?: ((event: MouseEvent) => void) | null
1718
} & BadgeProps
1819

1920
export type ReactBadgeProps = {
20-
onClick?: (() => any) | null
21+
onClick?: (event: React.MouseEvent) => void
2122
children: React.ReactNode
2223
} & BadgeProps

src/pages/badge.astro

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import { getSections } from '@helpers'
1212
const sections = getSections({
1313
title: 'badges',
1414
components: [AstroBadge, SvelteBadge, ReactBadge],
15-
props: {
16-
onClick: () => {}
17-
}
15+
showSubTitle: true
1816
})
1917
---
2018

@@ -40,58 +38,79 @@ const sections = getSections({
4038

4139
{sections.map((section: any) => (
4240
<h1>{section.title}</h1>
41+
<Fragment>
42+
{section.subTitle && <h2 set:html={section.subTitle} />}
43+
</Fragment>
4344
<div class="grid md-2 lg-3">
4445
<ComponentWrapper title="Primary">
45-
<section.component onClick={section.onClick}>
46+
<section.component hover={true}>
4647
Primary
4748
</section.component>
4849
</ComponentWrapper>
4950

5051
<ComponentWrapper title="Secondary">
51-
<section.component theme="secondary" onClick={section.onClick}>
52+
<section.component theme="secondary" hover={true}>
5253
Secondary
5354
</section.component>
5455
</ComponentWrapper>
5556

5657
<ComponentWrapper title="Outline">
57-
<section.component theme="outline" onClick={section.onClick}>
58+
<section.component theme="outline" hover={true}>
5859
Outline
5960
</section.component>
6061
</ComponentWrapper>
6162

6263
<ComponentWrapper title="Flat">
63-
<section.component theme="flat" onClick={section.onClick}>
64+
<section.component theme="flat" hover={true}>
6465
Flat
6566
</section.component>
6667
</ComponentWrapper>
6768

6869
<ComponentWrapper title="With Icon">
69-
<section.component theme="secondary" onClick={section.onClick}>
70+
<section.component theme="secondary" hover={true}>
7071
<Icon type="github" size={14} />
7172
With Icon
7273
</section.component>
7374
</ComponentWrapper>
7475

7576
<ComponentWrapper title="Info">
76-
<section.component theme="info" onClick={section.onClick}>
77+
<section.component theme="info" hover={true}>
7778
Info
7879
</section.component>
7980
</ComponentWrapper>
8081

8182
<ComponentWrapper title="Success">
82-
<section.component theme="success" onClick={section.onClick}>
83+
<section.component theme="success" hover={true}>
8384
Success
8485
</section.component>
8586
</ComponentWrapper>
8687

8788
<ComponentWrapper title="Warning">
88-
<section.component theme="warning" onClick={section.onClick}>
89+
<section.component theme="warning" hover={true}>
8990
Warning
9091
</section.component>
9192
</ComponentWrapper>
9293

9394
<ComponentWrapper title="Alert">
94-
<section.component theme="alert" onClick={section.onClick}>
95+
<section.component theme="alert" hover={true}>
96+
Alert
97+
</section.component>
98+
</ComponentWrapper>
99+
100+
<ComponentWrapper title="Small success">
101+
<section.component theme="success" small={true}>
102+
Success
103+
</section.component>
104+
</ComponentWrapper>
105+
106+
<ComponentWrapper title="Small warning">
107+
<section.component theme="warning" small={true}>
108+
Warning
109+
</section.component>
110+
</ComponentWrapper>
111+
112+
<ComponentWrapper title="Small alert">
113+
<section.component theme="alert" small={true}>
95114
Alert
96115
</section.component>
97116
</ComponentWrapper>

0 commit comments

Comments
 (0)