Skip to content

Commit 10ce21f

Browse files
committed
refactor(ui-toolkit): replace VProgressCircular with JProgressCircular
Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
1 parent c0da2eb commit 10ce21f

File tree

12 files changed

+93
-61
lines changed

12 files changed

+93
-61
lines changed

frontend/src/components/Item/Card/GenericItemCard.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
<JSlot class="align-center card-content uno-h-full uno-w-full uno-flex uno-justify-center !uno-m-0">
1717
<slot name="image" />
1818
</JSlot>
19-
<JSlot class="align-center card-upper-content uno-flex uno-justify-center">
20-
<slot name="upper-content" />
21-
</JSlot>
19+
<JOverlay
20+
v-if="$slots['upper-content']"
21+
class="uno-top-0 uno-p-2">
22+
<span class="uno-flex uno-items-center">
23+
<slot name="upper-content" />
24+
</span>
25+
</JOverlay>
2226
<JOverlay
2327
v-if="overlay && hasFinePointer"
2428
hover

frontend/src/components/Item/Card/ItemCard.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
:type="getImageType" />
1313
</template>
1414
<template #upper-content>
15-
<VProgressCircular
15+
<JProgressCircular
1616
v-if="!isNil(refreshProgress)"
17-
:model-value="refreshProgress"
18-
:indeterminate="refreshProgress === 0"
19-
size="24" />
17+
:value="refreshProgress"
18+
:indeterminate="refreshProgress === 0" />
2019
<WatchedIndicator v-if="item.UserData && item.UserData.Played" />
2120
<VChip
2221
v-if="item.UserData && item.UserData.UnplayedItemCount"

frontend/src/components/Item/Metadata/ImageSearch.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@
4141
hide-details />
4242
</VRow>
4343
<VDivider />
44-
<VProgressCircular
44+
<JProgressCircular
4545
v-if="loading"
46-
:size="70"
47-
:width="7"
48-
color="primary"
4946
indeterminate
5047
class="loading-bar" />
5148
<VCard

frontend/src/components/Layout/AppBar/Buttons/TaskManagerButton.vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<template #icon>
66
<JProgressCircular
77
v-if="!buttonColor"
8-
class="uno-h-6 uno-w-6"
8+
class="uno-w-full"
99
indeterminate />
1010
<JIcon
1111
v-else
@@ -24,14 +24,16 @@
2424
:key="`${task.id}`"
2525
:title="task.text">
2626
<template #append>
27-
<VProgressCircular
28-
v-if="task.progress !== 100"
29-
:indeterminate="!!task.progress"
30-
:model-value="task.progress"
31-
size="24" />
32-
<JIcon
33-
v-else
34-
class="i-mdi:check" />
27+
<VListItemAction>
28+
<JProgressCircular
29+
v-if="task.progress !== 100"
30+
class="uno-w-15"
31+
:indeterminate="!!task.progress"
32+
:value="task.progress" />
33+
<JIcon
34+
v-else
35+
class="i-mdi:check" />
36+
</VListItemAction>
3537
</template>
3638
</VListItem>
3739
</VList>
@@ -47,6 +49,7 @@
4749
<script setup lang="ts">
4850
import { computed, ref, watch } from 'vue';
4951
import { useI18n } from 'vue-i18n';
52+
import { VListItemAction } from 'vuetify/components';
5053
import { taskManager, TaskType } from '#/store/task-manager';
5154
5255
interface TaskInfo {

frontend/src/components/Layout/Images/UserImage.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
:size="size">
44
<JImg
55
:src="url"
6-
:alt="$t('userImage')"
7-
:transition-props="{
8-
mode: 'out-in'
9-
}">
6+
:alt="$t('userImage')">
107
<template #placeholder>
118
<VAvatar
129
color="primary"

frontend/src/components/Layout/Splashscreen.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
name="slide-y-reverse"
1111
appear>
1212
<div class="uno-fixed uno-bottom-25 uno-w-full uno-flex uno-flex-col uno-items-center uno-gap-5">
13-
<JProgressCircular indeterminate />
13+
<JProgressCircular
14+
class="uno-w-20"
15+
indeterminate />
1416
<VBtn
1517
v-if="remote.auth.currentUser.value"
1618
@click="remote.auth.logoutCurrentUser">

frontend/src/pages/library/[itemId].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<JProgressCircular
1616
v-else-if="loading"
1717
indeterminate
18-
class="uno-h-4 uno-w-4" />
18+
class="uno-h-full" />
1919
<template v-else>
2020
{{ items.length ?? 0 }}
2121
</template>

frontend/types/global/components.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ declare module 'vue' {
138138
VMenu: typeof import('vuetify/components')['VMenu']
139139
VNavigationDrawer: typeof import('vuetify/components')['VNavigationDrawer']
140140
VolumeSlider: typeof import('./../../src/components/Layout/VolumeSlider.vue')['default']
141-
VProgressCircular: typeof import('vuetify/components')['VProgressCircular']
142141
VProgressLinear: typeof import('vuetify/components')['VProgressLinear']
143142
VResponsive: typeof import('vuetify/components')['VResponsive']
144143
VRow: typeof import('vuetify/components')['VRow']

packages/ui-toolkit/src/components/JImg.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@load.passive="onLoad"
99
@error.passive="onError">
1010
<JTransition
11+
mode="out-in"
1112
v-bind="isObj(transitionProps) ? transitionProps : undefined"
1213
:disabled="!transitionProps">
1314
<img
@@ -24,7 +25,9 @@
2425
<slot
2526
v-else-if="loading"
2627
name="loading">
27-
<JProgressCircular indeterminate />
28+
<JProgressCircular
29+
class="uno-w-full uno-h-full uno-flex uno-items-center uno-justify-center"
30+
indeterminate />
2831
</slot>
2932
<slot
3033
v-else-if="error"
Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,94 @@
11
<template>
22
<svg
3-
xmlns="http://www.w3.org/2000/svg"
3+
class="uno-object-contain uno-aspect-square uno-w-15"
44
:class="{
55
'j-progress-circular--indeterminate': indeterminate,
66
}"
7+
:style="{
8+
'--j-progresscircular-radius': toPx(MAGIC_RADIUS_CONSTANT),
9+
transform: `rotate(-90deg)`
10+
}"
11+
preserveAspectRatio="xMidYMid meet"
12+
viewBox="0 0 100 100"
713
role="progressbar"
814
aria-valuemin="0"
915
aria-valuemax="100"
10-
:aria-valuenow="indeterminate || !model ? undefined : Math.max(0, Math.min(model, 100))">
16+
:aria-valuenow="indeterminate ? undefined : normalizedValue"
17+
:aria-valuetext="indeterminate ? 'Cargando...' : `${normalizedValue}% completado`"
18+
v-bind="getBaseProps($attrs, false)">
1119
<circle
12-
class="j-progress-circular__underlay"
20+
class="j-progress-circular--underlay uno-stroke-current uno-z-1"
1321
fill="transparent"
1422
cx="50%"
1523
cy="50%"
1624
:r="MAGIC_RADIUS_CONSTANT"
1725
:stroke-width
1826
:stroke-dasharray="CIRCUMFERENCE"
1927
stroke-dashoffset="0" />
28+
<text
29+
v-if="$slots.default || (innerProgress && !indeterminate)"
30+
x="50%"
31+
y="50%"
32+
class="uno-fill-current j-progress-circular--text"
33+
dominant-baseline="middle"
34+
text-anchor="middle">
35+
<template v-if="$slots.default">
36+
<slot />
37+
</template>
38+
<template v-else>
39+
{{ normalizedValue }}%
40+
</template>
41+
</text>
2042
<circle
21-
class="j-progress-circular--overlay"
43+
class="j-progress-circular--overlay uno-transform-origin-center uno-stroke-current uno-stroke-cap-round uno-z-2"
2244
fill="transparent"
2345
cx="50%"
2446
cy="50%"
2547
:r="MAGIC_RADIUS_CONSTANT"
2648
:stroke-width
2749
:stroke-dasharray="CIRCUMFERENCE"
28-
:stroke-dashoffset="`${CIRCUMFERENCE}px`" />
50+
:stroke-dashoffset />
2951
</svg>
3052
</template>
3153

54+
<script lang="ts">
55+
// Changing this value will change the proportions of the circle accordingly
56+
const MAGIC_RADIUS_CONSTANT = 18;
57+
const strokeWidth = MAGIC_RADIUS_CONSTANT * 0.3;
58+
const CIRCUMFERENCE = 2 * Math.PI * MAGIC_RADIUS_CONSTANT;
59+
</script>
60+
3261
<script setup lang="ts">
33-
const { indeterminate } = defineProps<{
62+
import { computed } from 'vue';
63+
import { clamp, toPx } from '#/util/helpers';
64+
import { getBaseProps } from '#/util/props';
65+
66+
const { indeterminate, innerProgress, value = 0 } = defineProps<{
3467
indeterminate?: boolean;
68+
/**
69+
* Shows the progress in the inner of the circle
70+
*/
71+
innerProgress?: boolean;
72+
value?: number;
3573
}>();
36-
const model = defineModel<number>();
3774
38-
const strokeWidth = 6;
39-
const MAGIC_RADIUS_CONSTANT = 20;
40-
const CIRCUMFERENCE = 2 * Math.PI * MAGIC_RADIUS_CONSTANT;
75+
const normalizedValue = computed(() => clamp(value, 0, 100));
76+
const strokeDashoffset = computed(() => toPx(CIRCUMFERENCE * (1 - normalizedValue.value / 100)));
4177
</script>
4278

4379
<style scoped>
4480
@keyframes progress-circular-dash {
4581
0% {
46-
stroke-dasharray: 1 200;
82+
stroke-dasharray: calc(var(--j-progresscircular-radius) * 0.05) calc(var(--j-progresscircular-radius) * 10);
4783
stroke-dashoffset: 0;
4884
}
4985
50% {
50-
stroke-dasharray: 100 200;
51-
stroke-dashoffset: -15px;
86+
stroke-dasharray: calc(var(--j-progresscircular-radius) * 5) calc(var(--j-progresscircular-radius) * 10);
87+
stroke-dashoffset: calc(var(--j-progresscircular-radius) * -0.75);
5288
}
5389
to {
54-
stroke-dasharray: 100 200;
55-
stroke-dashoffset: -124px;
90+
stroke-dasharray: calc(var(--j-progresscircular-radius) * 5) calc(var(--j-progresscircular-radius) * 10);
91+
stroke-dashoffset: calc(var(--j-progresscircular-radius) * -6.2);
5692
}
5793
}
5894
@@ -62,26 +98,23 @@ const CIRCUMFERENCE = 2 * Math.PI * MAGIC_RADIUS_CONSTANT;
6298
}
6399
}
64100
101+
.j-progress-circular--text {
102+
font-size: calc(var(--j-progresscircular-radius) * 0.5);
103+
}
104+
65105
.j-progress-circular--overlay {
66-
stroke: currentColor;
67-
z-index: 2;
68106
transition: all 1.4s ease-in-out, stroke-width;
69107
}
70108
71-
.j-progress-circular__underlay {
109+
.j-progress-circular--underlay {
72110
color: rgba(var(--j-border-color), var(--j-border-opacity));
73-
stroke: currentColor;
74-
z-index: 1;
75111
}
76112
77113
.j-progress-circular--indeterminate .j-progress-circular--overlay {
78-
stroke-dasharray: 25 200;
114+
stroke-dasharray: calc(var(--j-progresscircular-radius) * 1.25) calc(var(--j-progresscircular-radius) * 10);
79115
stroke-dashoffset: 0;
80-
stroke-linecap: round;
81-
transform-origin: 50%;
82116
animation: 1.4s ease-in-out infinite progress-circular-dash,
83117
1.4s linear infinite progress-circular-rotate;
84118
transform: rotate(-90deg);
85119
}
86-
87120
</style>

packages/ui-toolkit/src/util/props.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ function hasClickHandler(attrs: Record<string, unknown>) {
1616
/**
1717
* Gets the base props for every component.
1818
*/
19-
export function getBaseProps(attrs: Record<string, unknown>) {
19+
export function getBaseProps(attrs: Record<string, unknown>, ariaHidden = true) {
2020
const hasClick = hasClickHandler(attrs);
2121

2222
return mergeProps(attrs, {
2323
'role': hasClick ? 'button' : undefined,
24-
'aria-hidden': !hasClick,
24+
'aria-hidden': !hasClick && ariaHidden,
2525
'tabindex': hasClick ? 0 : undefined
2626
});
2727
};

packages/ui-toolkit/storybook/stories/JProgressCircular.stories.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ type Story = StoryObj<typeof JProgressCircular>;
1111

1212
export const Default: Story = {
1313
args: {
14-
indeterminate: false
15-
}
16-
};
17-
18-
export const Indeterminate: Story = {
19-
args: {
20-
indeterminate: true
14+
indeterminate: false,
15+
value: 0
2116
}
2217
};

0 commit comments

Comments
 (0)