forked from mark-when/markwhen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
259 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<script setup lang="ts"> | ||
import type { ViewProvider } from "@/viewProvider"; | ||
const props = defineProps<{ isActive: boolean; vp: ViewProvider }>(); | ||
const emits = defineEmits<{ (event: "click"): void }>(); | ||
</script> | ||
|
||
<template> | ||
<button | ||
:class=" | ||
isActive | ||
? 'border-indigo-500 dark:border-indigo-400' | ||
: 'border-transparent' | ||
" | ||
@click="emits('click')" | ||
class="rounded px-2 py-1 mb-1 bg-white dark:bg-slate-900 font-bold grid border-2 vpButton" | ||
> | ||
<div | ||
v-html="vp.iconSvg" | ||
class="vpIcon flex w-full h-full justify-center items-center px-1" | ||
></div> | ||
<span class="vpName flex px-1" | ||
><span>{{ vp.name }}</span></span | ||
> | ||
<span v-if="isActive" class="ml-auto vpCheckmark"> | ||
<svg | ||
class="w-5 h-5 text-indigo-500 dark:text-indigo-400" | ||
focusable="false" | ||
aria-hidden="true" | ||
viewBox="0 0 24 24" | ||
fill="currentColor" | ||
stroke-width="1" | ||
stroke="currentColor" | ||
> | ||
<path | ||
d="M9 16.17 5.53 12.7a.9959.9959 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71c.39-.39.39-1.02 0-1.41a.9959.9959 0 0 0-1.41 0L9 16.17z" | ||
></path></svg | ||
></span> | ||
<div class="vpUrl flex px-1 text-sm text-gray-500"> | ||
<span>{{ vp.url }}</span> | ||
</div> | ||
</button> | ||
</template> | ||
|
||
<style scoped> | ||
.vpButton { | ||
grid-template-areas: | ||
"icon title checkmark" | ||
". url ."; | ||
grid-template-columns: auto 1fr auto; | ||
} | ||
.vpIcon { | ||
grid-area: icon; | ||
} | ||
.vpName { | ||
grid-area: title; | ||
} | ||
.vpCheckmark { | ||
grid-area: checkmark; | ||
} | ||
.vpUrl { | ||
grid-area: url; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<script setup lang="ts"> | ||
import { computed, ref } from "vue"; | ||
import Dialog from "@/Dialog/Dialog.vue"; | ||
import { useViewStore } from "@/Views/viewStore"; | ||
import type { ViewProvider } from "@/viewProvider"; | ||
import ViewOptionRow from "./ViewOptionRow.vue"; | ||
const viewStore = useViewStore(); | ||
const viewUrl = ref(""); | ||
const addView = () => { | ||
viewStore.views.unshift({ | ||
url: viewUrl.value, | ||
name: "View", | ||
capabilities: { | ||
edit: true, | ||
hoveringEvent: true, | ||
jumpToEvent: true, | ||
mobile: true, | ||
}, | ||
iconSvg: `<svg xmlns="http:https://www.w3.org/2000/svg" class="w-5 h-5" width="40" height="40" viewBox="0 0 24 24" stroke-width="3" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> | ||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path> | ||
<path d="M12 3l8 4.5l0 9l-8 4.5l-8 -4.5l0 -9l8 -4.5"></path> | ||
<path d="M12 12l8 -4.5"></path> | ||
<path d="M12 12l0 9"></path> | ||
<path d="M12 12l-8 -4.5"></path> | ||
</svg>`, | ||
uses: { | ||
jump: true, | ||
pages: true, | ||
sort: true, | ||
tags: true, | ||
}, | ||
}); | ||
viewStore.selectedViewIndex = 0; | ||
viewStore.showingViewsDialog = false; | ||
}; | ||
const isActiveView = (v: ViewProvider) => { | ||
const index = viewStore.views.findIndex( | ||
(vo) => vo.name === v.name && v.url === vo.url | ||
); | ||
return index; | ||
}; | ||
const toggleView = (v: ViewProvider) => { | ||
const index = isActiveView(v); | ||
if (index < 0) { | ||
viewStore.views.unshift(v); | ||
} else if (viewStore.views.length > 1) { | ||
viewStore.views.splice(index, 1); | ||
} | ||
}; | ||
</script> | ||
|
||
<template> | ||
<Dialog v-model="viewStore.showingViewsDialog"> | ||
<template #header> | ||
<div | ||
class="p-2 flex flex-row items-center dark:text-white text-gray-800 font-bold" | ||
> | ||
Views | ||
</div></template | ||
> | ||
<div class="w-full flex px-2 mb-1 flex-col"> | ||
<ViewOptionRow | ||
v-for="view in viewStore.viewOptions" | ||
:vp="view" | ||
:is-active="isActiveView(view) >= 0" | ||
@click="toggleView(view)" | ||
></ViewOptionRow> | ||
</div> | ||
<form class="w-full flex px-2 pb-2 flex-col" @submit.prevent="addView"> | ||
<div class="w-full flex flex-row gap-1"> | ||
<input | ||
ref="input" | ||
type="text" | ||
placeholder="http:https://localhost:5000" | ||
v-model="viewUrl" | ||
class="w-full py-1 px-2 outline-none rounded-t dark:bg-gray-700 font-bold dark:text-white bg-gray-100" | ||
required | ||
/> | ||
<button | ||
role="button" | ||
type="button" | ||
class="rounded px-2 ml-auto dark:bg-gray-700 dark:text-white font-bold" | ||
@click.prevent="addView" | ||
> | ||
Add | ||
</button> | ||
</div> | ||
</form> | ||
<div class="flex flex-row w-full pb-2 px-2"> | ||
<div class="flex flex-row ml-auto"> | ||
<button | ||
role="button" | ||
type="button" | ||
class="rounded px-2 ml-auto dark:bg-gray-700 dark:text-white font-bold" | ||
@click.prevent="viewStore.showingViewsDialog = false" | ||
> | ||
Done | ||
</button> | ||
</div> | ||
</div> | ||
</Dialog> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters