Skip to content

Commit d3b8fae

Browse files
committed
components: Button props
1 parent c0d72eb commit d3b8fae

File tree

16 files changed

+541
-347
lines changed

16 files changed

+541
-347
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
.button {
2+
@apply outline-none text-white font-semibold leading-relaxed button-shadow;
3+
4+
&:hover {
5+
@apply button-shadow-hover;
6+
}
7+
8+
&:focus {
9+
@apply outline-none widget-shadow-lightblue;
10+
}
11+
12+
&:disabled {
13+
@apply cursor-default bg-acc-light-text text-white;
14+
15+
&:hover {
16+
@apply button-shadow bg-acc-light-text;
17+
}
18+
}
19+
}
20+
21+
/* COLOR VARIANTS */
22+
23+
.color-default {
24+
@apply bg-button-1 hover:bg-button-2;
25+
}
26+
27+
.color-dark {
28+
@apply bg-primary hover:bg-acc-hoverblue;
29+
}
30+
31+
.color-red {
32+
@apply bg-acc-red hover:bg-acc-hoverred;
33+
}
34+
35+
.color-green {
36+
@apply bg-acc-green hover:bg-acc-hovergreen;
37+
}
38+
39+
.color-white {
40+
@apply bg-white text-link-1 shadow-none;
41+
42+
&:hover {
43+
@apply bg-white/70;
44+
}
45+
}
46+
47+
.color-gradient {
48+
background: linear-gradient(92.21deg, #6db0fc 11.79%, #5deda2 113.81%);
49+
50+
&:disabled {
51+
background: linear-gradient(92.21deg, #6db0fc 11.79%, #5deda2 113.81%);
52+
}
53+
}
54+
55+
/* SHAPE VARIANTS */
56+
57+
.shape-default {
58+
@apply rounded;
59+
}
60+
61+
.shape-pill {
62+
@apply rounded-full;
63+
}
64+
65+
/* SIZE VARIANTS */
66+
67+
.size-small {
68+
@apply px-3 py-0.5 text-sm;
69+
}
70+
71+
.size-medium {
72+
@apply px-6 py-1.5 text-base;
73+
}
74+
75+
.size-large {
76+
@apply px-8 py-2 text-base;
77+
}
78+
79+
/* ICON */
80+
81+
.withIcon {
82+
@apply flex items-center justify-center;
83+
84+
svg {
85+
@apply mr-2;
86+
}
87+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import cx from "classnames";
2+
import React from "react";
3+
import { Props } from "../types";
4+
import css from "./index.module.css";
5+
6+
function Button({
7+
children,
8+
className,
9+
icon,
10+
color = "default",
11+
size = "medium",
12+
shape = "default",
13+
...props
14+
}: Props) {
15+
return (
16+
<button
17+
className={cx(
18+
css.button,
19+
css[`color-${color}`],
20+
css[`shape-${shape}`],
21+
css[`size-${size}`],
22+
{ [css.withIcon]: !!icon },
23+
className,
24+
)}
25+
type="button"
26+
data-testid="default-button"
27+
// These props need to come last
28+
{...props}
29+
>
30+
{icon}
31+
{children}
32+
</button>
33+
);
34+
}
35+
36+
export default Button;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.group {
2+
button:not(:last-of-type) {
3+
@apply mr-3;
4+
}
5+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import cx from "classnames";
2+
import React from "react";
3+
import css from "./index.module.css";
4+
5+
type GroupProps = {
6+
children: React.ReactNode;
7+
className?: string;
8+
};
9+
10+
function Group({ children, className }: GroupProps) {
11+
return (
12+
<div className={cx(css.group, className)} aria-label="button-group">
13+
{children}
14+
</div>
15+
);
16+
}
17+
18+
export default Group;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.buttonLink {
2+
@apply font-semibold text-sm leading-relaxed bg-transparent;
3+
4+
&:focus {
5+
@apply outline-none widget-shadow-lightblue;
6+
}
7+
8+
&:disabled {
9+
@apply text-ld-darkgrey;
10+
11+
&:hover {
12+
@apply text-ld-darkgrey;
13+
}
14+
}
15+
}
16+
17+
.underlined {
18+
@apply underline px-2;
19+
}
20+
21+
/* COLOR VARIANTS */
22+
23+
.color-default {
24+
@apply text-link-1 hover:text-link-2;
25+
}
26+
27+
.color-dark {
28+
@apply text-primary hover:text-acc-hoverblue;
29+
}
30+
31+
.color-red {
32+
@apply text-acc-red hover:text-acc-hoverred;
33+
}
34+
35+
.color-green {
36+
@apply text-acc-green hover:text-acc-hovergreen;
37+
}
38+
39+
/* SIZE VARIANTS */
40+
41+
.size-small {
42+
@apply text-sm;
43+
}
44+
45+
.size-medium {
46+
@apply text-base;
47+
}
48+
49+
.size-large {
50+
@apply text-lg;
51+
}
52+
53+
/* ICON */
54+
55+
.withIcon {
56+
@apply flex items-center justify-center;
57+
58+
svg {
59+
@apply mr-2;
60+
}
61+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import cx from "classnames";
2+
import React from "react";
3+
import { Props } from "../types";
4+
import css from "./index.module.css";
5+
6+
type LinkProps = Props & {
7+
underlined?: boolean;
8+
};
9+
10+
function Link({
11+
children,
12+
className,
13+
icon,
14+
color = "default",
15+
size = "medium",
16+
underlined = false,
17+
...props
18+
}: LinkProps) {
19+
return (
20+
<button
21+
className={cx(
22+
css.buttonLink,
23+
css[`color-${color}`],
24+
css[`size-${size}`],
25+
{
26+
[css.withIcon]: !!icon,
27+
[css.underlined]: underlined,
28+
},
29+
className,
30+
)}
31+
type="button"
32+
// These props need to come last
33+
{...props}
34+
>
35+
{icon}
36+
{children}
37+
</button>
38+
);
39+
}
40+
41+
export default Link;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
.buttonOutlined {
2+
@apply outline-none font-semibold leading-relaxed border button-shadow bg-transparent;
3+
4+
&:focus {
5+
@apply outline-none widget-shadow-lightblue;
6+
}
7+
8+
&:disabled {
9+
@apply cursor-default border-acc-light-text text-acc-light-text;
10+
11+
&:hover {
12+
@apply border-acc-light-text text-acc-light-text;
13+
}
14+
}
15+
}
16+
17+
/* COLOR VARIANTS */
18+
19+
.color-default {
20+
@apply border-button-1 text-button-1;
21+
22+
&:hover {
23+
@apply border-button-2 text-button-2;
24+
}
25+
}
26+
27+
.color-dark {
28+
@apply border-primary text-primary;
29+
30+
&:hover {
31+
@apply border-acc-hoverblue text-acc-hoverblue;
32+
}
33+
}
34+
35+
.color-red {
36+
@apply border-acc-red text-acc-red;
37+
38+
&:hover {
39+
@apply border-acc-hoverred text-acc-hoverred;
40+
}
41+
}
42+
43+
.color-green {
44+
@apply border-acc-green text-acc-green;
45+
46+
&:hover {
47+
@apply border-acc-hovergreen text-acc-hovergreen;
48+
}
49+
}
50+
51+
/* SHAPE VARIANTS */
52+
53+
.shape-default {
54+
@apply rounded;
55+
}
56+
57+
.shape-pill {
58+
@apply rounded-full;
59+
}
60+
61+
/* SIZE VARIANTS */
62+
63+
.size-small {
64+
@apply px-3 py-0.5 text-sm;
65+
}
66+
67+
.size-medium {
68+
@apply px-6 py-1.5 text-base;
69+
}
70+
71+
.size-large {
72+
@apply px-8 py-2 text-base;
73+
}
74+
75+
/* ICON */
76+
77+
.withIcon {
78+
@apply flex items-center justify-center;
79+
80+
svg {
81+
@apply mr-2;
82+
}
83+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import cx from "classnames";
2+
import React from "react";
3+
import { Props } from "../types";
4+
import css from "./index.module.css";
5+
6+
function Outlined({
7+
children,
8+
className,
9+
icon,
10+
color = "default",
11+
size = "medium",
12+
shape = "default",
13+
...props
14+
}: Props) {
15+
return (
16+
<button
17+
className={cx(
18+
css.buttonOutlined,
19+
css[`color-${color}`],
20+
css[`shape-${shape}`],
21+
css[`size-${size}`],
22+
{ [css.withIcon]: !!icon },
23+
className,
24+
)}
25+
type="button"
26+
// These props need to come last
27+
{...props}
28+
>
29+
{icon}
30+
{children}
31+
</button>
32+
);
33+
}
34+
35+
export default Outlined;

0 commit comments

Comments
 (0)