-
Notifications
You must be signed in to change notification settings - Fork 402
Expand file tree
/
Copy pathIconButton.svelte
More file actions
78 lines (70 loc) · 1.4 KB
/
IconButton.svelte
File metadata and controls
78 lines (70 loc) · 1.4 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
<script>
export let color = "currentColor";
export let disabled = false;
export let icon;
export let title;
export let errorDot = false;
export let warnDot = false;
export let infoDot = false;
</script>
<button
class:infoDot={infoDot || warnDot || errorDot}
class:warnDot
class:errorDot
on:click
{disabled}
style="--svg-fill: {color};"
{title}
>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html icon}
</button>
<style>
button {
align-items: center;
background-color: transparent;
color: inherit;
cursor: pointer;
display: flex;
flex-shrink: 0;
height: 1.5rem;
justify-content: center;
overflow: visible;
position: relative;
width: 1.5rem;
}
button.infoDot::after {
background-color: var(--color-blue);
border: 2px solid var(--color-bg-secondary);
border-radius: 50%;
content: "";
height: 0.75rem;
left: 0;
position: absolute;
top: 0;
width: 0.75rem;
}
button.warnDot::after {
background-color: var(--color-yellow);
}
button.errorDot::after {
background-color: var(--color-red);
}
button:disabled {
opacity: var(--opacity-disabled);
pointer-events: none;
}
button :global(svg) {
fill: var(--svg-fill);
height: auto;
opacity: 0.75;
pointer-events: none; /* prevent svg from triggering click events */
transform: scale(0.667);
width: 100%;
}
@media (hover: hover) {
button:hover :global(svg) {
opacity: 1;
}
}
</style>