1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | @import '../../globals/scss/typography';
|
9 |
|
10 | @mixin button-base {
|
11 | @include reset;
|
12 | @include font-family;
|
13 | @include font-smoothing;
|
14 | @include letter-spacing;
|
15 | cursor: pointer;
|
16 | display: inline-flex;
|
17 | align-items: center;
|
18 | justify-content: center;
|
19 | flex-shrink: 0;
|
20 | font-size: $button-font-size;
|
21 | font-weight: $button-font-weight;
|
22 | min-height: rem($button-height);
|
23 | padding: $button-padding;
|
24 | border-radius: $button-border-radius;
|
25 | text-align: center;
|
26 | text-decoration: none;
|
27 | transition-duration: $transition--base;
|
28 | transition-timing-function: ease-in;
|
29 | white-space: nowrap;
|
30 | line-height: 16px;
|
31 |
|
32 | &:disabled {
|
33 | cursor: not-allowed;
|
34 | opacity: 0.5;
|
35 | }
|
36 |
|
37 | .#{$prefix}--btn__icon {
|
38 | width: rem(16px);
|
39 | height: rem(16px);
|
40 | margin-left: 0.5rem;
|
41 | transition-duration: $transition--base;
|
42 | transition-timing-function: ease-in;
|
43 | }
|
44 | }
|
45 |
|
46 | @mixin button-theme($bg-color, $border-color, $font-color, $hover-bg-color, $icon-color) {
|
47 | background-color: $bg-color;
|
48 | border-width: $button-border-width;
|
49 | border-style: solid;
|
50 | border-color: $border-color;
|
51 | color: $font-color;
|
52 |
|
53 | &:focus,
|
54 | &:hover {
|
55 | background-color: $hover-bg-color;
|
56 | }
|
57 |
|
58 | &:focus {
|
59 | border: $button-border-width solid $ui-02;
|
60 | outline: $button-border-width solid $hover-bg-color;
|
61 | }
|
62 |
|
63 | &:disabled:hover,
|
64 | &:disabled:focus {
|
65 | background-color: $bg-color;
|
66 | }
|
67 |
|
68 | &:active {
|
69 | background-color: darken($bg-color, 20%);
|
70 | }
|
71 |
|
72 | .#{$prefix}--btn__icon {
|
73 | fill: $icon-color;
|
74 | }
|
75 | }
|
76 |
|
77 | @mixin button-base--x {
|
78 | @include reset;
|
79 | @include type-style('body-short-01');
|
80 |
|
81 | cursor: pointer;
|
82 | display: inline-flex;
|
83 | align-items: center;
|
84 | justify-content: space-between;
|
85 | flex-shrink: 0;
|
86 | min-height: rem($button-height);
|
87 | padding: $button-padding;
|
88 | border-radius: $button-border-radius;
|
89 | text-align: left;
|
90 | text-decoration: none;
|
91 | transition: $duration--fast-01 motion(entrance, productive);
|
92 | outline: $button-outline-width solid transparent;
|
93 | position: relative;
|
94 | max-width: rem(320px);
|
95 |
|
96 | &:disabled,
|
97 | &.#{$prefix}--btn--disabled {
|
98 | cursor: not-allowed;
|
99 | color: $ui-04;
|
100 | background: $ibm-color__gray-30;
|
101 | border-color: $ibm-color__gray-30;
|
102 | }
|
103 |
|
104 | .#{$prefix}--btn__icon {
|
105 | position: absolute;
|
106 | right: rem(16px);
|
107 | flex-shrink: 0;
|
108 | width: rem(16px);
|
109 | height: rem(16px);
|
110 | transition: $duration--fast-01 motion(entrance, productive);
|
111 | }
|
112 | }
|
113 |
|
114 | @mixin button-theme--x($bg-color, $border-color, $font-color, $hover-bg-color, $icon-color, $active-color) {
|
115 | background-color: $bg-color;
|
116 | border-width: $button-border-width;
|
117 | border-style: solid;
|
118 | border-color: $border-color;
|
119 | color: $font-color;
|
120 |
|
121 | &:hover {
|
122 | background-color: $hover-bg-color;
|
123 | }
|
124 |
|
125 | &::before,
|
126 | &::after {
|
127 | box-sizing: border-box;
|
128 | position: absolute;
|
129 | content: '';
|
130 | transition: $duration--fast-01 motion(entrance, productive);
|
131 | }
|
132 |
|
133 | &:not(.#{$prefix}--btn--disabled)::before {
|
134 | top: calc(-#{$button-border-width} + #{$button-outline-width});
|
135 | left: -$button-border-width + $button-outline-width;
|
136 | width: calc(100% + (2 * #{$button-border-width}) - (2 * #{$button-outline-width}));
|
137 | height: calc(100% + (2 * #{$button-border-width}) - (2 * #{$button-outline-width}));
|
138 | border: 1px solid transparent;
|
139 | }
|
140 |
|
141 | &:focus::before {
|
142 | border-color: $ui-02;
|
143 | }
|
144 |
|
145 | &:not(.#{$prefix}--btn--disabled)::after {
|
146 | top: -#{$button-border-width};
|
147 | left: -#{$button-border-width};
|
148 | height: calc(100% + 2 * #{$button-border-width});
|
149 | width: calc(100% + 2 * #{$button-border-width});
|
150 | border: $button-outline-width solid transparent;
|
151 | }
|
152 |
|
153 | &:focus::after {
|
154 | border-color: $focus;
|
155 | }
|
156 |
|
157 | &:disabled:hover,
|
158 | &:disabled:focus,
|
159 | &:hover.#{$prefix}--btn--disabled,
|
160 | &:focus.#{$prefix}--btn--disabled {
|
161 | color: $ui-04;
|
162 | background: $ibm-color__gray-30;
|
163 | border-color: $ibm-color__gray-30;
|
164 | text-decoration: none;
|
165 | }
|
166 |
|
167 | &:active {
|
168 | background-color: $active-color;
|
169 | }
|
170 |
|
171 | .#{$prefix}--btn__icon {
|
172 | fill: $icon-color;
|
173 | }
|
174 | }
|