-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.astro
More file actions
80 lines (70 loc) · 1.52 KB
/
Button.astro
File metadata and controls
80 lines (70 loc) · 1.52 KB
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
---
interface Props {
backgroundColor?: string;
borderRadius?: string;
padding?: string;
href?: string;
id?: string;
}
const {
backgroundColor = "#715ec2",
borderRadius = "clamp(4px, 1em, 20px)",
padding = "0.6em 1.5em",
href = "#",
id,
} = Astro.props;
---
<a href={href} class="button-container">
<button id={id} class="button">
<slot />
</button>
</a>
<style
define:vars={{
backgroundColor: backgroundColor,
padding: padding,
borderRadius: borderRadius,
}}
>
.button-container {
display: inline-flex;
text-decoration: none;
width: fit-content;
}
.button {
/* 基础重置 */
border: none;
outline: none;
cursor: pointer;
white-space: nowrap;
display: inline-flex;
align-items: center;
justify-content: center;
background: var(--backgroundColor);
padding: var(--padding);
border-radius: var(--borderRadius);
color: rgb(245, 242, 250);
font-weight: bold;
width: auto;
height: auto;
/* font-size: 1vw; */
font-size: clamp(10px, 1rem, 10vw);
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
transform: scale(1);
}
.button:hover {
background: color-mix(in srgb, var(--backgroundColor), white 15%);
transform: scale(1.05);
}
.button:active {
transform: scale(0.96);
background: color-mix(in srgb, var(--backgroundColor), black 10%);
transition: all 0.1s ease;
}
@media (max-width: 400px) {
.button-container,
.button {
width: 100%;
}
}
</style>