refactor to ui components

This commit is contained in:
2023-05-26 16:43:12 +02:00
parent a642fcd1fb
commit c3bd807bff
13 changed files with 122 additions and 125 deletions

6
components.d.ts vendored
View File

@@ -11,6 +11,7 @@ declare module '@vue/runtime-core' {
export interface GlobalComponents { export interface GlobalComponents {
Auth: typeof import('./src/components/Auth.vue')['default'] Auth: typeof import('./src/components/Auth.vue')['default']
Autocomplete: typeof import('./src/components/Note/Autocomplete.vue')['default'] Autocomplete: typeof import('./src/components/Note/Autocomplete.vue')['default']
Button: typeof import('./src/components/ui/Button.vue')['default']
Hamburger: typeof import('./src/components/TopBar/Hamburger.vue')['default'] Hamburger: typeof import('./src/components/TopBar/Hamburger.vue')['default']
ListView: typeof import('./src/components/ViewModes/ListView.vue')['default'] ListView: typeof import('./src/components/ViewModes/ListView.vue')['default']
Logo: typeof import('./src/components/TopBar/Logo.vue')['default'] Logo: typeof import('./src/components/TopBar/Logo.vue')['default']
@@ -31,5 +32,10 @@ declare module '@vue/runtime-core' {
SkeletonTopBar: typeof import('./src/components/Skeleton/SkeletonTopBar.vue')['default'] SkeletonTopBar: typeof import('./src/components/Skeleton/SkeletonTopBar.vue')['default']
Spinner: typeof import('./src/components/Spinner.vue')['default'] Spinner: typeof import('./src/components/Spinner.vue')['default']
TopBar: typeof import('./src/components/TopBar.vue')['default'] TopBar: typeof import('./src/components/TopBar.vue')['default']
UIButton: typeof import('./src/components/ui/UIButton.vue')['default']
UIButtonGroup: typeof import('./src/components/ui/UIButtonGroup.vue')['default']
UIModal: typeof import('./src/components/ui/UIModal.vue')['default']
UITable: typeof import('./src/components/ui/UITable.vue')['default']
UITextInput: typeof import('./src/components/ui/UITextInput.vue')['default']
} }
} }

View File

@@ -95,7 +95,7 @@ provide('loading', loading)
<SkeletonNote v-else /> <SkeletonNote v-else />
</main> </main>
</div> </div>
<Modal :open="passphraseRequired" :persistent="true"> <UIModal :open="passphraseRequired" :persistent="true">
<template #title>Enter your passphrase</template> <template #title>Enter your passphrase</template>
<template #default="{ close }"> <template #default="{ close }">
<p> <p>
@@ -118,9 +118,9 @@ provide('loading', loading)
</div> </div>
</template> </template>
<template #actions="{ close }"> <template #actions="{ close }">
<button class="btn-primary btn-sm btn" @click="submitPassphrase(close)">Submit</button> <UIButton color="primary" size="sm" @click="submitPassphrase(close)">Submit</UIButton>
</template> </template>
</Modal> </UIModal>
</template> </template>
<style scoped> <style scoped>
.sidebar-enter-from, .sidebar-enter-from,

View File

@@ -12,35 +12,31 @@ const emit = defineEmits<{
<h1 class="flex flex-grow items-center rounded-md text-3xl font-semibold hover:bg-gray-200"> <h1 class="flex flex-grow items-center rounded-md text-3xl font-semibold hover:bg-gray-200">
<slot name="title"></slot> <slot name="title"></slot>
</h1> </h1>
<div class="btn-group flex items-center" v-if="!props.note.isRoot"> <UIButtonGroup class="flex items-center" v-if="!props.note.isRoot">
<Modal> <UIModal>
<template #activator="{ open }"> <template #activator="{ open }">
<button class="btn-toolbar btn-sm btn" @click="open"> <UIButton size="sm" @click="open"><i class="fas fa-fw fa-trash" /></UIButton>
<i class="fas fa-fw fa-trash" />
</button>
</template> </template>
<template #title>Delete note</template> <template #title>Delete note</template>
<template #default>Are you sure you want to delete this note?</template> <template #default>Are you sure you want to delete this note?</template>
<template #actions="{ close }"> <template #actions="{ close }">
<button class="btn-primary btn-sm btn" @click="emit('delete', close)">Delete note</button> <UIButton size="sm" color="primary" @click="emit('delete', close)">Delete notes</UIButton>
<button class="btn-sm btn" @click="close">Cancel</button> <UIButton size="sm" @click="close">Cancel</UIButton>
</template> </template>
</Modal> </UIModal>
<Modal> <UIModal>
<template #activator="{ open }"> <template #activator="{ open }">
<button class="btn-toolbar btn-sm btn" @click="open"> <UIButton size="sm" @click="open"><i class="fas fa-fw fa-sitemap" /></UIButton>
<i class="fas fa-fw fa-sitemap" />
</button>
</template> </template>
<template #title>Set root note</template> <template #title>Set root note</template>
<template #default>Are you sure you want to set this note as root note?</template> <template #default>Are you sure you want to set this note as root note?</template>
<template #actions="{ close }"> <template #actions="{ close }">
<button class="btn-sm btn" @click="close">Cancel</button> <UIButton size="sm" @click="close">Cancel</UIButton>
<button class="btn-primary btn-sm btn" @click="emit('setRoot', close)"> <UIButton size="sm" color="primary" @click="emit('setRoot', close)">
Set current note as root Set current note as root
</button> </UIButton>
</template> </template>
</Modal> </UIModal>
</div> </UIButtonGroup>
</div> </div>
</template> </template>

View File

@@ -19,10 +19,7 @@ const authUI: any = inject('firebaseAuthUI')
const authModalInitialStateOpen = ref<boolean>(authUI.isPendingRedirect()) const authModalInitialStateOpen = ref<boolean>(authUI.isPendingRedirect())
</script> </script>
<template> <template>
<div <div class="z-[500] flex h-[50px] bg-primary" :class="searchActive && 'search-active'">
class="z-[500] flex h-[50px] bg-primary"
:class="searchActive && 'search-active'"
>
<div class="mx-auto flex w-full max-w-app items-center py-2.5 text-white"> <div class="mx-auto flex w-full max-w-app items-center py-2.5 text-white">
<div <div
class="search-active-hide flex items-center pl-3" class="search-active-hide flex items-center pl-3"
@@ -41,29 +38,33 @@ const authModalInitialStateOpen = ref<boolean>(authUI.isPendingRedirect())
<div class="flex h-full flex-grow flex-row items-center gap-2 pl-5 pr-3"> <div class="flex h-full flex-grow flex-row items-center gap-2 pl-5 pr-3">
<template v-if="!loading"> <template v-if="!loading">
<SearchBar @active="(active) => (searchActive = active)" /> <SearchBar @active="(active) => (searchActive = active)" />
<button <UIButton
class="search-active-hide btn-outline btn-sm btn py-1 text-white" size="sm"
variant="outline"
class="search-active-hide py-1 text-white"
@click="addNote('Untitled new note', '', true)" @click="addNote('Untitled new note', '', true)"
> >
<i class="fas fa-plus-circle text-[1.1rem]" /> <i class="fas fa-plus-circle text-[1.1rem]" />
</button> </UIButton>
<Modal v-if="initialized && !user" :open="authModalInitialStateOpen"> <UIModal v-if="initialized && !user" :open="authModalInitialStateOpen">
<template #activator="{ open }"> <template #activator="{ open }">
<button <UIButton
class="search-active-hide btn-outline btn-sm btn py-1 text-white" size="sm"
variant="outline"
class="search-active-hide py-1 text-white"
@click="open" @click="open"
> >
Sign in Sign in
</button> </UIButton>
</template> </template>
<template #title>Sign in</template> <template #title>Sign in</template>
<template #default="{ close }"> <template #default="{ close }">
<Auth @signedIn="close" /> <Auth @signedIn="close" />
</template> </template>
<template #actions="{ close }"> <template #actions="{ close }">
<button class="btn-sm btn" @click="close">Close</button> <UIButton size="sm" @click="close">Close</UIButton>
</template> </template>
</Modal> </UIModal>
<Settings v-else-if="user" /> <Settings v-else-if="user" />
</template> </template>
<SkeletonTopBar v-else /> <SkeletonTopBar v-else />

View File

@@ -41,80 +41,3 @@ const emit = defineEmits<{
transition-duration: 0.2s; transition-duration: 0.2s;
} }
</style> </style>
<!--
$hamburger-layer-color: white;
$hamburger-layer-width: 25px;
$hamburger-layer-height: 3px;
$hamburger-layer-spacing: 3px;
$hamburger-padding-x: 0px;
$hamburger-padding-y: 0px;
$hamburger-scale-speed: calc(200ms / 0.22s);
@import 'hamburgers/_sass/hamburgers/hamburgers.scss';
@if index($hamburger-types, spin-r) {
/*
* Spin Reverse
*/
.hamburger--spin-r {
.hamburger-inner {
transition-duration: ($hamburger-scale-speed * 0.22s);
transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
&::before {
transition: top
($hamburger-scale-speed * 0.1s)
($hamburger-scale-speed * 0.25s)
ease-in,
opacity ($hamburger-scale-speed * 0.1s) ease-in;
}
&::after {
transition: bottom
($hamburger-scale-speed * 0.1s)
($hamburger-scale-speed * 0.25s)
ease-in,
transform
($hamburger-scale-speed * 0.22s)
cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
}
&.is-active {
.hamburger-inner {
transform: rotate(-225deg);
transition-delay: ($hamburger-scale-speed * 0.12s);
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
&::before {
top: 0;
opacity: 0;
transition: top ($hamburger-scale-speed * 0.1s) ease-out,
opacity
($hamburger-scale-speed * 0.1s)
($hamburger-scale-speed * 0.12s)
ease-out;
}
&::after {
bottom: 0;
transform: rotate(90deg);
transition: bottom ($hamburger-scale-speed * 0.1s) ease-out,
transform
($hamburger-scale-speed * 0.22s)
($hamburger-scale-speed * 0.12s)
cubic-bezier(0.215, 0.61, 0.355, 1);
}
}
}
}
}
button.hamburger {
outline: none !important;
line-height: 1;
opacity: 0.9;
border-radius: 2rem;
}
.hamburger-box {
display: block;
}
</style> -->

View File

@@ -45,7 +45,7 @@ const handleClick = (fn: (...args: any[]) => any) => {
{{ sourceLabels[source] }} {{ sourceLabels[source] }}
</a> </a>
</li> </li>
<Modal> <UIModal>
<template #activator="{ open }"> <template #activator="{ open }">
<li @click="open" class="text-base"> <li @click="open" class="text-base">
<a> <a>
@@ -63,7 +63,7 @@ const handleClick = (fn: (...args: any[]) => any) => {
<button class="btn-sm btn" @click="close">Cancel</button> <button class="btn-sm btn" @click="close">Cancel</button>
<button class="btn-primary btn-sm btn" @click="signOut(close)">Sign out</button> <button class="btn-primary btn-sm btn" @click="signOut(close)">Sign out</button>
</template> </template>
</Modal> </UIModal>
</ul> </ul>
</div> </div>
</OnClickOutside> </OnClickOutside>

View File

@@ -41,26 +41,26 @@ const deleteSelectedNotes = (closeModal: () => void) => {
<div class="whitespace-nowrap font-semibold">{{ countSelectedNotes }} selected</div> <div class="whitespace-nowrap font-semibold">{{ countSelectedNotes }} selected</div>
</template> </template>
</div> </div>
<Modal v-if="countSelectedNotes > 0"> <UIModal v-if="countSelectedNotes > 0">
<template #activator="{ open }"> <template #activator="{ open }">
<button class="btn-toolbar btn-sm btn" @click="open">Delete</button> <UIButton size="sm" @click="open">Delete</UIButton>
</template> </template>
<template #default>Are you sure you want to delete the selected notes?</template> <template #default>Are you sure you want to delete the selected notes?</template>
<template #actions="{ close }"> <template #actions="{ close }">
<button class="btn-primary btn-sm btn" @click="deleteSelectedNotes(close)"> <UIButton size="sm" color="primary" @click="deleteSelectedNotes(close)">
Delete selected notes Delete selected notes
</button> </UIButton>
<button class="btn-sm btn" @click="close">Close</button> <UIButton size="sm" @click="close">Close</UIButton>
</template> </template>
</Modal> </UIModal>
<input <UITextInput
type="text" size="sm"
placeholder="Start typing to filter"
class="input-bordered input input-sm my-1 ml-auto mr-1 max-w-xs flex-grow"
v-model="filter" v-model="filter"
/> placeholder="Start typing to filter"
class="my-1 ml-auto mr-1 max-w-xs flex-grow"
></UITextInput>
</div> </div>
<table class="table-compact table w-full"> <UITable density="compact" class="w-full">
<thead> <thead>
<tr> <tr>
<th class="w-[48px]"></th> <th class="w-[48px]"></th>
@@ -101,6 +101,6 @@ const deleteSelectedNotes = (closeModal: () => void) => {
<td>{{ formatDate(note.modified) }}</td> <td>{{ formatDate(note.modified) }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </UITable>
</div> </div>
</template> </template>

View File

@@ -33,6 +33,8 @@ const renderMindmap = () => {
const cy = cytoscape({ const cy = cytoscape({
container: mindmapCanvas, container: mindmapCanvas,
elements, elements,
autoungrabify: true,
autounselectify: true,
layout: { layout: {
name: 'cose', name: 'cose',

View File

@@ -0,0 +1,23 @@
<script setup lang="ts">
interface Props {
size?: string
variant?: 'regular' | 'outline'
color?: string
}
const props = withDefaults(defineProps<Props>(), {
size: 'md',
variant: 'regular',
color: 'regular'
})
const styleClass = computed(() => {
const sizeClass = `btn-${props.size}`
const variantClass = props.variant !== 'regular' ? `btn-${props.variant}` : ''
const colorClass = props.color !== 'regular' ? `btn-${props.color}` : ''
return [sizeClass, variantClass, colorClass]
})
</script>
<template>
<button class="btn" :class="styleClass"><slot></slot></button>
</template>

View File

@@ -0,0 +1,3 @@
<template>
<div class="btn-group"><slot></slot></div>
</template>

View File

@@ -0,0 +1,15 @@
<script setup lang="ts">
interface Props {
density?: 'compact'
}
const props = defineProps<Props>()
const styleClass = computed(() => {
const densityClass = props.density ? 'table-compact' : ''
return [densityClass]
})
</script>
<template>
<table class="table" :class="styleClass"><slot></slot></table>
</template>

View File

@@ -0,0 +1,28 @@
<script setup lang="ts">
interface Props {
modelValue: any
size?: 'sm' | 'md' | 'lg' | 'xl'
}
const props = withDefaults(defineProps<Props>(), {
size: 'md'
})
const emit = defineEmits<{
'update:modelValue': [value: any]
}>()
const styleClass = computed(() => {
const sizeClass = `input-${props.size}`
return [sizeClass]
})
</script>
<template>
<input
type="text"
:value="props.modelValue"
@input="emit('update:modelValue', ($event.target as HTMLInputElement)?.value)"
class="input-bordered input input-sm my-1 ml-auto mr-1 max-w-xs flex-grow"
:class="styleClass"
/>
</template>