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

@include iro.props-namespace('avatar') {
    @include iro.props-store((
        --dims: (
            --size:              iro.fn-px-to-rem(40px),
            --size-sm:           iro.fn-px-to-rem(30px),
            --size-xs:           iro.fn-px-to-rem(18px),
            --indicator-size:    fn.foreign-dim(--status-indicator, --size),
            --indicator-spacing: iro.fn-px-to-rem(3px),
            --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:  1rem;
        font-style: normal;

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

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

        @include iro.bem-elem('content') {
            display:          block;
            width:            fn.dim(--size);
            height:           fn.dim(--size);
            border-radius:    fn.dim(--rounding);
            background-color: hsl(fn.color(--h), fn.color(--s), fn.color(--l));
            color:            #fff;
            line-height:      fn.dim(--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));
            }
        }

        @include iro.bem-modifier('sm') {
            font-size: iro.fn-px-to-rem(13px);

            @include iro.bem-elem('content') {
                width:       fn.dim(--size-sm);
                height:      fn.dim(--size-sm);
                line-height: fn.dim(--size-sm);
            }
        }

        @include iro.bem-modifier('xs') {
            font-size: iro.fn-px-to-rem(11px);

            @include iro.bem-elem('content') {
                width:       fn.dim(--size-xs);
                height:      fn.dim(--size-xs);
                line-height: fn.dim(--size-xs);
            }
        }
    }
}