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