summaryrefslogtreecommitdiffstats
path: root/src/objects/_button.scss
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2024-06-22 19:30:00 +0200
committerVolpeon <git@volpeon.ink>2024-06-22 19:30:00 +0200
commit6b0fcac695aa7a5517f6f53cec50da493acc4582 (patch)
tree05b1ec4bfd484c75f1ee82f06f674aba69ad1408 /src/objects/_button.scss
parentWIP: Refactoring (diff)
downloadiro-design-6b0fcac695aa7a5517f6f53cec50da493acc4582.tar.gz
iro-design-6b0fcac695aa7a5517f6f53cec50da493acc4582.tar.bz2
iro-design-6b0fcac695aa7a5517f6f53cec50da493acc4582.zip
Update
Diffstat (limited to 'src/objects/_button.scss')
-rw-r--r--src/objects/_button.scss173
1 files changed, 173 insertions, 0 deletions
diff --git a/src/objects/_button.scss b/src/objects/_button.scss
new file mode 100644
index 0000000..d3588f6
--- /dev/null
+++ b/src/objects/_button.scss
@@ -0,0 +1,173 @@
1@use 'sass:list';
2@use 'iro-sass/src/index' as iro;
3@use '../functions' as fn;
4
5$themes: primary accent positive negative warning;
6
7@mixin button-variant($theme: null) {
8 $key: if($theme == null, (), --#{$theme});
9
10 &:link,
11 &:visited,
12 &:enabled {
13 border-color: fn.color(list.join($key, --bg));
14 background-color: fn.color(list.join($key, --bg));
15 color: fn.color(list.join($key, --label));
16 }
17
18 @include iro.bem-modifier('outline') {
19 &:link,
20 &:visited,
21 &:enabled {
22 background-color: transparent;
23 color: fn.color(list.join($key, --outline-label));
24 }
25 }
26
27 &:link,
28 &:visited,
29 &:enabled {
30 &:hover {
31 border-color: fn.color(list.join($key, --hover --bg));
32 background-color: fn.color(list.join($key, --hover --bg));
33 color: fn.color(list.join($key, --hover --label));
34 }
35
36 &:active {
37 border-color: fn.color(list.join($key, --active --bg));
38 background-color: fn.color(list.join($key, --active --bg));
39 color: fn.color(list.join($key, --active --label));
40 }
41 }
42}
43
44@include iro.props-namespace('button') {
45 @include iro.props-store((
46 --dims: (
47 --line-height: 1.4,
48 --pad-i: fn.global-dim(--size --225),
49 --pad-b: fn.global-dim(--size --65),
50 --rounding: 10em,
51
52 --lg: (
53 --pad-i: fn.global-dim(--size --300),
54 --pad-b: fn.global-dim(--size --100),
55 ),
56 ),
57 --colors: (
58 --bg: fn.global-color(--border-mute),
59 --label: fn.global-color(--text),
60 --outline-label: fn.global-color(--text),
61
62 --hover: (
63 --bg: fn.global-color(--border),
64 --label: fn.global-color(--heading),
65 ),
66 --active: (
67 --bg: fn.global-color(--border-strong),
68 --label: fn.global-color(--heading),
69 ),
70 --disabled: (
71 --bg: fn.global-color(--border-mute),
72 --label: fn.global-color(--text-disabled),
73 ),
74 --key-focus: (
75 --bg: fn.global-color(--base --50),
76 --label: fn.global-color(--heading),
77 --border: fn.global-color(--yellow-static --400),
78 ),
79
80 --primary: (
81 --bg: fn.global-color(--base --800),
82 --label: fn.global-color(--base --800-text),
83 --outline-label: fn.global-color(--text),
84
85 --hover: (
86 --bg: fn.global-color(--base --900),
87 --label: fn.global-color(--base --900-text),
88 ),
89 --active: (
90 --bg: fn.global-color(--base --900),
91 --label: fn.global-color(--base --900-text),
92 ),
93 ),
94 ),
95 ));
96
97 @each $theme in $themes {
98 @if $theme != primary {
99 @include iro.props-store((
100 --colors: (
101 --#{$theme}: (
102 --bg: fn.global-color(--#{$theme} --900),
103 --label: fn.global-color(--#{$theme} --900-text),
104 --outline-label: fn.global-color(--#{$theme} --1000),
105
106 --hover: (
107 --bg: fn.global-color(--#{$theme} --1000),
108 --label: fn.global-color(--#{$theme} --1000-text),
109 ),
110 --active: (
111 --bg: fn.global-color(--#{$theme} --1100),
112 --label: fn.global-color(--#{$theme} --1100-text),
113 ),
114 ),
115 ),
116 ));
117 }
118 }
119
120 @include iro.bem-object(iro.props-namespace()) {
121 display: inline-block;
122 padding-block: fn.dim(--pad-b);
123 padding-inline: fn.dim(--pad-i);
124 border: 2px solid transparent;
125 border-radius: fn.dim(--rounding);
126 border-color: fn.color(--disabled --bg);
127 background-color: fn.color(--disabled --bg);
128 color: fn.color(--disabled --label);
129 font-weight: 500;
130 line-height: fn.dim(--line-height);
131 text-align: center;
132 text-decoration: none;
133 vertical-align: top;
134
135 @include iro.bem-modifier('block') {
136 display: block;
137 }
138
139 @include iro.bem-modifier('outline') {
140 background-color: transparent;
141 box-shadow: none;
142 }
143
144 @include iro.bem-modifier('lg') {
145 padding-block: fn.dim(--lg --pad-b);
146 padding-inline: fn.dim(--lg --pad-i);
147 }
148
149 @include button-variant();
150
151 @each $theme in $themes {
152 @include iro.bem-modifier($theme) {
153 @include button-variant($theme);
154 }
155 }
156
157 &:link,
158 &:visited,
159 &:enabled {
160 &:focus-visible {
161 border-color: fn.color(--key-focus --border);
162 background-color: fn.color(--key-focus --bg);
163 color: fn.color(--key-focus --label);
164 }
165 }
166
167 @include iro.bem-modifier('round') {
168 inline-size: calc(1em * fn.dim(--line-height) + 2 * fn.dim(--pad-b));
169 padding-inline: 0;
170 border-radius: 100em;
171 }
172 }
173}