@hyvor/design 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script>import {
|
|
2
|
+
IconCheckCircleFill,
|
|
3
|
+
IconXCircleFill
|
|
4
|
+
} from "@hyvor/icons";
|
|
5
|
+
export let block = false;
|
|
2
6
|
export let full = false;
|
|
3
7
|
export let padding = "medium";
|
|
4
8
|
export let size = "medium";
|
|
9
|
+
export let state = "loading";
|
|
10
|
+
export let duration = 2e3;
|
|
11
|
+
$: {
|
|
12
|
+
if (state === "success" || state === "error") {
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
state = "none";
|
|
15
|
+
}, duration);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
5
18
|
export let color = "var(--accent)";
|
|
6
19
|
export let colorTrack = "var(--accent-lightest)";
|
|
7
20
|
export let invert = false;
|
|
@@ -33,6 +46,9 @@ padding = typeof padding === "number" ? padding : paddings[padding];
|
|
|
33
46
|
class="loader"
|
|
34
47
|
class:block
|
|
35
48
|
class:full
|
|
49
|
+
class:success={state === 'success'}
|
|
50
|
+
class:error={state === 'error'}
|
|
51
|
+
|
|
36
52
|
|
|
37
53
|
style:--local-size={size + "px"}
|
|
38
54
|
style:padding={block ? padding + "px" : undefined}
|
|
@@ -40,38 +56,54 @@ padding = typeof padding === "number" ? padding : paddings[padding];
|
|
|
40
56
|
>
|
|
41
57
|
|
|
42
58
|
|
|
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
|
-
|
|
59
|
+
{#if state !== 'none'}
|
|
60
|
+
<span class="loader-wrap">
|
|
61
|
+
|
|
62
|
+
{#if state === 'loading'}
|
|
63
|
+
<svg>
|
|
64
|
+
<circle
|
|
65
|
+
class="track"
|
|
66
|
+
cx="50%"
|
|
67
|
+
cy="50%"
|
|
68
|
+
r={r + "px"}
|
|
69
|
+
fill="none"
|
|
70
|
+
stroke-width={strokeWidth}
|
|
71
|
+
stroke={colorTrack}
|
|
72
|
+
></circle>
|
|
73
|
+
<circle
|
|
74
|
+
class="progress"
|
|
75
|
+
cx="50%"
|
|
76
|
+
cy="50%"
|
|
77
|
+
r={r + "px"}
|
|
78
|
+
fill="none"
|
|
79
|
+
stroke-width={strokeWidth}
|
|
80
|
+
stroke={color}
|
|
81
|
+
stroke-linecap="round"
|
|
82
|
+
stroke-dasharray={strokeDashArray}
|
|
83
|
+
stroke-dashoffset={strokeDashOffset}
|
|
84
|
+
></circle>
|
|
85
|
+
</svg>
|
|
86
|
+
{:else if state === 'success'}
|
|
87
|
+
<span class="success-icon">
|
|
88
|
+
<IconCheckCircleFill color="var(--green)" width={size} height={size} />
|
|
89
|
+
</span>
|
|
90
|
+
{:else if state === 'error'}
|
|
91
|
+
<span class="error-icon">
|
|
92
|
+
<IconXCircleFill color="var(--red)" width={size} height={size} />
|
|
93
|
+
</span>
|
|
94
|
+
{/if}
|
|
95
|
+
|
|
96
|
+
</span>
|
|
97
|
+
|
|
98
|
+
{/if}
|
|
99
|
+
|
|
68
100
|
|
|
69
101
|
{#if $$slots.default}
|
|
70
102
|
<div class="message">
|
|
71
103
|
<slot></slot>
|
|
72
104
|
</div>
|
|
73
105
|
{/if}
|
|
74
|
-
|
|
106
|
+
|
|
75
107
|
</div>
|
|
76
108
|
|
|
77
109
|
|
|
@@ -115,6 +147,10 @@ padding = typeof padding === "number" ? padding : paddings[padding];
|
|
|
115
147
|
position: relative;
|
|
116
148
|
}
|
|
117
149
|
|
|
150
|
+
.success-icon, .error-icon {
|
|
151
|
+
animation: scale 0.2s ease-in-out;
|
|
152
|
+
}
|
|
153
|
+
|
|
118
154
|
svg {
|
|
119
155
|
width: inherit;
|
|
120
156
|
height: inherit;
|
|
@@ -138,4 +174,14 @@ circle.progress {
|
|
|
138
174
|
100% {
|
|
139
175
|
transform: rotate(270deg);
|
|
140
176
|
}
|
|
177
|
+
}
|
|
178
|
+
@keyframes scale {
|
|
179
|
+
0% {
|
|
180
|
+
transform: scale(0.5);
|
|
181
|
+
opacity: 0.4;
|
|
182
|
+
}
|
|
183
|
+
100% {
|
|
184
|
+
transform: scale(1);
|
|
185
|
+
opacity: 1;
|
|
186
|
+
}
|
|
141
187
|
}</style>
|
|
@@ -6,6 +6,8 @@ declare const __propDef: {
|
|
|
6
6
|
full?: boolean | undefined;
|
|
7
7
|
padding?: number | "none" | "small" | "medium" | "large" | undefined;
|
|
8
8
|
size?: number | "small" | "medium" | "large" | undefined;
|
|
9
|
+
state?: "none" | "error" | "success" | "loading" | undefined;
|
|
10
|
+
duration?: number | undefined;
|
|
9
11
|
color?: string | undefined;
|
|
10
12
|
colorTrack?: string | undefined;
|
|
11
13
|
invert?: boolean | undefined;
|