summaryrefslogtreecommitdiffstats
path: root/src/objects/_avatar.scss
diff options
context:
space:
mode:
Diffstat (limited to 'src/objects/_avatar.scss')
-rw-r--r--src/objects/_avatar.scss165
1 files changed, 165 insertions, 0 deletions
diff --git a/src/objects/_avatar.scss b/src/objects/_avatar.scss
new file mode 100644
index 0000000..d9c1105
--- /dev/null
+++ b/src/objects/_avatar.scss
@@ -0,0 +1,165 @@
1@use 'sass:list';
2@use 'iro-sass/src/iro-sass' as iro;
3@use '../functions' as fn;
4
5$sizes: 'xs' 'sm' 'lg' 'xl' 'xxl' 'xxxl';
6
7@mixin status($size: ()) {
8 @include iro.bem-elem('status') {
9 inline-size: fn.dim(list.join($size, --indicator-size));
10 block-size: fn.dim(list.join($size, --indicator-size));
11
12 @include iro.bem-next-elem('content') {
13 mask-image: radial-gradient(circle calc(.5 * fn.dim(list.join($size, --indicator-size)) + fn.dim(--indicator-spacing)) at
14 calc(100% - .5 * fn.dim(list.join($size, --indicator-size)))
15 calc(100% - .5 * fn.dim(list.join($size, --indicator-size))),
16 transparent 95%,
17 #fff);
18 }
19 }
20}
21
22@include iro.props-namespace('avatar') {
23 @include iro.props-store((
24 --dims: (
25 --size: fn.global-dim(--size --500),
26 --font-size: fn.global-dim(--font-size --100),
27 --indicator-size: fn.global-dim(--size --150),
28 --indicator-spacing: fn.global-dim(--size --40),
29 --rounding: 25%,
30
31 --xxxl: (
32 --size: fn.global-dim(--size --1600),
33 --font-size: fn.global-dim(--font-size --800),
34 --indicator-size: fn.global-dim(--size --400),
35 ),
36 --xxl: (
37 --size: fn.global-dim(--size --1200),
38 --font-size: fn.global-dim(--font-size --600),
39 --indicator-size: fn.global-dim(--size --300),
40 ),
41 --xl: (
42 --size: fn.global-dim(--size --800),
43 --font-size: fn.global-dim(--font-size --300),
44 --indicator-size: fn.global-dim(--size --225),
45 ),
46 --lg: (
47 --size: fn.global-dim(--size --650),
48 --font-size: fn.global-dim(--font-size --200),
49 --indicator-size: fn.global-dim(--size --175),
50 ),
51 --sm: (
52 --size: fn.global-dim(--size --375),
53 --font-size: fn.global-dim(--font-size --75),
54 --indicator-size: fn.global-dim(--size --125),
55 ),
56 --xs: (
57 --size: fn.global-dim(--size --250),
58 --font-size: fn.global-dim(--font-size --50),
59 --indicator-size: fn.global-dim(--size --100),
60 ),
61
62 --key-focus: (
63 --border: fn.global-dim(--key-focus --border),
64 --border-offset: fn.global-dim(--key-focus --border-offset),
65 --outline: fn.global-dim(--key-focus --outline),
66 ),
67 ),
68 --colors: (
69 --h: 354,
70 --s: 44%,
71 --l: 45%,
72
73 --key-focus: (
74 --border: fn.global-color(--focus --border),
75 --outline: fn.global-color(--focus --outline),
76 ),
77 ),
78 ));
79
80 @include iro.bem-object(iro.props-namespace()) {
81 position: relative;
82 display: inline-block;
83 font-size: fn.dim(--font-size);
84 font-style: normal;
85 vertical-align: .05em;
86 border-radius: fn.dim(--rounding);
87
88 &::after {
89 position: absolute;
90 inset: calc(-1 * fn.dim(--key-focus --border-offset));
91 z-index: 1;
92 display: none;
93 pointer-events: none;
94 content: '';
95 border: fn.dim(--key-focus --border-offset) solid transparent;
96 border-radius: fn.dim(--rounding);
97 outline: fn.color(--key-focus --border) solid fn.dim(--key-focus --border);
98 box-shadow: 0 0 0 calc(fn.dim(--key-focus --border) + fn.dim(--key-focus --outline)) fn.color(--key-focus --outline);
99 }
100
101 @include iro.bem-elem('status') {
102 position: absolute;
103 inset-block-end: 0;
104 inset-inline-end: 0;
105 }
106
107 @include status;
108
109 @include iro.bem-elem('content') {
110 display: block;
111 inline-size: fn.dim(--size);
112 block-size: fn.dim(--size);
113 line-height: fn.dim(--size);
114 text-align: center;
115 object-fit: cover;
116 object-position: center center;
117 border-radius: fn.dim(--rounding);
118 }
119
120 @include iro.bem-modifier('circle') {
121 border-radius: 100%;
122
123 &::after {
124 border-radius: 100%;
125 }
126
127 @include iro.bem-elem('content') {
128 border-radius: 100%;
129 }
130 }
131
132 @include iro.bem-modifier('placeholder') {
133 @include iro.bem-elem('content') {
134 background-color: hsl(0, 0%, fn.color(--l));
135 }
136 }
137
138 @include iro.bem-modifier('colored') {
139 @include iro.bem-elem('content') {
140 color: #fff;
141 background-color: hsl(fn.color(--h), fn.color(--s), fn.color(--l));
142 }
143 }
144
145 @each $size in $sizes {
146 @include iro.bem-modifier($size) {
147 font-size: fn.dim(--#{$size} --font-size);
148
149 @include status(--#{$size});
150
151 @include iro.bem-elem('content') {
152 inline-size: fn.dim(--#{$size} --size);
153 block-size: fn.dim(--#{$size} --size);
154 line-height: fn.dim(--#{$size} --size);
155 }
156 }
157 }
158
159 &:focus-visible {
160 &::after {
161 display: block;
162 }
163 }
164 }
165}