summaryrefslogtreecommitdiffstats
path: root/src/objects/_card.scss
blob: 205bb33cf8c085b9abe9763f7d966c22cded1564 (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
@use 'sass:meta';
@use 'iro-sass/src/iro-sass' as iro;
@use '../props';
@use 'avatar.vars' as avatar;

@forward 'card.vars';
@use 'card.vars' as vars;

@mixin styles {
    @include props.materialize(meta.module-variables('vars'));

    @include iro.bem-object('card') {
        display:          block;
        margin:           calc(-1 * props.get(vars.$key-focus--border-width));
        background-color: props.get(vars.$bg-color);
        background-clip:  content-box;
        border:           props.get(vars.$key-focus--border-offset) solid transparent;
        border-radius:    calc(props.get(vars.$rounding) + props.get(vars.$key-focus--border-offset));
        transition:       transform .2s;

        @include iro.bem-multi('&:link, &:visited, &:enabled', 'modifier' 'interactive') {
            &:hover,
            &:active,
            &:focus-visible {
                transform: translateY(props.get(vars.$hover--offset-b));
            }

            &:focus-visible {
                outline:      props.get(vars.$key-focus--border-color) solid props.get(vars.$key-focus--border-width);
                box-shadow:
                    0
                    0
                    0
                    calc(props.get(vars.$key-focus--border-width) + props.get(vars.$key-focus--outline-width))
                    props.get(vars.$key-focus--outline-color);
            }
        }

        @include iro.bem-elem('avatar') {
            margin-block-start:  props.get(vars.$pad-b);
            margin-inline-start: props.get(vars.$pad-i);
        }

        @include iro.bem-elem('image') {
            display:          block;
            inline-size:      100%;
            object-fit:       cover;
            transition:       transform .2s, opacity .2s;

            &:first-child {
                border-start-start-radius: props.get(vars.$rounding);
                border-start-end-radius:   props.get(vars.$rounding);
            }

            &:last-child {
                border-end-start-radius: props.get(vars.$rounding);
                border-end-end-radius:   props.get(vars.$rounding);
            }

            @include iro.bem-next-elem('avatar') {
                margin-block-start: calc(-.7 * props.get(avatar.$size--xl));
            }
        }

        @include iro.bem-elem('body') {
            padding-block:  props.get(vars.$pad-b);
            padding-inline: props.get(vars.$pad-i);

            &::before {
                display:       block;
                margin-block:  -100em 100em;
                content:       '';
            }
        }

        @include iro.bem-elem('content') {
            margin-block-start: props.get(vars.$spacing);
        }

        @include iro.bem-elem('footer') {
            padding-block:      0 props.get(vars.$pad-b);
            padding-inline:     props.get(vars.$pad-i);
            margin-block-start: calc(-1 * props.get(vars.$pad-b));

            &::before {
                display:          block;
                block-size:       props.get(vars.$divider-width);
                margin-block:     props.get(vars.$spacing);
                content:          '';
                background-color: props.get(vars.$divider-width);
            }
        }

        @include iro.bem-modifier('quiet') {
            position:         relative;
            background-color: transparent;
            border:           0;

            @include iro.bem-multi('&:link, &:visited, &:enabled', 'modifier' 'interactive') {
                &:hover,
                &:active,
                &:focus-visible {
                    transform: none;

                    @include iro.bem-elem('image') {
                        background-color: props.get(vars.$quiet--hover--image-color);
                        opacity:          .75;
                        transform:        translateY(props.get(vars.$hover--offset-b));
                    }
                }

                &:focus-visible {
                    outline:    none;
                    box-shadow: none;

                    @include iro.bem-elem('image') {
                        background-color: props.get(vars.$quiet--hover--image-color);
                        outline:          props.get(vars.$key-focus--border-color) solid props.get(vars.$key-focus--border-width);
                        box-shadow:
                            0
                            0
                            0
                            calc(props.get(vars.$key-focus--border-width) + props.get(vars.$key-focus--outline-width))
                            props.get(vars.$key-focus--outline-color);
                        opacity:          1;
                    }
                }
            }

            @include iro.bem-elem('image') {
                position:         relative;
                margin:           calc(-1 * props.get(vars.$key-focus--border-width));
                background-color: props.get(vars.$quiet--image-color);
                background-clip:  padding-box;
                border:           props.get(vars.$key-focus--border-offset) solid transparent;
                border-radius:    calc(props.get(vars.$rounding) + props.get(vars.$key-focus--border-offset));
            }

            @include iro.bem-elem('body') {
                padding:             0;
                padding-block-start: props.get(vars.$spacing);
            }

            @include iro.bem-elem('footer') {
                padding-inline: 0;
            }
        }
    }
}