summaryrefslogtreecommitdiffstats
path: root/src/objects/_avatar.scss
blob: 526912f20c2a49d3582b78b01c14a389311db993 (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
@use 'iro-sass/src/index' as iro;
@use '../functions' as fn;

@mixin status($size) {
    @include iro.bem-elem('status') {
        width:  fn.dim(--#{$size} --indicator-size);
        height: fn.dim(--#{$size} --indicator-size);

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

@include iro.props-namespace('avatar') {
    @include iro.props-store((
        --dims: (
            --150: (
                --size:           fn.global-dim(--size --600),
                --font-size:      fn.global-dim(--font-size --150),
                --indicator-size: fn.global-dim(--size --175),
            ),
            --100: (
                --size:           fn.global-dim(--size --450),
                --font-size:      fn.global-dim(--font-size --100),
                --indicator-size: fn.global-dim(--size --125),
            ),
            --75: (
                --size:           fn.global-dim(--size --325),
                --font-size:      fn.global-dim(--font-size --75),
                --indicator-size: fn.global-dim(--size --100),
            ),
            --50: (
                --size:           fn.global-dim(--size --225),
                --font-size:      fn.global-dim(--font-size --50),
                --indicator-size: fn.global-dim(--size --85),
            ),
            --indicator-spacing: fn.global-dim(--size --40),
            --rounding:          25%,
        ),
    ), 'dims');

    @include iro.props-store((
        --colors: (
            --h: 354,
            --s: 44%,
            --l: 45%,
        ),
    ), 'colors');

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

        @include iro.bem-elem('status') {
            position: absolute;
            right:    0;
            bottom:   0;
        }

        @include status(100);

        @include iro.bem-elem('content') {
            display:          block;
            width:            fn.dim(--100 --size);
            height:           fn.dim(--100 --size);
            border-radius:    fn.dim(--rounding);
            background-color: hsl(fn.color(--h), fn.color(--s), fn.color(--l));
            color:            #fff;
            line-height:      fn.dim(--100 --size);
            text-align:       center;
            object-fit:       cover;
            object-position:  center center;
        }

        @include iro.bem-modifier('circle') {
            @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));
            }
        }

        @each $size in 50 75 150 {
            @include iro.bem-modifier($size) {
                font-size: fn.dim(--#{$size} --font-size);
    
                @include status($size);
    
                @include iro.bem-elem('content') {
                    width:       fn.dim(--#{$size} --size);
                    height:      fn.dim(--#{$size} --size);
                    line-height: fn.dim(--#{$size} --size);
                }
            }
        }
    }
}