@redseed/redseed-ui-vue3 1.4.0 → 1.5.0
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.
package/index.js
CHANGED
|
@@ -40,6 +40,7 @@ import MessageBox from './src/components/MessageBox/MessageBox.vue'
|
|
|
40
40
|
import MetaItem from './src/components/PageHeading/MetaItem.vue'
|
|
41
41
|
import Modal from './src/components/Modal/Modal.vue'
|
|
42
42
|
import PageHeading from './src/components/PageHeading/PageHeading.vue'
|
|
43
|
+
import ProgressCircle from './src/components/Progress/ProgressCircle.vue'
|
|
43
44
|
import SignInWithGoogle from './src/components/Social/SignInWithGoogle.vue'
|
|
44
45
|
import SignUpWithGoogle from './src/components/Social/SignUpWithGoogle.vue'
|
|
45
46
|
import TwoColumnLayout from './src/components/TwoColumnLayout/TwoColumnLayout.vue'
|
|
@@ -87,6 +88,7 @@ export {
|
|
|
87
88
|
MetaItem,
|
|
88
89
|
Modal,
|
|
89
90
|
PageHeading,
|
|
91
|
+
ProgressCircle,
|
|
90
92
|
SignInWithGoogle,
|
|
91
93
|
SignUpWithGoogle,
|
|
92
94
|
TwoColumnLayout,
|
package/package.json
CHANGED
|
@@ -147,7 +147,7 @@ const buttonSlotIconClass = computed(() => [
|
|
|
147
147
|
@apply text-xs;
|
|
148
148
|
@apply px-2.5 py-1.5;
|
|
149
149
|
&--icon {
|
|
150
|
-
@apply px-1.5;
|
|
150
|
+
@apply px-1.5 py-1.5;
|
|
151
151
|
}
|
|
152
152
|
.button-slot__icon {
|
|
153
153
|
@apply w-4 h-4;
|
|
@@ -158,7 +158,7 @@ const buttonSlotIconClass = computed(() => [
|
|
|
158
158
|
@apply text-sm;
|
|
159
159
|
@apply px-3 py-2;
|
|
160
160
|
&--icon {
|
|
161
|
-
@apply px-2;
|
|
161
|
+
@apply px-2 py-2;
|
|
162
162
|
}
|
|
163
163
|
.button-slot__icon {
|
|
164
164
|
@apply w-5 h-5;
|
|
@@ -169,13 +169,10 @@ const buttonSlotIconClass = computed(() => [
|
|
|
169
169
|
@apply text-base;
|
|
170
170
|
@apply px-4 py-2;
|
|
171
171
|
&--icon {
|
|
172
|
-
@apply px-2;
|
|
172
|
+
@apply px-2.5 py-2.5;
|
|
173
173
|
}
|
|
174
174
|
.button-slot__icon {
|
|
175
175
|
@apply w-5 h-5;
|
|
176
|
-
&--only {
|
|
177
|
-
@apply w-6 h-6;
|
|
178
|
-
}
|
|
179
176
|
}
|
|
180
177
|
}
|
|
181
178
|
// modifier lg size
|
|
@@ -183,13 +180,10 @@ const buttonSlotIconClass = computed(() => [
|
|
|
183
180
|
@apply text-lg;
|
|
184
181
|
@apply px-4 py-2;
|
|
185
182
|
&--icon {
|
|
186
|
-
@apply px-
|
|
183
|
+
@apply px-3 py-3;
|
|
187
184
|
}
|
|
188
185
|
.button-slot__icon {
|
|
189
186
|
@apply w-5 h-5;
|
|
190
|
-
&--only {
|
|
191
|
-
@apply w-7 h-7;
|
|
192
|
-
}
|
|
193
187
|
}
|
|
194
188
|
}
|
|
195
189
|
// modifier icon at the end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, computed, onMounted, watchPostEffect } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
percentage: {
|
|
6
|
+
type: Number,
|
|
7
|
+
default: 0,
|
|
8
|
+
},
|
|
9
|
+
sm: { // default size
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false,
|
|
12
|
+
},
|
|
13
|
+
md: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: false,
|
|
16
|
+
},
|
|
17
|
+
lg: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// Ensure the percentage is between 0 and 100
|
|
24
|
+
const safePercentage = computed(() => {
|
|
25
|
+
if (props.percentage < 0) return 0
|
|
26
|
+
if (props.percentage > 100) return 100
|
|
27
|
+
|
|
28
|
+
return props.percentage
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// default size of the progress circle
|
|
32
|
+
const defaultSize = computed(() => !props.sm && !props.md && !props.lg)
|
|
33
|
+
|
|
34
|
+
// Class for the progress circle
|
|
35
|
+
const progressCircleClass = computed(() => [
|
|
36
|
+
'progress-circle',
|
|
37
|
+
{
|
|
38
|
+
'progress-circle--sm': props.sm || defaultSize.value,
|
|
39
|
+
'progress-circle--md': props.md,
|
|
40
|
+
'progress-circle--lg': props.lg,
|
|
41
|
+
},
|
|
42
|
+
])
|
|
43
|
+
|
|
44
|
+
// Reference to the progress circle element
|
|
45
|
+
const progressCircle = ref(null)
|
|
46
|
+
|
|
47
|
+
// Set the stroke dash of the progress circle
|
|
48
|
+
function setProgressCircleDash() {
|
|
49
|
+
// Get the radius of the progress circle
|
|
50
|
+
const radius = progressCircle.value.r.baseVal.value
|
|
51
|
+
// Calculate the circumference of the circle
|
|
52
|
+
const circumference = 2 * Math.PI * radius
|
|
53
|
+
// Calculate the offset of the stroke dash
|
|
54
|
+
const offset = circumference * (100 - safePercentage.value) / 100
|
|
55
|
+
|
|
56
|
+
// Set the stroke dash of the progress circle
|
|
57
|
+
progressCircle.value.style.strokeDasharray = `${circumference}`
|
|
58
|
+
// Set the stroke dash offset of the progress circle
|
|
59
|
+
progressCircle.value.style.strokeDashoffset = `${offset}`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Watch for changes in the percentage prop
|
|
63
|
+
watchPostEffect(setProgressCircleDash)
|
|
64
|
+
</script>
|
|
65
|
+
<template>
|
|
66
|
+
<div :class="progressCircleClass">
|
|
67
|
+
<svg viewBox="0 0 100 100">
|
|
68
|
+
<circle cx="50" cy="50" r="48"
|
|
69
|
+
class="progress-circle__background-circle"
|
|
70
|
+
></circle>
|
|
71
|
+
<circle cx="50" cy="50" r="48"
|
|
72
|
+
ref="progressCircle"
|
|
73
|
+
class="progress-circle__progress-circle"
|
|
74
|
+
></circle>
|
|
75
|
+
</svg>
|
|
76
|
+
<div class="progress-circle__content">
|
|
77
|
+
<slot></slot>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
<style lang="scss" scoped>
|
|
82
|
+
.progress-circle {
|
|
83
|
+
@apply relative;
|
|
84
|
+
&--sm {
|
|
85
|
+
@apply size-16 text-xs;
|
|
86
|
+
}
|
|
87
|
+
&--md {
|
|
88
|
+
@apply size-20 text-sm;
|
|
89
|
+
}
|
|
90
|
+
&--lg {
|
|
91
|
+
@apply size-24 text-base;
|
|
92
|
+
}
|
|
93
|
+
svg {
|
|
94
|
+
@apply w-full h-full -rotate-90 transition-all;
|
|
95
|
+
circle {
|
|
96
|
+
stroke-linecap: round;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
&__background-circle {
|
|
100
|
+
@apply stroke-gray-300 stroke-4 fill-none transition-all;
|
|
101
|
+
}
|
|
102
|
+
&__progress-circle {
|
|
103
|
+
@apply stroke-primary stroke-4 fill-none transition-all duration-0;
|
|
104
|
+
}
|
|
105
|
+
&__content {
|
|
106
|
+
@apply absolute inset-0 w-full h-full flex items-center justify-center;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
</style>
|