-
Notifications
You must be signed in to change notification settings - Fork 47
/
Card.svelte
137 lines (121 loc) · 3.44 KB
/
Card.svelte
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
<style>
/**
* Cards
*
* I drew some inspiration from the article on media-query less cards:
* https://css-tricks.com/how-to-make-a-media-query-less-card-component/
*/
.card,
.card-base {
display: flex;
flex-wrap: wrap;
align-items: center;
position: relative;
box-sizing: border-box;
width: 100%;
}
.card-border {
border: 1px solid var(--agnostic-card-border-color, var(--agnostic-gray-light));
}
.card-rounded {
border-radius: var(--agnostic-radius, 0.25rem);
}
.card-shadow {
box-shadow:
var(--agnostic-card-boxshadow1-offset-x, 0)
var(--agnostic-card-boxshadow1-offset-y, 0.375rem)
var(--agnostic-card-boxshadow1-blur, 0.5625rem)
var(--agnostic-card-boxshadow1-color, rgb(6 6 6 / 7.5%)),
var(--agnostic-card-boxshadow2-offset-x, 0) var(--agnostic-card-boxshadow2-offset-y, 0)
var(--agnostic-card-boxshadow2-blur, 1px)
var(--agnostic-card-boxshadow2-color, rgb(5 5 5 / 10%));
border-radius: var(--agnostic-card-border-radius, var(--agnostic-radius, 0.25rem));
overflow: hidden;
}
.card-shadow:hover {
box-shadow:
var(--agnostic-card-boxshadow1-offset-x, 0)
var(--agnostic-card-boxshadow1-offset-y, 0.375rem)
var(--agnostic-card-boxshadow1-blur, 0.875rem)
var(--agnostic-card-boxshadow1-color, rgb(4 4 4 / 10%)),
var(--agnostic-card-boxshadow2-offset-x, 0) var(--agnostic-card-boxshadow2-offset-y, 0)
var(--agnostic-card-boxshadow2-blur, 2px)
var(--agnostic-card-boxshadow2-color, rgb(3 3 3 / 10%));
}
/**
* Animates the y position and box shadow on hover
*/
.card-animated {
transition:
box-shadow ease-out 5s,
transform var(--agnostic-timing-fast)
cubic-bezier(
var(--agnostic-card-cubic-1, 0.39),
var(--agnostic-card-cubic-2, 0.575),
var(--agnostic-card-cubic-3, 0.565),
var(--agnostic-card-cubic-4, 1)
);
}
.card-animated:hover {
transform: translateY(var(--agnostic-card-translate-y-hover, -3px));
transition:
box-shadow ease-out var(--agnostic-timing-fast),
transform var(--agnostic-timing-slow)
cubic-bezier(
var(--agnostic-card-cubic-1, 0.39),
var(--agnostic-card-cubic-2, 0.575),
var(--agnostic-card-cubic-3, 0.565),
var(--agnostic-card-cubic-4, 1)
);
}
@media (prefers-reduced-motion), (update: slow) {
.card-animated,
.card-animated:hover {
transition-duration: 0.001ms !important;
}
}
.card-stacked {
flex-direction: column;
}
.card-success {
background: var(--agnostic-action-light);
color: var(--agnostic-action-dark);
}
.card-info {
background: var(--agnostic-primary-light);
color: var(--agnostic-primary-dark);
}
.card-error {
background: var(--agnostic-error-light);
color: var(--agnostic-error-dark);
}
.card-warning {
background: var(--agnostic-warning-light);
color: var(--agnostic-warning-dark);
}
</style>
<script>
export let isAnimated = false;
export let isSkinned = true;
export let isStacked = false;
export let isShadow = false;
export let isBorder = false;
export let isRounded = false;
export let type = "";
export let css = "";
let klasses = [
isSkinned ? "card" : "card-base",
isAnimated ? "card-animated" : "",
isStacked ? "card-stacked" : "",
isShadow ? "card-shadow" : "",
isRounded ? "card-rounded" : "",
isBorder ? "card-border" : "",
type ? `card-${type}` : "",
css ? `${css}` : "",
]
.filter((klass) => klass.length)
.join(" ");
</script>
<div class={klasses} on:click on:focus on:blur>
<slot />
</div>