summaryrefslogtreecommitdiffstats
path: root/assets/css/components/_card.scss
blob: f444daf38c1943c2419c32493420663d6a015ffa (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
@include namespace('card') {
    @include store((
        --dims: (
            --pad-x:        1.1em,
            --pad-y:        .8em,
            --hover-offset: -.5rem,
        ),
        --colors: (
            --bg: prop(--colors --bg-lo, $global: true),
            --hover: (
                --bg: prop(--colors --fg-lo, $global: true),
                --fg: prop(--colors --bg-hi, $global: true),
            )
        )
    ));

    @include store((
        --dims: (
            --pad-x: 1em,
            --pad-y: .7em
        )
    ), 'md');

    @include component(namespace()) {
        display:          flex;
        position:         relative;
        align-items:      center;
        transform:        translateY(0);
        transition:       transform .2s, background-color .2s, color .2s;
        background-color: prop(--colors --bg);
        line-height:      1.4;

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

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

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

            &:hover,
            &:focus {
                transform:        translateY(#{prop(--dims --hover-offset)});
                background-color: prop(--colors --hover --bg);
                color:            prop(--colors --hover --fg);

                &::after {
                    display: block;
                }
    
                small,
                strong {
                    color: prop(--colors --hover --fg);
                }
            }
        }

        @include element('content') {
            box-sizing: border-box;
            width:      100%;
            padding:    prop(--dims --pad-y) prop(--dims --pad-x);

            @include modifier('flip') {
                visibility:       hidden;
                position:         absolute;
                top:              0;
                left:             0;
                height:           100%;
                transition:       visibility 0s linear .2s, opacity .2s;
                opacity:          0;
                background-color: prop(--colors --hover --bg);
            }

            @include sibling-element('icon') {
                padding-right: prop(--dims --pad-x);
                padding-left:  0;
            }
        }

        @include element('icon') {
            display: block;
            flex:    0 0 auto;
            padding: prop(--dims --pad-y) 0 prop(--dims --pad-y) prop(--dims --pad-x);
        }

        @include element('image') {
            display:         block;
            flex:            0 0 auto;
            width:           4em;
            height:          100%;
            object-fit:      cover;
            object-position: center center;
        }
    }
}