Skip to content

Commit 4d99501

Browse files
committed
feat: improve button implementation GH-24
colors, inverse colors, and loading state
1 parent f8800ee commit 4d99501

7 files changed

Lines changed: 83 additions & 9 deletions

File tree

packages/panda-san/src/core/button.scss

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@import 'button';
21
@import 'colors';
32
@import 'reset';
43
@import 'utils';
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.button {
2+
@extend %base-font;
3+
align-items: center;
4+
background-color: map-get($button-default-type, background-color);
5+
border: solid px-to-rem(2px) map-get($button-default-type, background-color);
6+
border-radius: px-to-rem(5px);
7+
color: map-get($button-default-type, color);
8+
display: flex;
9+
justify-content: center;
10+
padding: px-to-rem(12px) px-to-rem(60px);
11+
12+
&--is-loading {
13+
color: transparent !important;
14+
pointer-events: none;
15+
16+
&::after {
17+
animation: button-spin 1.2s linear infinite;
18+
border: 0.2em solid map-get($button-default-type, color);
19+
border-radius: 50%;
20+
border-right-color: transparent;
21+
content: '';
22+
display: block;
23+
height: 1.2em;
24+
position: absolute;
25+
width: 1.2em;
26+
}
27+
}
28+
29+
&--is-inverse {
30+
background-color: transparent;
31+
color: map-get($button-default-type, background-color);
32+
33+
&.button--is-loading::after {
34+
border-color: map-get($button-default-type, background-color);
35+
border-right-color: transparent;
36+
}
37+
}
38+
39+
@each $type, $config in $button-types {
40+
&--is-#{$type} {
41+
background-color: map-get($config, background-color);
42+
border-color: map-get($config, background-color);
43+
color: map-get($config, color);
44+
45+
&.button--is-loading::after {
46+
border-color: map-get($config, color);
47+
border-right-color: transparent;
48+
}
49+
50+
&.button--is-inverse {
51+
background-color: transparent;
52+
color: map-get($config, background-color);
53+
54+
&.button--is-loading::after {
55+
border-color: map-get($config, background-color);
56+
border-right-color: transparent;
57+
}
58+
}
59+
}
60+
}
61+
62+
@keyframes button-spin {
63+
0% { transform: rotate(0deg); }
64+
100% { transform: rotate(360deg); }
65+
}
66+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import 'button';

packages/panda-san/src/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import 'variables/index';
22
@import 'mixins/index';
33
@import 'content/index';
4+
@import 'elements/index';
45
@import 'core/index';
56
@import 'form/index';
67
@import 'layout/index';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$button-types: (
2+
primary: (background-color: $yellow, color: $white),
3+
yellow: (background-color: $yellow, color: $white),
4+
red: (background-color: $red, color: $white),
5+
blue: (background-color: $blue, color: $white),
6+
green: (background-color: $green, color: $white),
7+
grey: (background-color: $grey, color: $black),
8+
white: (background-color: $white, color: $black),
9+
black: (background-color: $black, color: $white)
10+
);
11+
12+
$button-default-type: (
13+
background-color: $grey, color: $black
14+
);

packages/panda-san/src/variables/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import 'breakpoints';
22
@import 'colors';
3+
@import 'button';
34
@import 'container';
45
@import 'font';
56
@import 'form';

0 commit comments

Comments
 (0)