Merge remote-tracking branch 'base/main' into develop
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
@@ -0,0 +1,24 @@
|
||||
node_modules
|
||||
*.log
|
||||
.nuxt
|
||||
nuxt.d.ts
|
||||
.output
|
||||
.data
|
||||
.env
|
||||
package-lock.json
|
||||
framework
|
||||
dist
|
||||
.DS_Store
|
||||
|
||||
# Yarn
|
||||
.yarn/cache
|
||||
.yarn/*state*
|
||||
|
||||
# Local History
|
||||
.history
|
||||
|
||||
# VSCode
|
||||
.vscode/
|
||||
|
||||
# JetBrains/WebStorm
|
||||
.idea/
|
||||
@@ -0,0 +1,2 @@
|
||||
shamefully-hoist=true
|
||||
strict-peer-dependencies=false
|
||||
@@ -0,0 +1 @@
|
||||
typescript.includeWorkspace = true
|
||||
@@ -0,0 +1,3 @@
|
||||
# Drop Frontend Base
|
||||
|
||||
A repository of shared libraries for Drop apps
|
||||
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<div class="relative z-50" @close="emit('event', 'cancel')">
|
||||
<div class="fixed inset-0 bg-zinc-950/75" />
|
||||
|
||||
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
||||
<div
|
||||
class="flex min-h-full items-start justify-center p-4 text-center sm:items-center sm:p-0"
|
||||
>
|
||||
<div
|
||||
class="relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"
|
||||
>
|
||||
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
||||
<div class="sm:flex sm:items-start">
|
||||
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
||||
<h3 class="text-base font-semibold text-zinc-100">
|
||||
{{ props.data.title }}
|
||||
</h3>
|
||||
<div class="mt-2">
|
||||
<p class="text-sm text-zinc-400">
|
||||
{{ props.data.description }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="rounded-b-lg bg-zinc-800 px-4 py-3 sm:flex sm:gap-x-2 sm:flex-row-reverse sm:px-6"
|
||||
>
|
||||
<LoadingButton
|
||||
:loading="props.loading"
|
||||
@click="emit('event', 'confirm')"
|
||||
type="submit"
|
||||
class="w-full sm:w-fit"
|
||||
>
|
||||
{{ props.data.buttonText ?? "Confirm" }}
|
||||
</LoadingButton>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-900 sm:mt-0 sm:w-auto"
|
||||
@click="emit('event', 'cancel')"
|
||||
ref="cancelButtonRef"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
TransitionChild,
|
||||
TransitionRoot,
|
||||
} from "@headlessui/vue";
|
||||
import type {
|
||||
ModalDatas,
|
||||
ModalEvents,
|
||||
ModalType,
|
||||
} from "../composables/modal-stack";
|
||||
|
||||
const props = defineProps<{
|
||||
zHeight: number;
|
||||
loading: boolean;
|
||||
data: ModalDatas[ModalType.Confirmation];
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: "event", v: ModalEvents[ModalType.Confirmation]): void;
|
||||
}>();
|
||||
</script>
|
||||
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<button
|
||||
type="submit"
|
||||
:class="[
|
||||
styles[style].base,
|
||||
props.disabled ? styles[style].disabled : styles[style].dft,
|
||||
]"
|
||||
:disabled="props.disabled"
|
||||
>
|
||||
<div v-if="props.loading" role="status">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="w-5 h-5 text-transparent animate-spin fill-white"
|
||||
viewBox="0 0 100 101"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
/>
|
||||
</svg>
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
<slot v-else />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
type Style = "default" | "none";
|
||||
const props = defineProps<{
|
||||
loading: boolean;
|
||||
style?: Style;
|
||||
disabled?: boolean;
|
||||
}>();
|
||||
|
||||
const style = props.style ?? "default";
|
||||
|
||||
const styles: {
|
||||
[key in Style]: { base: string; dft: string; disabled: string };
|
||||
} = {
|
||||
["default"]: {
|
||||
base: "inline-flex min-h-9 items-center justify-center rounded-md px-3 py-1.5 text-sm font-semibold leading-6 shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600",
|
||||
dft: "text-white bg-blue-600 hover:bg-blue-500",
|
||||
disabled:
|
||||
"text-zinc-400 bg-blue-600/10 hover:bg-blue-600/10",
|
||||
},
|
||||
["none"]: { base: "", dft: "", disabled: "" },
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<TransitionGroup name="modal">
|
||||
<component
|
||||
v-for="(modal, modalIdx) in stack"
|
||||
:key="modal.data"
|
||||
:is="modal.component"
|
||||
:z-height="(modalIdx + 1) * 50"
|
||||
:loading="modal.loading"
|
||||
:data="modal.data"
|
||||
@event="
|
||||
(event: string, ...args: any[]) => handleCallback(modalIdx, event, args)
|
||||
"
|
||||
/>
|
||||
</TransitionGroup>
|
||||
<div id="modalstack"></div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.modal-enter-active,
|
||||
.modal-leave-active {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
.modal-enter-from {
|
||||
opacity: 0;
|
||||
}
|
||||
.modal-enter-to {
|
||||
opacity: 100;
|
||||
}
|
||||
.modal-leave-from {
|
||||
opacity: 100;
|
||||
}
|
||||
.modal-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script setup lang="ts">
|
||||
const stack = useModalStack();
|
||||
|
||||
async function handleCallback(modalIdx: number, event: string, args: any[]) {
|
||||
const modal = stack.value[modalIdx];
|
||||
const close = () => {
|
||||
stack.value.splice(modalIdx, 1);
|
||||
};
|
||||
|
||||
// Gets unwrapped when we call from the DOM
|
||||
// I kinda hate this but it's how Vue works so....
|
||||
(modal.loading as unknown as boolean) = true;
|
||||
try {
|
||||
await modal.callback(event, close, ...args);
|
||||
} finally {
|
||||
(modal.loading as unknown as boolean) = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,64 @@
|
||||
<template>
|
||||
<TransitionRoot as="template" :show="open">
|
||||
<Dialog class="relative z-50" @close="open = false">
|
||||
<TransitionChild
|
||||
as="template"
|
||||
enter="ease-out duration-300"
|
||||
enter-from="opacity-0"
|
||||
enter-to="opacity-100"
|
||||
leave="ease-in duration-200"
|
||||
leave-from="opacity-100"
|
||||
leave-to="opacity-0"
|
||||
>
|
||||
<div
|
||||
class="fixed inset-0 bg-zinc-950/75 transition-opacity"
|
||||
/>
|
||||
</TransitionChild>
|
||||
|
||||
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
||||
<div
|
||||
class="flex min-h-full items-start justify-center p-4 text-center sm:items-center sm:p-0"
|
||||
>
|
||||
<TransitionChild
|
||||
as="template"
|
||||
enter="ease-out duration-300"
|
||||
enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||
enter-to="opacity-100 translate-y-0 sm:scale-100"
|
||||
leave="ease-in duration-200"
|
||||
leave-from="opacity-100 translate-y-0 sm:scale-100"
|
||||
leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||
>
|
||||
<div
|
||||
:class="['relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full', props.sizeClass ?? 'sm:max-w-lg']"
|
||||
>
|
||||
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
||||
<slot />
|
||||
</div>
|
||||
<div
|
||||
class="rounded-b-lg bg-zinc-800 px-4 py-3 sm:flex sm:gap-x-2 sm:flex-row-reverse sm:px-6"
|
||||
>
|
||||
<slot name="buttons" :close="close" />
|
||||
</div>
|
||||
</div>
|
||||
</TransitionChild>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
</TransitionRoot>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
TransitionChild,
|
||||
TransitionRoot,
|
||||
} from "@headlessui/vue";
|
||||
|
||||
const open: Ref<boolean> = defineModel<boolean>() as any;
|
||||
const props = defineProps<{sizeClass?: string}>();
|
||||
|
||||
function close() {
|
||||
open.value = false;
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<div class="relative z-50" @close="emit('event', 'close')">
|
||||
<div
|
||||
class="fixed inset-0 bg-zinc-950/75"
|
||||
/>
|
||||
|
||||
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
||||
<div
|
||||
class="flex min-h-full items-start justify-center p-4 text-center sm:items-center sm:p-0"
|
||||
>
|
||||
<div
|
||||
class="relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"
|
||||
>
|
||||
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
||||
<div class="sm:flex sm:items-start">
|
||||
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
||||
<h3
|
||||
class="text-base font-semibold text-zinc-100"
|
||||
>{{ props.data.title }}
|
||||
</h3>
|
||||
<div class="mt-2">
|
||||
<p class="text-sm text-zinc-400">
|
||||
{{ props.data.description }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="rounded-b-lg bg-zinc-800 px-4 py-3 sm:flex sm:gap-x-2 sm:flex-row-reverse sm:px-6"
|
||||
>
|
||||
<LoadingButton
|
||||
:loading="props.loading"
|
||||
@click="emit('event', 'close')"
|
||||
type="submit"
|
||||
class="w-full sm:w-fit"
|
||||
>
|
||||
{{ props.data.buttonText ?? "Close" }}
|
||||
</LoadingButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
TransitionChild,
|
||||
TransitionRoot,
|
||||
} from "@headlessui/vue";
|
||||
import type {
|
||||
ModalDatas,
|
||||
ModalEvents,
|
||||
ModalType,
|
||||
} from "../composables/modal-stack";
|
||||
|
||||
const props = defineProps<{
|
||||
zHeight: number;
|
||||
loading: boolean;
|
||||
data: ModalDatas[ModalType.Notification];
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: "event", v: ModalEvents[ModalType.Notification]): void;
|
||||
}>();
|
||||
</script>
|
||||
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<div class="relative z-50" @close="emit('event', 'cancel')">
|
||||
<div class="fixed inset-0 bg-zinc-950/75" />
|
||||
|
||||
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
||||
<div
|
||||
class="flex min-h-full items-start justify-center p-4 text-center sm:items-center sm:p-0"
|
||||
>
|
||||
<div
|
||||
class="relative transform rounded-lg bg-zinc-900 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"
|
||||
>
|
||||
<div class="px-4 pb-4 pt-5 space-y-4 sm:p-6 sm:pb-4">
|
||||
<div class="sm:flex sm:items-start">
|
||||
<div class="mt-3 text-center sm:mt-0 sm:text-left w-full">
|
||||
<h3 class="text-base font-semibold text-zinc-100">
|
||||
{{ props.data.title }}
|
||||
</h3>
|
||||
<div class="mt-1">
|
||||
<p class="text-sm text-zinc-400">
|
||||
{{ props.data.description }}
|
||||
</p>
|
||||
</div>
|
||||
<form
|
||||
class="mt-4 w-full"
|
||||
@submit.prevent="() => emit('event', 'submit', v)"
|
||||
>
|
||||
<input
|
||||
v-model="v"
|
||||
type="text"
|
||||
:placeholder="props.data.placeholder"
|
||||
class="block w-full rounded-md border-0 bg-zinc-800 py-1.5 text-white shadow-sm ring-1 ring-inset ring-zinc-700 placeholder:text-zinc-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
|
||||
/>
|
||||
<button class="hidden" type="submit" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="rounded-b-lg bg-zinc-800 px-4 py-3 sm:flex sm:gap-x-2 sm:flex-row-reverse sm:px-6"
|
||||
>
|
||||
<LoadingButton
|
||||
:loading="props.loading"
|
||||
@click="emit('event', 'submit', v)"
|
||||
type="submit"
|
||||
class="w-full sm:w-fit"
|
||||
>
|
||||
{{ props.data.buttonText ?? "Submit" }}
|
||||
</LoadingButton>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-900 sm:mt-0 sm:w-auto"
|
||||
@click="emit('event', 'cancel')"
|
||||
ref="cancelButtonRef"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
TransitionChild,
|
||||
TransitionRoot,
|
||||
} from "@headlessui/vue";
|
||||
import type {
|
||||
ModalDatas,
|
||||
ModalEvents,
|
||||
ModalType,
|
||||
} from "../composables/modal-stack";
|
||||
|
||||
const props = defineProps<{
|
||||
zHeight: number;
|
||||
loading: boolean;
|
||||
data: ModalDatas[ModalType.TextInput];
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: "event", v: ModalEvents[ModalType.TextInput], s?: string): void;
|
||||
}>();
|
||||
|
||||
const v = ref(props.data.dft || "");
|
||||
</script>
|
||||
@@ -0,0 +1,74 @@
|
||||
import type { Component } from "vue";
|
||||
import ConfirmationModal from "../components/ConfirmationModal.vue";
|
||||
import NotificationModal from "../components/NotificationModal.vue";
|
||||
import TextInputModal from "../components/TextInputModal.vue";
|
||||
|
||||
export type ModalCallbackType<T extends ModalType> = (
|
||||
event: ModalEvents[T],
|
||||
close: () => void,
|
||||
...args: any[]
|
||||
) => Promise<void> | void;
|
||||
|
||||
export interface ModalStackElement<T extends ModalType> {
|
||||
component: Component;
|
||||
type: T;
|
||||
callback: ModalCallbackType<T>;
|
||||
loading: Ref<boolean>;
|
||||
data: ModalDatas[T];
|
||||
}
|
||||
|
||||
export enum ModalType {
|
||||
Confirmation,
|
||||
Notification,
|
||||
TextInput
|
||||
}
|
||||
|
||||
export type ModalEvents = {
|
||||
[ModalType.Confirmation]: "confirm" | "cancel";
|
||||
[ModalType.Notification]: "close";
|
||||
[ModalType.TextInput]: "cancel" | "submit"
|
||||
};
|
||||
|
||||
export type ModalDatas = {
|
||||
[ModalType.Confirmation]: {
|
||||
title: string;
|
||||
description: string;
|
||||
buttonText?: string;
|
||||
};
|
||||
[ModalType.Notification]: {
|
||||
title: string;
|
||||
description: string;
|
||||
buttonText?: string;
|
||||
};
|
||||
[ModalType.TextInput]: {
|
||||
title: string,
|
||||
description: string,
|
||||
buttonText?: string,
|
||||
dft?: string,
|
||||
placeholder?: string,
|
||||
}
|
||||
};
|
||||
|
||||
const modalComponents: { [key in ModalType]: Component } = {
|
||||
[ModalType.Confirmation]: ConfirmationModal,
|
||||
[ModalType.Notification]: NotificationModal,
|
||||
[ModalType.TextInput]: TextInputModal,
|
||||
};
|
||||
|
||||
export function createModal<T extends ModalType>(
|
||||
type: T,
|
||||
data: ModalDatas[T],
|
||||
callback: ModalCallbackType<T>
|
||||
) {
|
||||
const modalStack = useModalStack();
|
||||
modalStack.value.push({
|
||||
type,
|
||||
component: modalComponents[type],
|
||||
data,
|
||||
callback,
|
||||
loading: ref(false),
|
||||
});
|
||||
}
|
||||
|
||||
export const useModalStack = () =>
|
||||
useState<Array<ModalStackElement<any>>>("modal-stack", () => []);
|
||||
@@ -0,0 +1,3 @@
|
||||
import withNuxt from './.playground/.nuxt/eslint.config.mjs'
|
||||
|
||||
export default withNuxt()
|
||||
@@ -0,0 +1,2 @@
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
export default defineNuxtConfig({});
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "my-nuxt-layer",
|
||||
"type": "module",
|
||||
"version": "0.0.1",
|
||||
"main": "./nuxt.config.ts",
|
||||
"scripts": {
|
||||
"dev": "nuxi dev .playground",
|
||||
"dev:prepare": "nuxt prepare .playground",
|
||||
"build": "nuxt build .playground",
|
||||
"generate": "nuxt generate .playground",
|
||||
"preview": "nuxt preview .playground",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/eslint": "latest",
|
||||
"eslint": "^9.17.0",
|
||||
"nuxt": "^3.14.1592",
|
||||
"typescript": "^5.7.2",
|
||||
"vue": "latest"
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
|
||||
"dependencies": {
|
||||
"@headlessui/vue": "^1.7.23",
|
||||
"@heroicons/vue": "^2.2.0"
|
||||
}
|
||||
}
|
||||
+6248
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user