Skip to content

Commit b844bec

Browse files
committed
refactoring
1 parent faf8cc7 commit b844bec

13 files changed

+50
-61
lines changed

src/App.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import LayoutStack from '@/components/LayoutStack.vue';
44
import TheControls from '@/components/TheControls.vue';
55
import TheCycle from '@/components/TheCycle.vue';
66
import TheCycleEdit from '@/components/TheCycleEdit.vue';
7-
import TheNotificationBar from '@/components/TheNotificationBar.vue';
87
import BaseToast from '@/components/BaseToast.vue';
98
import BaseButton from '@/components/BaseButton.vue';
109
import TheGraphicTimer from '@/components/TheGraphicTimer.vue';
@@ -98,7 +97,7 @@ onBeforeUnmount(() => tickWorker.postMessage({ type: 'stop' }));
9897

9998
<template>
10099
<TheGraphicTimer v-if="cycle.currentInterval" />
101-
<TheNotificationBar>
100+
<div class="fixed inset-x-0 top-0 divide-y divide-blue-100" role="status">
102101
<TransitionFadeSlide>
103102
<BaseToast
104103
v-if="notifyBarVisible"
@@ -121,7 +120,7 @@ onBeforeUnmount(() => tickWorker.postMessage({ type: 'stop' }));
121120
</BaseButton>
122121
</BaseToast>
123122
</TransitionFadeSlide>
124-
</TheNotificationBar>
123+
</div>
125124
<main
126125
class="container mx-auto flex min-h-screen flex-col items-center justify-center px-4 py-4 sm:px-8"
127126
>

src/components/BaseButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defineSlots<{ default?: () => unknown }>();
99
</script>
1010
<template>
1111
<button
12-
:type="type"
12+
:type
1313
class="flex items-center gap-x-2.5 rounded-md transition-colors duration-75"
1414
:class="{
1515
'bg-blue-700 text-white hover:bg-blue-800': variant === 'primary',

src/components/BaseControl.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defineSlots<{ default?: () => unknown }>();
1111
</script>
1212
<template>
1313
<button
14-
:type="type"
14+
:type
1515
:aria-pressed="pressed"
1616
class="inline-flex gap-x-1 rounded-sm border-none p-3 align-middle leading-none text-blue-600 transition-colors duration-150 hover:enabled:bg-blue-100 disabled:text-gray-500 aria-pressed:bg-blue-200 dark:text-sky-400 dark:hover:enabled:bg-sky-700"
1717
>

src/components/BaseIcon.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ const icons = import.meta.glob<{ default: Component }>(
2424
},
2525
);
2626
27-
const props = defineProps({
27+
const { name } = defineProps({
2828
name: oneOf(iconList).isRequired,
2929
});
3030
3131
const icon = shallowRef<Component>();
3232
3333
watch(
34-
() => props.name,
35-
async (name) => {
36-
if (!name) {
34+
() => name,
35+
async (iconName) => {
36+
if (!iconName) {
3737
icon.value = undefined;
3838
}
3939
try {
40-
icon.value = await icons[`../assets/zondicons/${name}.svg`]();
40+
icon.value = await icons[`../assets/zondicons/${iconName}.svg`]();
4141
} catch (e) {
4242
console.error(e);
4343
icon.value = undefined;

src/components/BaseTimer.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@ import {
99
} from '@/utils';
1010
import { IntervalType } from '@/types';
1111
12-
const props = defineProps({
12+
const { type, duration } = defineProps({
1313
type: oneOf(['none', ...Object.values(IntervalType)] as const).def('none'),
1414
duration: integer().def(0),
1515
});
1616
17-
const time = computed(() => formatTime(props.duration));
17+
const time = computed(() => formatTime(duration));
1818
const label = computed(() => {
19-
const mins = getMinutes(props.duration);
20-
const secs = getSeconds(props.duration);
19+
const mins = getMinutes(duration);
20+
const secs = getSeconds(duration);
2121
return `${mins} minutes ${secs ? secs + ' seconds ' : ''}left`;
2222
});
2323
24-
const classes = computed(() =>
25-
getIntervalTypeColor(props.type as IntervalType),
26-
);
24+
const classes = computed(() => getIntervalTypeColor(type as IntervalType));
2725
</script>
2826
<template>
2927
<div

src/components/IntervalEditBox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ defineEmits<{
3434
<template v-for="(value, name) in IntervalType" :key="value">
3535
<option
3636
v-if="value !== IntervalType.None"
37-
:value="value"
37+
:value
3838
:selected="value === type"
3939
>
4040
{{ name }}

src/components/IntervalSquare.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,32 @@ import { oneOf, integer, bool } from 'vue-types';
44
import { formatTime, formatTimeDuration, toTitleCase } from '@/utils';
55
import { IntervalType } from '@/types';
66
7-
const props = defineProps({
7+
const { type, duration } = defineProps({
88
type: oneOf(Object.values(IntervalType)).isRequired,
99
duration: integer().def(0),
1010
current: bool().def(false),
1111
});
1212
1313
const abbr = computed(() =>
14-
props.type.replace(/(\w).+?($|-)/g, (_: string, v: string) =>
15-
v.toUpperCase(),
16-
),
14+
type.replace(/(\w).+?($|-)/g, (_: string, v: string) => v.toUpperCase()),
1715
);
1816
1917
const classes = computed(() => {
20-
if (props.type === IntervalType.Work) {
18+
if (type === IntervalType.Work) {
2119
return 'text-amber-300';
2220
}
23-
if (props.type === IntervalType.ShortBreak) {
21+
if (type === IntervalType.ShortBreak) {
2422
return 'text-green-300';
2523
}
26-
if (props.type === IntervalType.LongBreak) {
24+
if (type === IntervalType.LongBreak) {
2725
return 'text-green-300';
2826
}
2927
return 'text-blue-100';
3028
});
3129
32-
const durationFormatted = computed(() => formatTime(props.duration));
33-
const durationAttr = computed(() => formatTimeDuration(props.duration));
34-
const typeFormatted = computed(() => toTitleCase(props.type));
30+
const durationFormatted = computed(() => formatTime(duration));
31+
const durationAttr = computed(() => formatTimeDuration(duration));
32+
const typeFormatted = computed(() => toTitleCase(type));
3533
</script>
3634
<template>
3735
<li

src/components/TheControls.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import LayoutInline from '@/components/LayoutInline.vue';
66
import { Status } from '@/types';
77
import { useMain } from '@/stores/main';
88
9-
const main = useMain();
10-
11-
const props = defineProps({
12-
status: oneOf(Object.values(Status)).def(Status.Pause),
13-
});
14-
159
defineEmits<{
1610
play: [];
1711
pause: [];
@@ -20,7 +14,12 @@ defineEmits<{
2014
settings: [];
2115
}>();
2216
23-
const isPlaying = computed(() => props.status === Status.Play);
17+
const main = useMain();
18+
19+
const { status } = defineProps({
20+
status: oneOf(Object.values(Status)).def(Status.Pause),
21+
});
22+
const isPlaying = computed(() => status === Status.Play);
2423
</script>
2524
<template>
2625
<LayoutInline tag="fieldset" vertical-align="center" space="2">

src/components/TheCycle.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const cycle = useCycle();
1010
<ul class="flex flex-wrap items-center justify-center gap-1">
1111
<IntervalSquare
1212
v-for="(interval, i) in cycle.intervals"
13-
:key="i"
13+
:key="interval.id"
1414
:type="interval.type"
1515
:duration="interval.duration"
1616
:current="cycle.current === i"

src/components/TheCycleEdit.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import { bool } from 'vue-types';
1111
import { clone } from '@/utils';
1212
1313
const cycle = useCycle();
14-
const dialog = ref<HTMLDialogElement>();
1514
16-
const props = defineProps({
15+
const { open } = defineProps({
1716
open: bool().isRequired,
1817
});
1918
@@ -22,24 +21,29 @@ const emit = defineEmits<{
2221
save: [intervals: Interval[]];
2322
}>();
2423
25-
const intervalsRef = ref<Interval[]>([]);
2624
const cancellable = computed(() => intervalsRef.value.length > 1);
2725
26+
const intervalsRef = ref<Interval[]>([]);
27+
2828
function deleteInterval(deleteId?: string) {
2929
intervalsRef.value = intervalsRef.value.filter(({ id }) => deleteId !== id);
3030
}
31-
32-
function submit() {
33-
emit('save', clone(intervalsRef.value));
34-
close();
31+
function addInterval() {
32+
intervalsRef.value.push(cycle.createInterval());
3533
}
3634
3735
function close() {
3836
emit('toggled', false);
3937
}
4038
39+
function submit() {
40+
emit('save', clone(intervalsRef.value));
41+
close();
42+
}
43+
44+
const dialog = ref<HTMLDialogElement>();
4145
watch(
42-
() => props.open,
46+
() => open,
4347
(open: boolean) => {
4448
if (open === true) {
4549
intervalsRef.value = clone(cycle.intervals);
@@ -49,10 +53,6 @@ watch(
4953
dialog.value?.close();
5054
},
5155
);
52-
53-
function addInterval() {
54-
intervalsRef.value.push(cycle.createInterval());
55-
}
5656
</script>
5757
<template>
5858
<dialog ref="dialog" class="m-auto bg-transparent" @close="close">

0 commit comments

Comments
 (0)