summaryrefslogtreecommitdiffstats
path: root/src/objects/_avatar.scss
blob: d9c1105f4cfcefc4c3475c889bb4f14feb488982 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
@use 'sass:list';
@use 'iro-sass/src/iro-sass' as iro;
@use '../functions' as fn;

$sizes: 'xs' 'sm' 'lg' 'xl' 'xxl' 'xxxl';

@mixin status($size: ()) {
    @include iro.bem-elem('status') {
        inline-size: fn.dim(list.join($size, --indicator-size));
        block-size:  fn.dim(list.join($size, --indicator-size));

        @include iro.bem-next-elem('content') {
            mask-image: radial-gradient(circle calc(.5 * fn.dim(list.join($size, --indicator-size)) + fn.dim(--indicator-spacing)) at
                calc(100% - .5 * fn.dim(list.join($size, --indicator-size)))
                calc(100% - .5 * fn.dim(list.join($size, --indicator-size))),
                transparent 95%,
                #fff);
        }
    }
}

@include iro.props-namespace('avatar') {
    @include iro.props-store((
        --dims: (
            --size:              fn.global-dim(--size --500),
            --font-size:         fn.global-dim(--font-size --100),
            --indicator-size:    fn.global-dim(--size --150),
            --indicator-spacing: fn.global-dim(--size --40),
            --rounding:          25%,

            --xxxl: (
                --size:           fn.global-dim(--size --1600),
                --font-size:      fn.global-dim(--font-size --800),
                --indicator-size: fn.global-dim(--size --400),
            ),
            --xxl: (
                --size:           fn.global-dim(--size --1200),
                --font-size:      fn.global-dim(--font-size --600),
                --indicator-size: fn.global-dim(--size --300),
            ),
            --xl: (
                --size:           fn.global-dim(--size --800),
                --font-size:      fn.global-dim(--font-size --300),
                --indicator-size: fn.global-dim(--size --225),
            ),
            --lg: (
                --size:           fn.global-dim(--size --650),
                --font-size:      fn.global-dim(--font-size --200),
                --indicator-size: fn.global-dim(--size --175),
            ),
            --sm: (
                --size:           fn.global-dim(--size --375),
                --font-size:      fn.global-dim(--font-size --75),
                --indicator-size: fn.global-dim(--size --125),
            ),
            --xs: (
                --size:           fn.global-dim(--size --250),
                --font-size:      fn.global-dim(--font-size --50),
                --indicator-size: fn.global-dim(--size --100),
            ),
            
            --key-focus: (
                --border:        fn.global-dim(--key-focus --border),
                --border-offset: fn.global-dim(--key-focus --border-offset),
                --outline:       fn.global-dim(--key-focus --outline),
            ),
        ),
        --colors: (
            --h: 354,
            --s: 44%,
            --l: 45%,

            --key-focus: (
                --border:  fn.global-color(--focus --border),
                --outline: fn.global-color(--focus --outline),
            ),
        ),
    ));

    @include iro.bem-object(iro.props-namespace()) {
        position:       relative;
        display:        inline-block;
        font-size:      fn.dim(--font-size);
        font-style:     normal;
        vertical-align: .05em;
        border-radius:  fn.dim(--rounding);

        &::after {
            position:       absolute;
            inset:          calc(-1 * fn.dim(--key-focus --border-offset));
            z-index:        1;
            display:        none;
            pointer-events: none;
            content:        '';
            border:         fn.dim(--key-focus --border-offset) solid transparent;
            border-radius:  fn.dim(--rounding);
            outline:        fn.color(--key-focus --border) solid fn.dim(--key-focus --border);
            box-shadow:     0 0 0 calc(fn.dim(--key-focus --border) + fn.dim(--key-focus --outline)) fn.color(--key-focus --outline);
        }

        @include iro.bem-elem('status') {
            position:         absolute;
            inset-block-end:  0;
            inset-inline-end: 0;
        }

        @include status;

        @include iro.bem-elem('content') {
            display:          block;
            inline-size:      fn.dim(--size);
            block-size:       fn.dim(--size);
            line-height:      fn.dim(--size);
            text-align:       center;
            object-fit:       cover;
            object-position:  center center;
            border-radius:    fn.dim(--rounding);
        }

        @include iro.bem-modifier('circle') {
            border-radius: 100%;

            &::after {
                border-radius: 100%;
            }

            @include iro.bem-elem('content') {
                border-radius: 100%;
            }
        }

        @include iro.bem-modifier('placeholder') {
            @include iro.bem-elem('content') {
                background-color: hsl(0, 0%, fn.color(--l));
            }
        }

        @include iro.bem-modifier('colored') {
            @include iro.bem-elem('content') {
                color:            #fff;
                background-color: hsl(fn.color(--h), fn.color(--s), fn.color(--l));
            }
        }

        @each $size in $sizes {
            @include iro.bem-modifier($size) {
                font-size: fn.dim(--#{$size} --font-size);
    
                @include status(--#{$size});
    
                @include iro.bem-elem('content') {
                    inline-size: fn.dim(--#{$size} --size);
                    block-size:  fn.dim(--#{$size} --size);
                    line-height: fn.dim(--#{$size} --size);
                }
            }
        }
    
        &:focus-visible {
            &::after {
                display: block;
            }
        }
    }
}