@m3ui-vue/m3ui-vue 0.5.6 → 0.5.7
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/m3ui.js +2 -2
- package/dist/m3ui.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/plugin.test.ts +9 -0
- package/src/components/MTimePicker.vue +1 -0
- package/src/plugin.ts +4 -1
package/package.json
CHANGED
|
@@ -24,4 +24,13 @@ describe('createM3UI', () => {
|
|
|
24
24
|
app.use(createM3UI({ palette: 'purple' }))
|
|
25
25
|
expect(document.documentElement.hasAttribute('data-palette')).toBe(false)
|
|
26
26
|
})
|
|
27
|
+
|
|
28
|
+
it('does not override a palette the user already picked', () => {
|
|
29
|
+
localStorage.setItem('m3-palette', 'teal')
|
|
30
|
+
document.documentElement.setAttribute('data-palette', 'teal')
|
|
31
|
+
const app = createApp(defineComponent({ render: () => h('div') }))
|
|
32
|
+
app.use(createM3UI({ palette: 'iron' }))
|
|
33
|
+
expect(document.documentElement.getAttribute('data-palette')).toBe('teal')
|
|
34
|
+
expect(localStorage.getItem('m3-palette')).toBe('teal')
|
|
35
|
+
})
|
|
27
36
|
})
|
|
@@ -53,6 +53,7 @@ function pad(n: number) { return String(n).padStart(2, '0') }
|
|
|
53
53
|
function selectHour(h: number) {
|
|
54
54
|
selectedHour.value = h
|
|
55
55
|
mode.value = 'minute'
|
|
56
|
+
emit('update:modelValue', `${pad(h)}:${pad(selectedMinute.value)}`)
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
function selectMinute(m: number) {
|
package/src/plugin.ts
CHANGED
|
@@ -12,7 +12,10 @@ export interface M3UIOptions {
|
|
|
12
12
|
export function createM3UI(options: M3UIOptions = {}) {
|
|
13
13
|
return {
|
|
14
14
|
install(app: App) {
|
|
15
|
-
|
|
15
|
+
// `options.palette` is only the first-visit default — once the user picks a palette via
|
|
16
|
+
// `useColorPalette().set()` it's persisted to localStorage, and that choice must win on
|
|
17
|
+
// every later boot instead of being clobbered back to the plugin's static default.
|
|
18
|
+
if (options.palette && options.palette !== 'purple' && !localStorage.getItem('m3-palette')) {
|
|
16
19
|
document.documentElement.setAttribute('data-palette', options.palette)
|
|
17
20
|
localStorage.setItem('m3-palette', options.palette)
|
|
18
21
|
}
|