summaryrefslogtreecommitdiffstats
path: root/assets/css/components/_card.scss
blob: ca23bf430ea916241e60dc25ac08f20184ca7cc2 (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
@use 'iro-sass/src/index' as iro;
@use 'iro-design/src/functions' as fn;
@use '../functions' as fn2;

@include iro.props-namespace('card') {
    @include iro.props-store((
        --dims: (
            --hover-offset: fn2.px-to-em(-5px),
            --indicator: (
                --width:  1em,
                --height: 4px,
            ),
        )
    ), 'dims');

    @include iro.props-store((
        --colors: (
            --bg:     fn.global-color(--bg),
            --fg:     fn.global-color(--fg),
            --unread: fn.global-color(--obj),
            --border: fn.global-color(--obj),
            --hover: (
                --bg: fn.global-color(--fg-lo),
                --fg: fn.global-color(--bg-hi2),
            ),
        )
    ), 'colors');

    @include iro.bem-component(iro.props-namespace()) {
        display:          flex;
        position:         relative;
        flex-direction:   column;
        justify-content:  center;
        transform:        translateY(0);
        transition:       transform .2s, background-color .2s, color .2s, border-color .2s;
        background-color: fn.color(--bg);
        color:            fn.color(--fg);
        line-height:      1.4;

        &::after {
            content:  '';
            display:  none;
            position: absolute;
            top:      100%;
            left:     0;
            width:    100%;
            height:   calc(-1 * fn.dim(--hover-offset));
        }

        small,
        strong {
            transition: color .2s;
        }

        &:link,
        &:visited {
            text-decoration: none;

            &:hover,
            &:focus {
                transform:        translateY(fn.dim(--hover-offset));
                background-color: fn.color(--hover --bg);
                color:            fn.color(--hover --fg);

                &::after {
                    display: block;
                }

                small,
                strong {
                    color: fn.color(--hover --fg);
                }

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

                @include iro.bem-elem('indicator') {
                    color: fn.color(--hover --fg);
                }
            }
        }

        &:visited {
            @include iro.bem-elem('indicator') {
                color: fn.color(--bg);
            }
        }

        @include iro.bem-modifier('outline') {
            border:           1px solid fn.color(--border);
            background-color: transparent;

            &:link,
            &:visited {
                &:hover,
                &:focus {
                    border-color: transparent;
                }
            }
        }

        @include iro.bem-elem('row') {
            @include iro.bem-modifier('hidden') {
                visibility:       hidden;
                position:         absolute;
                z-index:          10;
                right:            0;
                bottom:           0;
                left:             0;
                transition:       opacity .2s, visibility 0s .2s;
                opacity:          0;
                background-color: fn.color(--hover --bg);

                @media (hover: none) {
                    visibility:       visible;
                    position:         static;
                    opacity:          1;
                    background-color: transparent;
                }
            }
        }

        @include iro.bem-elem('thumbnail') {
            position:    relative;
            width:       100%;
            height:      3em;
            padding-top: 30%;
        }

        @include iro.bem-elem('thumbnail-img') {
            display:    block;
            position:   absolute;
            top:        0;
            left:       0;
            width:      100%;
            height:     100%;
            object-fit: cover;
        }

        @include iro.bem-elem('indicator') {
            transition: color .2s;
            color:      fn.color(--unread);

            &::before {
                content:          '';
                display:          block;
                width:            fn.dim(--indicator --width);
                height:           fn.dim(--indicator --height);
                border-radius:    fn.dim(--indicator --height);
                background-color: currentColor;
            }
        }

        @media print {
            border: 2px solid currentColor;
        }
    }
}