summaryrefslogtreecommitdiffstats
path: root/src/objects/_card.scss
blob: ffe52d690b82f28427aa675bf04cc290e91414b8 (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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
@use 'sass:meta';
@use 'iro-sass/src/iro-sass' as iro;
@use 'iro-sass/src/props';
@use '../props' as *;
@use 'avatar.vars' as avatar;

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

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

    @include iro.bem-object('card') {
        position:         relative;
        display:          flex;
        flex-direction:   column;
        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));

                @include iro.bem-elem('body') {
                    @include iro.bem-modifier('hidden') {
                        visibility: visible;
                        opacity:    1;
                        transition:
                            opacity .2s ease,
                            visibility .2s linear;
                    }
                }
            }

            &: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;
            flex:        0 0 auto;
            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') {
            flex:            1 0 auto;
            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-modifier('hidden') {
                position:                absolute;
                inset-block-end:         0;
                inset-inline:            0;
                z-index:                 10;
                visibility:              hidden;
                background-color:        props.get(vars.$bg-color);
                border-end-start-radius: props.get(vars.$rounding);
                border-end-end-radius:   props.get(vars.$rounding);
                opacity:                 0;
                transition:
                    opacity .2s ease,
                    visibility 0s .2s linear;

                @include iro.bem-next-elem('image') {
                    border-start-start-radius: props.get(vars.$rounding);
                    border-start-end-radius:   props.get(vars.$rounding);
                }
            }
        }

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

        @include iro.bem-elem('footer') {
            flex:               0 0 auto;
            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;
            }
        }
    }
}