summaryrefslogtreecommitdiffstats
path: root/src/objects/_radio.scss
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2022-02-05 19:33:35 +0100
committerVolpeon <git@volpeon.ink>2022-02-05 19:33:35 +0100
commitb2e7a1fac1613f63e879b22c577500de0b033fdc (patch)
tree6b03addf8992d7af6ab4c8dd3cf117e5ce09a494 /src/objects/_radio.scss
parentAdded field-label (diff)
downloadiro-design-b2e7a1fac1613f63e879b22c577500de0b033fdc.tar.gz
iro-design-b2e7a1fac1613f63e879b22c577500de0b033fdc.tar.bz2
iro-design-b2e7a1fac1613f63e879b22c577500de0b033fdc.zip
Added radio
Diffstat (limited to 'src/objects/_radio.scss')
-rw-r--r--src/objects/_radio.scss155
1 files changed, 155 insertions, 0 deletions
diff --git a/src/objects/_radio.scss b/src/objects/_radio.scss
new file mode 100644
index 0000000..635a260
--- /dev/null
+++ b/src/objects/_radio.scss
@@ -0,0 +1,155 @@
1@use 'iro-sass/src/index' as iro;
2
3@include iro.props-namespace('radio') {
4 @include iro.props-store((
5 --dims: (
6 --diameter: iro.fn-px-to-rem(15px),
7 --label-gap: .6rem,
8 --border-width: iro.props-get(--dims --border-width --medium, $global: true),
9 --padding-x: .3rem,
10 --padding-y: .3rem,
11 --margin-right: iro.props-get(--dims --spacing --x --md, $global: true),
12 ),
13 --colors: (
14 --circle-border: iro.props-get(--colors --fg-hi2, $global: true),
15 --circle-bg: iro.props-get(--colors --bg-hi, $global: true),
16
17 --hover: (
18 --label: iro.props-get(--colors --fg-lo, $global: true),
19 --circle-border: iro.props-get(--colors --fg-hi, $global: true),
20 ),
21 --active: (
22 --circle-border: iro.props-get(--colors --accent --primary, $global: true),
23
24 --hover: (
25 --circle-border: iro.props-get(--colors --accent --primary-lo, $global: true),
26 ),
27 ),
28 --key-focus: (
29 --label: iro.props-get(--colors --focus --text, $global: true),
30 --circle-border: iro.props-get(--colors --focus --fill, $global: true),
31 --shadow: iro.props-get(--colors --focus --shadow, $global: true),
32 ),
33 --disabled: (
34 --label: iro.props-get(--colors --fg-hi3, $global: true),
35 --circle-border: iro.props-get(--colors --obj-lo, $global: true),
36 --circle-bg: iro.props-get(--colors --bg-hi, $global: true),
37
38 --active: (
39 --circle-border: iro.props-get(--colors --obj-lo, $global: true),
40 ),
41 )
42 ),
43 ));
44
45 @include iro.bem-object(iro.props-namespace()) {
46 display: inline-flex;
47 position: relative;
48 align-items: flex-start;
49 margin-right: calc(-1 * iro.props-get(--dims --padding-x) + iro.props-get(--dims --margin-right));
50 margin-left: calc(-1 * iro.props-get(--dims --padding-x));
51 padding: iro.props-get(--dims --padding-y) iro.props-get(--dims --padding-x);
52
53 @include iro.bem-elem('circle') {
54 display: block;
55 position: relative;
56 box-sizing: border-box;
57 flex: 0 0 auto;
58 width: iro.props-get(--dims --diameter);
59 height: iro.props-get(--dims --diameter);
60 margin-top: calc(.5 * (#{$line-height * 1em} - #{iro.props-get(--dims --diameter)}));
61 border-radius: 2em;
62 background-color: iro.props-get(--colors --circle-border);
63
64 &::after {
65 content: '';
66 display: block;
67 position: absolute;
68 z-index: 10;
69 top: 50%;
70 left: iro.props-get(--dims --border-width);
71 width: calc(iro.props-get(--dims --diameter) - 2 * iro.props-get(--dims --border-width));
72 height: calc(iro.props-get(--dims --diameter) - 2 * iro.props-get(--dims --border-width));
73 transform: translateY(-50%);
74 transition: transform .2s ease;
75 border-radius: iro.props-get(--dims --diameter);
76 background-color: iro.props-get(--colors --circle-bg);
77 }
78 }
79
80 @include iro.bem-elem('label') {
81 margin-left: iro.props-get(--dims --label-gap);
82 }
83
84 @include iro.bem-elem('native') {
85 position: absolute;
86 top: 0;
87 left: 0;
88 width: 100%;
89 height: 100%;
90 margin: 0;
91 padding: 0;
92 overflow: hidden;
93 opacity: .0001;
94
95 &:hover {
96 @include iro.bem-sibling-elem('label') {
97 color: iro.props-get(--colors --hover --label);
98 }
99
100 @include iro.bem-sibling-elem('circle') {
101 background-color: iro.props-get(--colors --hover --circle-border);
102 }
103 }
104
105 &:checked {
106 @include iro.bem-sibling-elem('circle') {
107 background-color: iro.props-get(--colors --active --circle-border);
108
109 &::after {
110 transform: translateY(-50%) scale(.44);
111 }
112 }
113
114 &:hover {
115 @include iro.bem-sibling-elem('circle') {
116 background-color: iro.props-get(--colors --active --hover --circle-border);
117 }
118 }
119 }
120
121 &:disabled {
122 @include iro.bem-sibling-elem('label') {
123 color: iro.props-get(--colors --disabled --label);
124 }
125
126 @include iro.bem-sibling-elem('circle') {
127 background-color: iro.props-get(--colors --disabled --circle-border);
128
129 &::after {
130 background-color: iro.props-get(--colors --disabled --circle-bg);
131 }
132 }
133
134 &:checked {
135 @include iro.bem-sibling-elem('circle') {
136 background-color: iro.props-get(--colors --disabled --active --circle-border);
137 }
138 }
139 }
140
141 @include iro.bem-at-theme('keyboard') {
142 &:focus {
143 @include iro.bem-sibling-elem('label') {
144 color: iro.props-get(--colors --key-focus --label);
145 }
146
147 @include iro.bem-sibling-elem('circle') {
148 background-color: iro.props-get(--colors --key-focus --circle-border);
149 box-shadow: iro.props-get(--colors --key-focus --shadow);
150 }
151 }
152 }
153 }
154 }
155}