From 0a3abbd894e1e6acd0c4b951c00c82254efcb14e Mon Sep 17 00:00:00 2001 From: Baku Hashimoto Date: Thu, 28 Sep 2023 10:57:28 +0900 Subject: [PATCH] WIP --- src/components/App.vue | 122 +++++++++----------- src/components/Tabs/Tab.vue | 105 +++++++++++++++++ src/components/Tabs/Tabs.vue | 202 +++++++++++++++++++++++++++++++++ src/components/Tabs/index.ts | 4 + src/components/Tabs/symbols.ts | 11 ++ src/components/Tabs/types.ts | 40 +++++++ src/components/Tabs/utils.ts | 11 ++ 7 files changed, 427 insertions(+), 68 deletions(-) create mode 100644 src/components/Tabs/Tab.vue create mode 100644 src/components/Tabs/Tabs.vue create mode 100644 src/components/Tabs/index.ts create mode 100644 src/components/Tabs/symbols.ts create mode 100644 src/components/Tabs/types.ts create mode 100644 src/components/Tabs/utils.ts diff --git a/src/components/App.vue b/src/components/App.vue index dffe276..65120a6 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -30,6 +30,7 @@ import MonacoEditor, {ErrorInfo} from './MonacoEditor.vue' import OverlayColorPicker from './OverlayColorPicker.vue' import OverlayNumberSlider from './OverlayNumberSlider.vue' import OverlayPointHandle from './OverlayPointHandle.vue' +import {Tab, Tabs} from './Tabs' const {refAppStorage} = useAppStorage('com.baku89.paperjs-editor') @@ -332,47 +333,42 @@ window.addEventListener('drop', async e => { /> -
-
+ + + +
Settings
+
+ +
+ + + +
+
+
@@ -448,7 +444,30 @@ window.addEventListener('drop', async e => { background-image radial-gradient(circle at 0 0, var(--dot-color) 1px, transparent 0), linear-gradient(to bottom, var(--axis-color) 1px, transparent 0), linear-gradient(to right, var(--axis-color) 1px, transparent 0) background-repeat repeat, repeat-x, repeat-y +.inspector-tab + height 100% +.play + display inline-flex + justify-content center + align-items center + background var(--ui-button) + color var(--ui-color) + width 32px + height 32px + border-radius 9999px + vertical-align middle + padding 0 6px + gap .4em + transition all ease .2s + width auto + padding 0 12px 0 6px + background var(--ui-color) + color var(--ui-bg) + + &:hover + background var(--ui-accent) + color var(--ui-bg) .inspector position relative @@ -456,39 +475,6 @@ window.addEventListener('drop', async e => { display flex flex-direction column gap 1rem - -.actions - display flex - align-items center - gap 0.5rem - - .spacer - flex-grow 1 - - button - display inline-flex - justify-content center - align-items center - background var(--ui-button) - color var(--ui-color) - width 32px - height 32px - border-radius 9999px - vertical-align middle - padding 0 6px - gap .4em - transition all ease .2s - - &.play - width auto - padding 0 12px 0 6px - background var(--ui-color) - color var(--ui-bg) - - &:hover - background var(--ui-accent) - color var(--ui-bg) - .editor-wrapper position relative flex-grow 1 diff --git a/src/components/Tabs/Tab.vue b/src/components/Tabs/Tab.vue new file mode 100644 index 0000000..dc9154b --- /dev/null +++ b/src/components/Tabs/Tab.vue @@ -0,0 +1,105 @@ + + + + + diff --git a/src/components/Tabs/Tabs.vue b/src/components/Tabs/Tabs.vue new file mode 100644 index 0000000..491e998 --- /dev/null +++ b/src/components/Tabs/Tabs.vue @@ -0,0 +1,202 @@ + + + + + diff --git a/src/components/Tabs/index.ts b/src/components/Tabs/index.ts new file mode 100644 index 0000000..db696e5 --- /dev/null +++ b/src/components/Tabs/index.ts @@ -0,0 +1,4 @@ +import Tab from './Tab.vue' +import Tabs from './Tabs.vue' + +export {Tab, Tabs} diff --git a/src/components/Tabs/symbols.ts b/src/components/Tabs/symbols.ts new file mode 100644 index 0000000..52f9bfc --- /dev/null +++ b/src/components/Tabs/symbols.ts @@ -0,0 +1,11 @@ +import {InjectionKey} from 'vue' + +import {AddTab, DeleteTab, TabsState, UpdateTab} from './types' + +export const AddTabKey: InjectionKey = Symbol('addTab') + +export const UpdateTabKey: InjectionKey = Symbol('updateTab') + +export const DeleteTabKey: InjectionKey = Symbol('deleteTab') + +export const TabsProviderKey: InjectionKey = Symbol('tabsProvider') diff --git a/src/components/Tabs/types.ts b/src/components/Tabs/types.ts new file mode 100644 index 0000000..f854a7f --- /dev/null +++ b/src/components/Tabs/types.ts @@ -0,0 +1,40 @@ +export interface PushTabOptions { + name: string + header: string + isDisabled: boolean + index: number + computedId: string + paneId: string +} + +export interface Tab extends PushTabOptions { + id?: string + prefix?: string + suffix?: string + isActive?: boolean +} + +export interface Tabs { + cacheLifetime: number + options: { + useUrlFragment?: boolean + defaultTabHash?: string | null + } +} + +export interface TabsState { + activeTabName: string + lastActiveTabHash: string + tabs: Array +} + +export type AddTab = (tab: PushTabOptions) => void + +export type UpdateTab = (computedId: string, tab: PushTabOptions) => void + +export type DeleteTab = (computedId: string) => void + +export interface ExpiringStorage { + get(key: string): string | null + set(key: string, value: string, ttl: number): void +} diff --git a/src/components/Tabs/utils.ts b/src/components/Tabs/utils.ts new file mode 100644 index 0000000..c5f37f9 --- /dev/null +++ b/src/components/Tabs/utils.ts @@ -0,0 +1,11 @@ +import {inject, InjectionKey} from 'vue' + +export function injectStrict(key: InjectionKey, fallback?: T) { + const resolved = inject(key, fallback) + + if (typeof resolved === 'undefined') { + throw new Error(`Could not resolve ${key.description}`) + } + + return resolved +}