Skip to content

Commit 11d14bc

Browse files
Merge pull request #77 from andrewcourtice/feat/history-extension
History extension
2 parents fa55047 + 1dc1135 commit 11d14bc

File tree

30 files changed

+2020
-2562
lines changed

30 files changed

+2020
-2562
lines changed

.vercelignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
yarn.lock

app/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
"@harlem/extension-trace": "^3.0.0",
2323
"@harlem/extension-transaction": "^3.0.0",
2424
"date-fns": "^2.29.3",
25-
"date-fns-tz": "^1.3.7",
25+
"date-fns-tz": "^2.0.0",
2626
"flex-layout-attribute": "^1.0.3",
2727
"harlem": "^3.0.0",
28-
"vue": "^3.2.45"
28+
"vue": "^3.2.47"
2929
},
3030
"devDependencies": {
31-
"@vitejs/plugin-vue": "^3.2.0",
32-
"@vue/compiler-sfc": "^3.2.45",
33-
"rollup-plugin-visualizer": "^5.8.3",
34-
"sass": "^1.56.1",
35-
"vite": "^3.2.5"
31+
"@vitejs/plugin-vue": "^4.0.0",
32+
"@vue/compiler-sfc": "^3.2.47",
33+
"rollup-plugin-visualizer": "^5.9.0",
34+
"sass": "^1.58.3",
35+
"vite": "^4.1.4"
3636
}
3737
}

app/src/app.vue

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,23 @@
1515
<br>
1616
If you have the Vue <strong>devtools</strong> installed, open them up and change the inspector to Harlem to see the store. The source code for this demo is available <a href="https://github.com/andrewcourtice/harlem/tree/main/app" target="_blank" rel="noopener noreferrer">here</a>.
1717
</p>
18-
<choice-group class="app__theme">
19-
<choice v-for="{ label, value } in state.themes"
20-
:key="value"
21-
v-model="theme"
22-
:id="value"
23-
:value="value">
24-
{{ label }}
25-
</choice>
26-
</choice-group>
18+
<div class="app__options" layout="rows center-justify gap-small">
19+
<choice-group self="sm-full">
20+
<choice v-for="{ label, value } in state.themes"
21+
:key="value"
22+
v-model="theme"
23+
:id="value"
24+
:value="value">
25+
{{ label }}
26+
</choice>
27+
</choice-group>
28+
<div layout="rows center-right gap-x-small" self="sm-full">
29+
<button class="button" self="sm-half" :disabled="!canUndo()" @click="undo()">Undo</button>
30+
<button class="button" self="sm-half" :disabled="!canRedo()" @click="redo()">Redo</button>
31+
</div>
32+
</div>
2733
</header>
28-
<div class="app__options" layout="rows center-justify">
34+
<div class="app__actions" layout="rows center-justify gap-small">
2935
<choice-group self="sm-full">
3036
<choice v-for="{ label, value } in state.clockTypes"
3137
:key="value"
@@ -81,11 +87,15 @@ import {
8187
} from 'date-fns-tz';
8288
8389
import {
90+
canRedo,
91+
canUndo,
8492
clocks,
8593
computeState,
8694
loadTimezones,
95+
redo,
8796
removeClock,
8897
state,
98+
undo,
8999
} from './stores/app';
90100
91101
loadTimezones();
@@ -95,7 +105,7 @@ watchEffect(() => document.body.setAttribute('theme', state.theme.toLowerCase())
95105
const addClockModal = ref();
96106
97107
const theme = computeState(state => state.theme);
98-
const clockType = computeState(state => state.clockType);
108+
const clockType = computeState(state => state.clockType, 'change-clock-type');
99109
100110
const clockComponent = computed(() => state.clockType === 'analogue'
101111
? AnalogueClock
@@ -140,13 +150,12 @@ function openAddClockModal() {
140150
text-align: center;
141151
}
142152
143-
.app__theme {
153+
.app__options {
144154
margin-top: 2rem;
145155
}
146156
147-
.app__options {
157+
.app__actions {
148158
margin: 2rem 0;
149-
gap: 1rem;
150159
}
151160
152161
.app__clocks {

app/src/assets/styles/_layout.scss

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
11
[self="size-auto"] {
22
width: auto;
3+
}
4+
5+
[layout~="gap-none"] {
6+
gap: 0;
7+
}
8+
9+
[layout~="gap-x-small"] {
10+
gap: var(--spacing__x-small);
11+
}
12+
13+
[layout~="gap-small"] {
14+
gap: var(--spacing__small);
15+
}
16+
17+
[layout~="gap-medium"] {
18+
gap: var(--spacing__medium);
19+
}
20+
21+
[layout~="gap-large"] {
22+
gap: var(--spacing__large);
23+
}
24+
25+
[layout] > [layout] {
26+
width: auto;
327
}

app/src/assets/styles/_variables.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
--colour__alert: #DC2626;
3333
--colour__alert--dark: #B91C1C;
3434

35+
--spacing__x-small: 0.5rem;
36+
--spacing__small: 1rem;
37+
--spacing__medium: 1.5rem;
38+
--spacing__large: 2rem;
39+
3540
--border__colour: #EDEDED;
3641

3742
--animation__timing: 250ms;

app/src/components/modals/add-clock.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</meta-text>
1919
</div>
2020
<template #footer="{ close }">
21-
<div class="add-clock-modal__actions" layout="row center-right">
21+
<div class="add-clock-modal__actions" layout="row center-right gap-small">
2222
<button class="button" @click="close()">Cancel</button>
2323
<button class="button button--primary" :disabled="!canComplete" @click="complete()">Add {{ model.selection.length }} Clocks</button>
2424
</div>
@@ -98,11 +98,4 @@ defineExpose({
9898
margin: 1rem 0;
9999
}
100100
101-
.add-clock-modal__actions {
102-
103-
& .button {
104-
margin-left: 1rem;
105-
}
106-
}
107-
108101
</style>

app/src/stores/app/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import {
55
export {
66
state,
77
computeState,
8+
undo,
9+
redo,
10+
canUndo,
11+
canRedo,
812
} from './store';
913

1014
export * from './getters';

app/src/stores/app/store.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import getState from './state';
22
import composeExtension from '@harlem/extension-compose';
33
import storageExtension from '@harlem/extension-storage';
4+
import historyExtension from '@harlem/extension-history';
45

56
import {
7+
ACTIONS,
68
MUTATIONS,
79
NAME,
810
} from './constants';
@@ -18,9 +20,22 @@ export const {
1820
action,
1921
reset,
2022
computeState,
23+
undo,
24+
redo,
25+
canUndo,
26+
canRedo,
2127
} = createStore(NAME, getState(), {
2228
extensions: [
2329
composeExtension(),
30+
historyExtension({
31+
mutations: {
32+
include: '*',
33+
exclude: [
34+
MUTATIONS.updateTime,
35+
ACTIONS.loadTimezones,
36+
],
37+
},
38+
}),
2439
storageExtension({
2540
exclude: [
2641
MUTATIONS.updateTime,

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@
4949
"vue": "^3.2.0"
5050
},
5151
"devDependencies": {
52-
"vue": "^3.2.45"
52+
"vue": "^3.2.47"
5353
}
5454
}

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
},
1414
"devDependencies": {
1515
"dotenv": "^16.0.3",
16-
"vitepress": "^1.0.0-alpha.30"
16+
"vitepress": "^1.0.0-alpha.47"
1717
},
1818
"dependencies": {
19-
"@vueuse/core": "^9.6.0"
19+
"@vueuse/core": "^9.13.0"
2020
}
2121
}

0 commit comments

Comments
 (0)