@youcan/celeste 0.6.32 → 0.6.33
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/dist/celeste.css +96 -1
- package/dist/cjs/chunks/index.js +95 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/progress-bar.js +84 -0
- package/dist/cjs/progress-circle.js +92 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/progress/index.d.ts +4 -0
- package/dist/components/progress/progress-bar.d.ts +31 -0
- package/dist/components/progress/progress-circle.d.ts +27 -0
- package/dist/es/chunks/index.js +110 -15
- package/dist/es/index.js +6 -0
- package/dist/es/progress-bar.js +85 -0
- package/dist/es/progress-circle.js +93 -0
- package/dist/es/select-content.js +1 -1
- package/dist/es/select-item.js +1 -1
- package/dist/es/select-trigger.js +1 -1
- package/dist/es/select-value.js +1 -1
- package/dist/es/tooltip.js +1 -1
- package/package.json +3 -3
- package/src/components/dropdown-menu/dropdown-menu-content.vue +2 -1
- package/src/components/index.ts +1 -0
- package/src/components/progress/index.ts +5 -0
- package/src/components/progress/progress-bar.vue +167 -0
- package/src/components/progress/progress-circle.vue +126 -0
- package/src/components/progress/stories/progress-bar.stories.ts +328 -0
- package/src/components/progress/stories/progress-circular.stories.ts +152 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { defineComponent, useCssVars, computed, openBlock, createElementBlock, toDisplayString, createCommentVNode, createElementVNode, renderSlot, createTextVNode, createVNode, unref, mergeProps, withCtx } from "vue";
|
|
2
|
+
import { useDelegatedProps } from "./use-delegated-props.js";
|
|
3
|
+
import { c as clsx } from "./chunks/clsx.js";
|
|
4
|
+
import { ak as By, al as Iy } from "./chunks/index.js";
|
|
5
|
+
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
6
|
+
const _hoisted_1 = ["data-layout"];
|
|
7
|
+
const _hoisted_2 = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "celeste-progress-bar-label"
|
|
10
|
+
};
|
|
11
|
+
const _hoisted_3 = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "celeste-progress-bar-label-title"
|
|
14
|
+
};
|
|
15
|
+
const _hoisted_4 = { class: "celeste-progress-bar-label" };
|
|
16
|
+
const _hoisted_5 = {
|
|
17
|
+
key: 1,
|
|
18
|
+
class: "celeste-progress-bar-description"
|
|
19
|
+
};
|
|
20
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
21
|
+
__name: "progress-bar",
|
|
22
|
+
props: {
|
|
23
|
+
modelValue: { default: 0 },
|
|
24
|
+
max: { default: 100 },
|
|
25
|
+
getValueLabel: {},
|
|
26
|
+
asChild: { type: Boolean },
|
|
27
|
+
as: {},
|
|
28
|
+
class: {},
|
|
29
|
+
color: { default: "primary" },
|
|
30
|
+
title: {},
|
|
31
|
+
layout: { default: "bare" }
|
|
32
|
+
},
|
|
33
|
+
setup(__props) {
|
|
34
|
+
useCssVars((_ctx) => ({
|
|
35
|
+
"6ba22aeb": progressIndicator.value
|
|
36
|
+
}));
|
|
37
|
+
const props = __props;
|
|
38
|
+
const delegatedProps = useDelegatedProps(props, "class");
|
|
39
|
+
const progress = computed(() => {
|
|
40
|
+
if (props.max === 0)
|
|
41
|
+
return 0;
|
|
42
|
+
const value = Math.min(Math.max(props.modelValue ?? 0, 0), props.max);
|
|
43
|
+
return Math.round(value / props.max * 100);
|
|
44
|
+
});
|
|
45
|
+
const progressIndicator = computed(() => {
|
|
46
|
+
return 100 - (props.modelValue ?? 0) / props.max * 100;
|
|
47
|
+
});
|
|
48
|
+
return (_ctx, _cache) => {
|
|
49
|
+
return openBlock(), createElementBlock("div", {
|
|
50
|
+
class: "celeste-progress-bar-wrapper",
|
|
51
|
+
"data-layout": _ctx.layout
|
|
52
|
+
}, [
|
|
53
|
+
_ctx.layout !== "bare" ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
54
|
+
props.title && _ctx.layout !== "inline" ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(_ctx.title), 1)) : createCommentVNode("", true),
|
|
55
|
+
createElementVNode("span", _hoisted_4, [
|
|
56
|
+
renderSlot(_ctx.$slots, "label", {}, () => [
|
|
57
|
+
createTextVNode(toDisplayString(progress.value) + "% ", 1)
|
|
58
|
+
], true)
|
|
59
|
+
])
|
|
60
|
+
])) : createCommentVNode("", true),
|
|
61
|
+
createVNode(unref(By), mergeProps(unref(delegatedProps), {
|
|
62
|
+
class: unref(clsx)(
|
|
63
|
+
"celeste-progress-bar",
|
|
64
|
+
props.class
|
|
65
|
+
)
|
|
66
|
+
}), {
|
|
67
|
+
default: withCtx(() => [
|
|
68
|
+
createVNode(unref(Iy), {
|
|
69
|
+
class: "celeste-progress-bar-indicator",
|
|
70
|
+
"data-color": _ctx.color
|
|
71
|
+
}, null, 8, ["data-color"])
|
|
72
|
+
]),
|
|
73
|
+
_: 1
|
|
74
|
+
}, 16, ["class"]),
|
|
75
|
+
_ctx.$slots.description && _ctx.layout === "default" ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
76
|
+
renderSlot(_ctx.$slots, "description", {}, void 0, true)
|
|
77
|
+
])) : createCommentVNode("", true)
|
|
78
|
+
], 8, _hoisted_1);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const progressBar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-850aadb2"]]);
|
|
83
|
+
export {
|
|
84
|
+
progressBar as default
|
|
85
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { defineComponent, useCssVars, computed, openBlock, createBlock, unref, mergeProps, withCtx, createVNode, createElementBlock, createElementVNode, renderSlot, createTextVNode, toDisplayString, createCommentVNode } from "vue";
|
|
2
|
+
import { useDelegatedProps } from "./use-delegated-props.js";
|
|
3
|
+
import { c as clsx } from "./chunks/clsx.js";
|
|
4
|
+
import { ak as By, al as Iy } from "./chunks/index.js";
|
|
5
|
+
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
6
|
+
const _hoisted_1 = ["width", "height"];
|
|
7
|
+
const _hoisted_2 = ["cx", "cy", "r"];
|
|
8
|
+
const _hoisted_3 = ["cx", "cy", "r", "stroke-dasharray", "stroke-dashoffset"];
|
|
9
|
+
const _hoisted_4 = {
|
|
10
|
+
key: 0,
|
|
11
|
+
class: "celeste-progress-circle-label"
|
|
12
|
+
};
|
|
13
|
+
const STROKE_WIDTH = 6.4;
|
|
14
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
15
|
+
__name: "progress-circle",
|
|
16
|
+
props: {
|
|
17
|
+
modelValue: { default: 0 },
|
|
18
|
+
max: { default: 100 },
|
|
19
|
+
getValueLabel: {},
|
|
20
|
+
asChild: { type: Boolean },
|
|
21
|
+
as: {},
|
|
22
|
+
class: {},
|
|
23
|
+
size: { default: 80 }
|
|
24
|
+
},
|
|
25
|
+
setup(__props) {
|
|
26
|
+
useCssVars((_ctx) => ({
|
|
27
|
+
"433ff7ca": circleSize.value
|
|
28
|
+
}));
|
|
29
|
+
const props = __props;
|
|
30
|
+
const delegatedProps = useDelegatedProps(props, "class");
|
|
31
|
+
const radius = computed(() => (props.size - STROKE_WIDTH) / 2);
|
|
32
|
+
const circumference = computed(() => 2 * Math.PI * radius.value);
|
|
33
|
+
const progress = computed(() => {
|
|
34
|
+
if (props.max === 0)
|
|
35
|
+
return 0;
|
|
36
|
+
const value = Math.min(Math.max(props.modelValue ?? 0, 0), props.max);
|
|
37
|
+
return Math.round(value / props.max * 100);
|
|
38
|
+
});
|
|
39
|
+
const offset = computed(() => {
|
|
40
|
+
return circumference.value * (1 - progress.value / 100);
|
|
41
|
+
});
|
|
42
|
+
const circleSize = computed(() => `${props.size}px`);
|
|
43
|
+
return (_ctx, _cache) => {
|
|
44
|
+
return openBlock(), createBlock(unref(By), mergeProps(unref(delegatedProps), {
|
|
45
|
+
value: props.modelValue,
|
|
46
|
+
class: unref(clsx)("celeste-progress-circle", props.class),
|
|
47
|
+
as: "div"
|
|
48
|
+
}), {
|
|
49
|
+
default: withCtx(() => [
|
|
50
|
+
createVNode(unref(Iy), { "as-child": "" }, {
|
|
51
|
+
default: withCtx(() => [
|
|
52
|
+
(openBlock(), createElementBlock("svg", {
|
|
53
|
+
class: "celeste-progress-circle-svg",
|
|
54
|
+
width: props.size,
|
|
55
|
+
height: props.size
|
|
56
|
+
}, [
|
|
57
|
+
createElementVNode("circle", {
|
|
58
|
+
class: "celeste-progress-circle-track",
|
|
59
|
+
cx: props.size / 2,
|
|
60
|
+
cy: props.size / 2,
|
|
61
|
+
r: radius.value,
|
|
62
|
+
"stroke-width": STROKE_WIDTH,
|
|
63
|
+
fill: "transparent"
|
|
64
|
+
}, null, 8, _hoisted_2),
|
|
65
|
+
createElementVNode("circle", {
|
|
66
|
+
class: "celeste-progress-circle-indicator",
|
|
67
|
+
cx: props.size / 2,
|
|
68
|
+
cy: props.size / 2,
|
|
69
|
+
r: radius.value,
|
|
70
|
+
"stroke-width": STROKE_WIDTH,
|
|
71
|
+
fill: "transparent",
|
|
72
|
+
"stroke-dasharray": circumference.value,
|
|
73
|
+
"stroke-dashoffset": offset.value
|
|
74
|
+
}, null, 8, _hoisted_3)
|
|
75
|
+
], 8, _hoisted_1))
|
|
76
|
+
]),
|
|
77
|
+
_: 1
|
|
78
|
+
}),
|
|
79
|
+
props.size !== 48 ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
80
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
81
|
+
createTextVNode(toDisplayString(progress.value) + "% ", 1)
|
|
82
|
+
], true)
|
|
83
|
+
])) : createCommentVNode("", true)
|
|
84
|
+
]),
|
|
85
|
+
_: 3
|
|
86
|
+
}, 16, ["value", "class"]);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const progressCircle = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f8ba36bb"]]);
|
|
91
|
+
export {
|
|
92
|
+
progressCircle as default
|
|
93
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, mergeProps, renderSlot } from "vue";
|
|
2
2
|
import { useDelegatedProps } from "./use-delegated-props.js";
|
|
3
3
|
import { c as clsx } from "./chunks/clsx.js";
|
|
4
|
-
import { x as xe,
|
|
4
|
+
import { x as xe, am as zy, an as Ky, ao as Xy } from "./chunks/index.js";
|
|
5
5
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
6
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
7
|
__name: "select-content",
|
package/dist/es/select-item.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, createVNode, renderSlot, createElementVNode } from "vue";
|
|
2
2
|
import { useDelegatedProps } from "./use-delegated-props.js";
|
|
3
3
|
import { c as clsx } from "./chunks/clsx.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ap as jy, aq as Yy, ar as Uy } from "./chunks/index.js";
|
|
5
5
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
6
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
7
|
__name: "select-item",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot, createVNode, createElementVNode } from "vue";
|
|
2
2
|
import { useDelegatedProps } from "./use-delegated-props.js";
|
|
3
3
|
import { c as clsx } from "./chunks/clsx.js";
|
|
4
|
-
import {
|
|
4
|
+
import { as as Ly, at as eg } from "./chunks/index.js";
|
|
5
5
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
6
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
7
|
__name: "select-trigger",
|
package/dist/es/select-value.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
|
|
2
2
|
import { useDelegatedProps } from "./use-delegated-props.js";
|
|
3
3
|
import { c as clsx } from "./chunks/clsx.js";
|
|
4
|
-
import {
|
|
4
|
+
import { au as Qy } from "./chunks/index.js";
|
|
5
5
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
6
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
7
|
__name: "select-value",
|
package/dist/es/tooltip.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, ref, openBlock, createBlock, unref, withCtx, createVNode, mergeProps, renderSlot, createElementBlock, normalizeClass, createCommentVNode, createElementVNode, toDisplayString } from "vue";
|
|
2
2
|
import CompactButton from "./compact-button.js";
|
|
3
3
|
import { c as clsx } from "./chunks/clsx.js";
|
|
4
|
-
import { x as xe,
|
|
4
|
+
import { x as xe, av as Lg, aw as zg, ax as Kg, ay as jg, az as Hg, aA as Wg } from "./chunks/index.js";
|
|
5
5
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
6
6
|
const _hoisted_1 = { class: "celeste-tooltip-content-box" };
|
|
7
7
|
const _hoisted_2 = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youcan/celeste",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.33",
|
|
5
5
|
"author": "YouCan <tech@youcan.shop>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"youcan",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"radix-vue": "^1.9.12",
|
|
44
44
|
"tinycolor2": "^1.6.0",
|
|
45
45
|
"vue-sonner": "^2.0.2",
|
|
46
|
-
"@youcan/celeste-icons": "0.6.
|
|
47
|
-
"@youcan/celeste-tokens": "0.6.
|
|
46
|
+
"@youcan/celeste-icons": "0.6.33",
|
|
47
|
+
"@youcan/celeste-tokens": "0.6.33"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@chromatic-com/storybook": "^4.0.0",
|
|
@@ -41,6 +41,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
41
41
|
--dropdown-max-width: 350px;
|
|
42
42
|
|
|
43
43
|
display: flex;
|
|
44
|
+
z-index: 50;
|
|
44
45
|
box-sizing: border-box;
|
|
45
46
|
flex-direction: column;
|
|
46
47
|
width: var(--dropdown-width);
|
|
@@ -52,11 +53,11 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
52
53
|
transition-property: display, transform, opacity;
|
|
53
54
|
transition-duration: var(--animation-fast);
|
|
54
55
|
transition-timing-function: ease-out;
|
|
55
|
-
transition-behavior: allow-discrete;
|
|
56
56
|
border: 1px solid var(--color-stroke-soft-200);
|
|
57
57
|
border-radius: var(--radius-16);
|
|
58
58
|
background-color: var(--color-bg-white-0);
|
|
59
59
|
box-shadow: var(--shadow-regular-md);
|
|
60
|
+
transition-behavior: allow-discrete;
|
|
60
61
|
gap: var(--spacing-4);
|
|
61
62
|
|
|
62
63
|
&[data-state='closed'] {
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useDelegatedProps } from '@/composables/use-delegated-props';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import {
|
|
5
|
+
ProgressIndicator,
|
|
6
|
+
ProgressRoot,
|
|
7
|
+
type ProgressRootProps,
|
|
8
|
+
} from 'radix-vue';
|
|
9
|
+
import { computed, type HTMLAttributes } from 'vue';
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(
|
|
12
|
+
defineProps<
|
|
13
|
+
ProgressRootProps & {
|
|
14
|
+
class?: HTMLAttributes['class'];
|
|
15
|
+
color?: 'blue' | 'red' | 'orange' | 'green' | 'primary';
|
|
16
|
+
title?: string;
|
|
17
|
+
layout?: 'default' | 'no-description' | 'inline' | 'bare';
|
|
18
|
+
}
|
|
19
|
+
>(),
|
|
20
|
+
{
|
|
21
|
+
modelValue: 0,
|
|
22
|
+
color: 'primary',
|
|
23
|
+
layout: 'bare',
|
|
24
|
+
max: 100,
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const delegatedProps = useDelegatedProps(props, 'class');
|
|
29
|
+
|
|
30
|
+
const progress = computed(() => {
|
|
31
|
+
if (props.max === 0)
|
|
32
|
+
return 0;
|
|
33
|
+
|
|
34
|
+
const value = Math.min(Math.max(props.modelValue ?? 0, 0), props.max);
|
|
35
|
+
|
|
36
|
+
return Math.round((value / props.max) * 100);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const progressIndicator = computed(() => {
|
|
40
|
+
return 100 - (props.modelValue ?? 0) / props.max * 100;
|
|
41
|
+
});
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<div class="celeste-progress-bar-wrapper" :data-layout="layout">
|
|
46
|
+
<div v-if="layout !== 'bare'" class="celeste-progress-bar-label">
|
|
47
|
+
<span
|
|
48
|
+
v-if="props.title && layout !== 'inline'"
|
|
49
|
+
class="celeste-progress-bar-label-title"
|
|
50
|
+
>
|
|
51
|
+
{{ title }}
|
|
52
|
+
</span>
|
|
53
|
+
<span
|
|
54
|
+
class="celeste-progress-bar-label"
|
|
55
|
+
>
|
|
56
|
+
<slot name="label">
|
|
57
|
+
{{ progress }}%
|
|
58
|
+
</slot>
|
|
59
|
+
</span>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<ProgressRoot
|
|
63
|
+
v-bind="delegatedProps"
|
|
64
|
+
:class="
|
|
65
|
+
clsx(
|
|
66
|
+
'celeste-progress-bar',
|
|
67
|
+
props.class,
|
|
68
|
+
)
|
|
69
|
+
"
|
|
70
|
+
>
|
|
71
|
+
<ProgressIndicator
|
|
72
|
+
class="celeste-progress-bar-indicator"
|
|
73
|
+
:data-color="color"
|
|
74
|
+
/>
|
|
75
|
+
</ProgressRoot>
|
|
76
|
+
|
|
77
|
+
<div v-if="$slots.description && layout === 'default'" class="celeste-progress-bar-description">
|
|
78
|
+
<slot name="description" />
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<style lang="scss" scoped>
|
|
84
|
+
.celeste-progress-bar-wrapper {
|
|
85
|
+
--bar-height: 6px;
|
|
86
|
+
|
|
87
|
+
display: flex;
|
|
88
|
+
width: 100%;
|
|
89
|
+
gap: var(--spacing-6);
|
|
90
|
+
|
|
91
|
+
.celeste-progress-bar {
|
|
92
|
+
height: var(--bar-height);
|
|
93
|
+
overflow: hidden;
|
|
94
|
+
border-radius: var(--radius-full);
|
|
95
|
+
background: var(--color-bg-soft-200);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.celeste-progress-bar-indicator {
|
|
99
|
+
--progress: v-bind('progressIndicator');
|
|
100
|
+
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: 100%;
|
|
103
|
+
transform: translateX(calc(var(--progress) * -1%));
|
|
104
|
+
border-radius: var(--radius-full);
|
|
105
|
+
background: var(--color-primary-base);
|
|
106
|
+
|
|
107
|
+
:dir(rtl) & {
|
|
108
|
+
transform: translateX(calc(var(--progress) * 1%));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&[data-color='orange'] {
|
|
112
|
+
background: var(--color-state-warning-base);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&[data-color='red'] {
|
|
116
|
+
background: var(--color-state-error-base);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&[data-color='blue'] {
|
|
120
|
+
background: var(--color-state-information-base);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&[data-color='green'] {
|
|
124
|
+
background: var(--color-state-success-base);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.celeste-progress-bar-label {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: space-between;
|
|
132
|
+
gap: var(--spacing-6);
|
|
133
|
+
color: var(--color-text-sub-600);
|
|
134
|
+
font: var(--paragraph-sm);
|
|
135
|
+
|
|
136
|
+
&.celeste-progress-bar-title {
|
|
137
|
+
color: var(--color-text-strong-950);
|
|
138
|
+
font: var(--label-sm);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.celeste-progress-bar-description {
|
|
143
|
+
color: var(--color-text-sub-600);
|
|
144
|
+
font: var(--paragraph-xs);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&[data-layout='default'],
|
|
148
|
+
&[data-layout='no-description'] {
|
|
149
|
+
flex-direction: column;
|
|
150
|
+
|
|
151
|
+
&:deep(.celeste-progress-bar) {
|
|
152
|
+
width: 100%;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&[data-layout='inline'],
|
|
157
|
+
&[data-layout='bare'] {
|
|
158
|
+
flex-direction: row-reverse;
|
|
159
|
+
align-items: center;
|
|
160
|
+
gap: var(--spacing-8);
|
|
161
|
+
|
|
162
|
+
&:deep(.celeste-progress-bar) {
|
|
163
|
+
flex: 1;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
</style>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { useDelegatedProps } from '@/composables/use-delegated-props';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import {
|
|
6
|
+
ProgressIndicator,
|
|
7
|
+
ProgressRoot,
|
|
8
|
+
type ProgressRootProps,
|
|
9
|
+
} from 'radix-vue';
|
|
10
|
+
import { computed } from 'vue';
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(
|
|
13
|
+
defineProps<
|
|
14
|
+
ProgressRootProps & {
|
|
15
|
+
class?: HTMLAttributes['class'];
|
|
16
|
+
size?: 80 | 72 | 64 | 56 | 48;
|
|
17
|
+
}
|
|
18
|
+
>(),
|
|
19
|
+
{
|
|
20
|
+
modelValue: 0,
|
|
21
|
+
size: 80,
|
|
22
|
+
max: 100,
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const delegatedProps = useDelegatedProps(props, 'class');
|
|
27
|
+
|
|
28
|
+
const STROKE_WIDTH = 6.4;
|
|
29
|
+
const radius = computed(() => (props.size - STROKE_WIDTH) / 2);
|
|
30
|
+
const circumference = computed(() => 2 * Math.PI * radius.value);
|
|
31
|
+
|
|
32
|
+
const progress = computed(() => {
|
|
33
|
+
if (props.max === 0)
|
|
34
|
+
return 0;
|
|
35
|
+
|
|
36
|
+
const value = Math.min(Math.max(props.modelValue ?? 0, 0), props.max);
|
|
37
|
+
|
|
38
|
+
return Math.round((value / props.max) * 100);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const offset = computed(() => {
|
|
42
|
+
return circumference.value * (1 - progress.value / 100);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const circleSize = computed(() => `${props.size}px`);
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<ProgressRoot
|
|
50
|
+
v-bind="delegatedProps"
|
|
51
|
+
:value="props.modelValue"
|
|
52
|
+
:class="clsx('celeste-progress-circle', props.class)"
|
|
53
|
+
as="div"
|
|
54
|
+
>
|
|
55
|
+
<ProgressIndicator as-child>
|
|
56
|
+
<svg
|
|
57
|
+
class="celeste-progress-circle-svg"
|
|
58
|
+
:width="props.size"
|
|
59
|
+
:height="props.size"
|
|
60
|
+
>
|
|
61
|
+
<circle
|
|
62
|
+
class="celeste-progress-circle-track"
|
|
63
|
+
:cx="props.size / 2"
|
|
64
|
+
:cy="props.size / 2"
|
|
65
|
+
:r="radius"
|
|
66
|
+
:stroke-width="STROKE_WIDTH"
|
|
67
|
+
fill="transparent"
|
|
68
|
+
/>
|
|
69
|
+
<circle
|
|
70
|
+
class="celeste-progress-circle-indicator"
|
|
71
|
+
:cx="props.size / 2"
|
|
72
|
+
:cy="props.size / 2"
|
|
73
|
+
:r="radius"
|
|
74
|
+
:stroke-width="STROKE_WIDTH"
|
|
75
|
+
fill="transparent"
|
|
76
|
+
:stroke-dasharray="circumference"
|
|
77
|
+
:stroke-dashoffset="offset"
|
|
78
|
+
/>
|
|
79
|
+
</svg>
|
|
80
|
+
</ProgressIndicator>
|
|
81
|
+
<div
|
|
82
|
+
v-if="props.size !== 48"
|
|
83
|
+
class="celeste-progress-circle-label"
|
|
84
|
+
>
|
|
85
|
+
<slot>
|
|
86
|
+
{{ progress }}%
|
|
87
|
+
</slot>
|
|
88
|
+
</div>
|
|
89
|
+
</ProgressRoot>
|
|
90
|
+
</template>
|
|
91
|
+
|
|
92
|
+
<style scoped lang="scss">
|
|
93
|
+
.celeste-progress-circle {
|
|
94
|
+
display: inline-flex;
|
|
95
|
+
position: relative;
|
|
96
|
+
align-items: center;
|
|
97
|
+
justify-content: center;
|
|
98
|
+
width: v-bind('circleSize');
|
|
99
|
+
height: v-bind('circleSize');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.celeste-progress-circle-svg {
|
|
103
|
+
transform: rotate(-90deg);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.celeste-progress-circle-track {
|
|
107
|
+
stroke: var(--color-bg-soft-200);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.celeste-progress-circle-indicator {
|
|
111
|
+
transition: stroke-dashoffset 0.3s ease;
|
|
112
|
+
stroke: var(--color-primary-base);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.celeste-progress-circle-label {
|
|
116
|
+
position: absolute;
|
|
117
|
+
top: 50%;
|
|
118
|
+
left: 50%;
|
|
119
|
+
transform: translate(-50%, -50%);
|
|
120
|
+
color: var(--color-text-strong-950);
|
|
121
|
+
font: var(--label-sm);
|
|
122
|
+
text-align: center;
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
user-select: none;
|
|
125
|
+
}
|
|
126
|
+
</style>
|