nuxt-ui-elements 0.1.7 → 0.1.10
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/module.json +1 -1
- package/dist/module.mjs +5 -13
- package/dist/runtime/components/DialogConfirm.d.vue.ts +25 -0
- package/dist/runtime/components/DialogConfirm.vue +119 -0
- package/dist/runtime/components/DialogConfirm.vue.d.ts +25 -0
- package/dist/runtime/composables/useDialog.d.ts +12 -0
- package/dist/runtime/composables/useDialog.js +51 -0
- package/package.json +1 -1
- package/dist/runtime/components/backgrounds/BackgroundAurora.d.vue.ts +0 -137
- package/dist/runtime/components/backgrounds/BackgroundAurora.vue +0 -147
- package/dist/runtime/components/backgrounds/BackgroundAurora.vue.d.ts +0 -137
- package/dist/runtime/components/backgrounds/BackgroundFlickeringGrid.d.vue.ts +0 -120
- package/dist/runtime/components/backgrounds/BackgroundFlickeringGrid.vue +0 -247
- package/dist/runtime/components/backgrounds/BackgroundFlickeringGrid.vue.d.ts +0 -120
- package/dist/runtime/composables/useColorResolver.d.ts +0 -40
- package/dist/runtime/composables/useColorResolver.js +0 -68
- package/dist/runtime/composables/useGradient.d.ts +0 -23
- package/dist/runtime/composables/useGradient.js +0 -37
- package/dist/runtime/composables/useThemeColors.d.ts +0 -69
- package/dist/runtime/composables/useThemeColors.js +0 -94
- package/dist/runtime/plugin.d.ts +0 -2
- package/dist/runtime/plugin.js +0 -4
- package/dist/runtime/themes/background-flickering-grid.d.ts +0 -7
- package/dist/runtime/themes/background-flickering-grid.js +0 -6
- package/dist/runtime/types/tv.d.ts +0 -14
- package/dist/runtime/types/tv.js +0 -0
- package/dist/runtime/utils/tv.d.ts +0 -1
- package/dist/runtime/utils/tv.js +0 -2
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, useLogger,
|
|
1
|
+
import { defineNuxtModule, createResolver, useLogger, addImportsDir } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const module$1 = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
@@ -9,20 +9,12 @@ const module$1 = defineNuxtModule({
|
|
|
9
9
|
prefix: "UE"
|
|
10
10
|
},
|
|
11
11
|
moduleDependencies: {
|
|
12
|
-
"
|
|
13
|
-
"@nuxtjs/color-mode": {}
|
|
12
|
+
"@nuxt/ui": {}
|
|
14
13
|
},
|
|
15
|
-
setup(
|
|
14
|
+
setup(_options, _nuxt) {
|
|
16
15
|
const resolver = createResolver(import.meta.url);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
logger.error("[nuxt-ui-elements] @nuxt/ui is required. Please install it");
|
|
20
|
-
}
|
|
21
|
-
addComponentsDir({
|
|
22
|
-
path: resolver.resolve("./runtime/components"),
|
|
23
|
-
pathPrefix: false,
|
|
24
|
-
prefix: options.prefix
|
|
25
|
-
});
|
|
16
|
+
useLogger("nuxt-ui-elements");
|
|
17
|
+
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
26
18
|
}
|
|
27
19
|
});
|
|
28
20
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
open?: boolean;
|
|
3
|
+
size?: "sm" | "md";
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
confirmLabel?: string;
|
|
7
|
+
dismissLabel?: string;
|
|
8
|
+
clickToClose?: boolean;
|
|
9
|
+
async?: boolean;
|
|
10
|
+
successDelay?: number;
|
|
11
|
+
onConfirm?: (() => void) | (() => Promise<void>);
|
|
12
|
+
onDismiss?: () => void;
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
}
|
|
15
|
+
declare const __VLS_export: import("@vue/runtime-core").DefineComponent<Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
|
|
16
|
+
"update:open": (value: boolean) => any;
|
|
17
|
+
close: (value?: any) => any;
|
|
18
|
+
"after:leave": () => any;
|
|
19
|
+
}, string, import("@vue/runtime-core").PublicProps, Readonly<Props> & Readonly<{
|
|
20
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
21
|
+
onClose?: ((value?: any) => any) | undefined;
|
|
22
|
+
"onAfter:leave"?: (() => any) | undefined;
|
|
23
|
+
}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const _default: typeof __VLS_export;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
const {
|
|
4
|
+
open = false,
|
|
5
|
+
size = "sm",
|
|
6
|
+
confirmLabel = "Yes",
|
|
7
|
+
dismissLabel = "No",
|
|
8
|
+
async = false,
|
|
9
|
+
successDelay = 1200,
|
|
10
|
+
...props
|
|
11
|
+
} = defineProps({
|
|
12
|
+
open: { type: Boolean, required: false },
|
|
13
|
+
size: { type: String, required: false },
|
|
14
|
+
title: { type: String, required: true },
|
|
15
|
+
description: { type: String, required: false },
|
|
16
|
+
confirmLabel: { type: String, required: false },
|
|
17
|
+
dismissLabel: { type: String, required: false },
|
|
18
|
+
clickToClose: { type: Boolean, required: false },
|
|
19
|
+
async: { type: Boolean, required: false },
|
|
20
|
+
successDelay: { type: Number, required: false },
|
|
21
|
+
onConfirm: { type: Function, required: false },
|
|
22
|
+
onDismiss: { type: Function, required: false },
|
|
23
|
+
onClose: { type: Function, required: false }
|
|
24
|
+
});
|
|
25
|
+
defineEmits(["update:open", "close", "after:leave"]);
|
|
26
|
+
const sizeClass = computed(() => {
|
|
27
|
+
switch (size) {
|
|
28
|
+
case "sm":
|
|
29
|
+
return "sm:max-w-md";
|
|
30
|
+
case "md":
|
|
31
|
+
return "sm:max-w-3xl";
|
|
32
|
+
default:
|
|
33
|
+
return "max-w-3xl";
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const isConfirming = ref(false);
|
|
37
|
+
const isComplete = ref(false);
|
|
38
|
+
const error = ref(null);
|
|
39
|
+
const confirm = async () => {
|
|
40
|
+
if (props.onConfirm) {
|
|
41
|
+
if (async) {
|
|
42
|
+
isConfirming.value = true;
|
|
43
|
+
error.value = null;
|
|
44
|
+
try {
|
|
45
|
+
await Promise.resolve(props.onConfirm());
|
|
46
|
+
isConfirming.value = false;
|
|
47
|
+
isComplete.value = true;
|
|
48
|
+
await new Promise((resolve) => setTimeout(resolve, successDelay));
|
|
49
|
+
props.onClose?.();
|
|
50
|
+
} catch (e) {
|
|
51
|
+
isConfirming.value = false;
|
|
52
|
+
error.value = e instanceof Error ? e.message : "An error occurred";
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
props.onConfirm();
|
|
57
|
+
props.onClose?.();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const dismiss = () => {
|
|
62
|
+
if (props.onDismiss) {
|
|
63
|
+
props.onDismiss();
|
|
64
|
+
}
|
|
65
|
+
props.onClose?.();
|
|
66
|
+
};
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<template>
|
|
70
|
+
<UModal
|
|
71
|
+
:open="open"
|
|
72
|
+
:dismissible="clickToClose"
|
|
73
|
+
:close="false"
|
|
74
|
+
:title="title"
|
|
75
|
+
:ui="{
|
|
76
|
+
content: `${sizeClass} divide-y-0`,
|
|
77
|
+
header: 'px-2 sm:px-5 py-3',
|
|
78
|
+
body: 'p-2 sm:p-5 sm:pt-0',
|
|
79
|
+
footer: 'justify-end gap-3'
|
|
80
|
+
}"
|
|
81
|
+
@update:open="$emit('update:open', $event)"
|
|
82
|
+
@close="$emit('close', $event)"
|
|
83
|
+
@after:leave="$emit('after:leave')"
|
|
84
|
+
>
|
|
85
|
+
<template #body>
|
|
86
|
+
<div class="space-y-3">
|
|
87
|
+
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
88
|
+
<div class="text-sm text-gray-500" v-html="description" />
|
|
89
|
+
|
|
90
|
+
<!-- Error message -->
|
|
91
|
+
<div
|
|
92
|
+
v-if="error"
|
|
93
|
+
class="text-sm text-red-500 dark:text-red-400 bg-red-50 dark:bg-red-950 p-3 rounded"
|
|
94
|
+
>
|
|
95
|
+
{{ error }}
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</template>
|
|
99
|
+
<template #footer>
|
|
100
|
+
<UButton
|
|
101
|
+
v-if="dismissLabel"
|
|
102
|
+
:ui="{ base: 'justify-around' }"
|
|
103
|
+
color="neutral"
|
|
104
|
+
variant="outline"
|
|
105
|
+
:label="dismissLabel"
|
|
106
|
+
@click="dismiss"
|
|
107
|
+
/>
|
|
108
|
+
<UButton
|
|
109
|
+
color="neutral"
|
|
110
|
+
:loading="isConfirming"
|
|
111
|
+
:disabled="isComplete"
|
|
112
|
+
:label="isComplete ? void 0 : confirmLabel"
|
|
113
|
+
:icon="isComplete ? 'i-heroicons-check' : void 0"
|
|
114
|
+
:ui="{ base: 'justify-around' }"
|
|
115
|
+
@click="confirm"
|
|
116
|
+
/>
|
|
117
|
+
</template>
|
|
118
|
+
</UModal>
|
|
119
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
open?: boolean;
|
|
3
|
+
size?: "sm" | "md";
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
confirmLabel?: string;
|
|
7
|
+
dismissLabel?: string;
|
|
8
|
+
clickToClose?: boolean;
|
|
9
|
+
async?: boolean;
|
|
10
|
+
successDelay?: number;
|
|
11
|
+
onConfirm?: (() => void) | (() => Promise<void>);
|
|
12
|
+
onDismiss?: () => void;
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
}
|
|
15
|
+
declare const __VLS_export: import("@vue/runtime-core").DefineComponent<Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
|
|
16
|
+
"update:open": (value: boolean) => any;
|
|
17
|
+
close: (value?: any) => any;
|
|
18
|
+
"after:leave": () => any;
|
|
19
|
+
}, string, import("@vue/runtime-core").PublicProps, Readonly<Props> & Readonly<{
|
|
20
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
21
|
+
onClose?: ((value?: any) => any) | undefined;
|
|
22
|
+
"onAfter:leave"?: (() => any) | undefined;
|
|
23
|
+
}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const _default: typeof __VLS_export;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import DialogConfirm from "../components/DialogConfirm.vue.js";
|
|
2
|
+
type CallbackFn = () => void | Promise<void>;
|
|
3
|
+
interface DialogInstance {
|
|
4
|
+
onConfirm: (fn: CallbackFn) => DialogInstance;
|
|
5
|
+
onDismiss: (fn: CallbackFn) => DialogInstance;
|
|
6
|
+
open: () => DialogInstance;
|
|
7
|
+
}
|
|
8
|
+
export declare const useDialog: () => {
|
|
9
|
+
confirm: (options: Omit<InstanceType<typeof DialogConfirm>["$props"], "onDismiss" | "onConfirm" | "class">) => DialogInstance;
|
|
10
|
+
confirmNavigate: (path: string) => void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import DialogConfirm from "../components/DialogConfirm.vue";
|
|
2
|
+
import { useOverlay } from "#imports";
|
|
3
|
+
import { navigateTo } from "#app";
|
|
4
|
+
export const useDialog = () => {
|
|
5
|
+
const overlay = useOverlay();
|
|
6
|
+
const confirm = (options) => {
|
|
7
|
+
let confirmCallback = () => {
|
|
8
|
+
};
|
|
9
|
+
let dismissCallback = () => {
|
|
10
|
+
};
|
|
11
|
+
const modal = overlay.create(DialogConfirm, {
|
|
12
|
+
destroyOnClose: true,
|
|
13
|
+
props: {
|
|
14
|
+
...options,
|
|
15
|
+
onConfirm: async () => {
|
|
16
|
+
await confirmCallback();
|
|
17
|
+
},
|
|
18
|
+
onDismiss: async () => {
|
|
19
|
+
await dismissCallback();
|
|
20
|
+
}
|
|
21
|
+
// onClose: () => {
|
|
22
|
+
// modal.close();
|
|
23
|
+
// },
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const dialogInstance = {
|
|
27
|
+
onConfirm: (fn) => {
|
|
28
|
+
confirmCallback = fn;
|
|
29
|
+
return dialogInstance;
|
|
30
|
+
},
|
|
31
|
+
onDismiss: (fn) => {
|
|
32
|
+
dismissCallback = fn;
|
|
33
|
+
return dialogInstance;
|
|
34
|
+
},
|
|
35
|
+
open: () => {
|
|
36
|
+
modal.open();
|
|
37
|
+
return dialogInstance;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return dialogInstance;
|
|
41
|
+
};
|
|
42
|
+
const confirmNavigate = (path) => {
|
|
43
|
+
confirm({
|
|
44
|
+
title: "Leave this page?",
|
|
45
|
+
description: "Are you sure you want to navigate away? Unsaved changes will be lost."
|
|
46
|
+
}).onConfirm(() => {
|
|
47
|
+
navigateTo(path);
|
|
48
|
+
}).open();
|
|
49
|
+
};
|
|
50
|
+
return { confirm, confirmNavigate };
|
|
51
|
+
};
|
package/package.json
CHANGED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import type { ColorInput } from "../../composables/useColorResolver.js";
|
|
2
|
-
/**
|
|
3
|
-
* Aurora - An animated aurora background component with gradient effects
|
|
4
|
-
*
|
|
5
|
-
* A beautiful CSS-based gradient animation that creates flowing aurora-like effects.
|
|
6
|
-
* Perfect for hero sections, landing pages, or anywhere you want eye-catching backgrounds.
|
|
7
|
-
*/
|
|
8
|
-
export type AuroraVariant = "calm" | "energetic" | "cosmic";
|
|
9
|
-
export interface AuroraProps {
|
|
10
|
-
/**
|
|
11
|
-
* Pin the aurora to a specific corner or edge of the container.
|
|
12
|
-
*
|
|
13
|
-
* When set, creates a radial mask that constrains the aurora effect to originate from
|
|
14
|
-
* the specified position, creating a spotlight or glow effect from that corner/edge.
|
|
15
|
-
*
|
|
16
|
-
* When undefined, aurora flows freely across the entire container without masking.
|
|
17
|
-
*
|
|
18
|
-
* Use cases:
|
|
19
|
-
* - 'top-right': Glow from top-right corner (perfect for hero sections)
|
|
20
|
-
* - 'bottom-left': Accent from bottom corner
|
|
21
|
-
* - 'top': Top edge glow (header backgrounds)
|
|
22
|
-
* - undefined: Full-screen flowing effect (landing pages)
|
|
23
|
-
*
|
|
24
|
-
* @default 'top-right'
|
|
25
|
-
*/
|
|
26
|
-
pin?: "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
27
|
-
/**
|
|
28
|
-
* Color for the aurora gradient. Supports:
|
|
29
|
-
* - Nuxt UI semantic: 'primary', 'secondary', 'success', 'info', 'warning', 'error', 'neutral'
|
|
30
|
-
* - Tailwind colors: 'blue-500', 'red-600', 'purple-400', etc.
|
|
31
|
-
* - Direct values: '#3b82f6', 'oklch(0.6 0.15 250)', 'rgb(59, 130, 246)'
|
|
32
|
-
*
|
|
33
|
-
* The component automatically generates multiple gradient shades from this base color
|
|
34
|
-
* with different lightness values for a rich, multi-tone aurora effect.
|
|
35
|
-
*
|
|
36
|
-
* @example 'primary' - Uses Nuxt UI theme primary color
|
|
37
|
-
* @example 'purple-500' - Tailwind purple
|
|
38
|
-
* @example '#8b5cf6' - Direct hex value
|
|
39
|
-
*
|
|
40
|
-
* @default 'primary'
|
|
41
|
-
*/
|
|
42
|
-
color?: ColorInput;
|
|
43
|
-
/**
|
|
44
|
-
* Speed of the aurora animation (0-100, where 100 is fastest).
|
|
45
|
-
*
|
|
46
|
-
* Controls how quickly the aurora gradient flows across the screen.
|
|
47
|
-
* - 0: Paused (no animation)
|
|
48
|
-
* - 1-30: Slow, calm movement
|
|
49
|
-
* - 40-60: Medium, steady flow
|
|
50
|
-
* - 70-100: Fast, energetic motion
|
|
51
|
-
*
|
|
52
|
-
* Range: 0-100
|
|
53
|
-
* @default 50
|
|
54
|
-
*/
|
|
55
|
-
speed?: number;
|
|
56
|
-
/**
|
|
57
|
-
* Opacity/visibility of the aurora effect (0-100).
|
|
58
|
-
*
|
|
59
|
-
* Controls the overall transparency of the aurora gradient overlay.
|
|
60
|
-
* Does NOT affect blur amount - use `variant` for preset blur configurations.
|
|
61
|
-
*
|
|
62
|
-
* - 0: Completely invisible
|
|
63
|
-
* - 30: Subtle, gentle glow
|
|
64
|
-
* - 50: Balanced visibility
|
|
65
|
-
* - 80-100: Bold, prominent effect
|
|
66
|
-
*
|
|
67
|
-
* Range: 0-100
|
|
68
|
-
* @default 50
|
|
69
|
-
*/
|
|
70
|
-
opacity?: number;
|
|
71
|
-
/**
|
|
72
|
-
* Lightness adjustment for the base color in OKLCH color space (0-100).
|
|
73
|
-
*
|
|
74
|
-
* Controls the brightness/saturation of the generated gradient colors.
|
|
75
|
-
* - Lower values (30-50): Darker, more saturated colors (better for dark mode)
|
|
76
|
-
* - Higher values (60-80): Lighter, pastel colors (better for light mode)
|
|
77
|
-
*
|
|
78
|
-
* The component automatically adjusts this for dark mode, but you can override
|
|
79
|
-
* using the `dark` prop for custom dark mode appearance.
|
|
80
|
-
*
|
|
81
|
-
* Range: 0-100
|
|
82
|
-
* @default 70 (light mode), 40 (dark mode)
|
|
83
|
-
*/
|
|
84
|
-
lightness?: number;
|
|
85
|
-
/**
|
|
86
|
-
* Dark mode overrides for color, lightness, and opacity.
|
|
87
|
-
*
|
|
88
|
-
* Allows you to customize the aurora appearance specifically for dark mode.
|
|
89
|
-
* Any property not specified will use the default light mode value.
|
|
90
|
-
*
|
|
91
|
-
* @example { color: 'blue-400', lightness: 30, opacity: 60 }
|
|
92
|
-
*/
|
|
93
|
-
dark?: {
|
|
94
|
-
color?: ColorInput;
|
|
95
|
-
lightness?: number;
|
|
96
|
-
opacity?: number;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Animation style variant with preset configurations.
|
|
100
|
-
*
|
|
101
|
-
* When set, overrides `speed`, `opacity`, and blur settings with carefully tuned presets.
|
|
102
|
-
* - 'calm': Slow, gentle, heavily blurred (meditative feel)
|
|
103
|
-
* - 'energetic': Fast, vibrant, lightly blurred (dynamic feel)
|
|
104
|
-
* - 'cosmic': Medium speed, high opacity, moderate blur (space-like effect)
|
|
105
|
-
*
|
|
106
|
-
* Leave undefined to manually control speed and opacity.
|
|
107
|
-
*/
|
|
108
|
-
variant?: AuroraVariant;
|
|
109
|
-
/**
|
|
110
|
-
* Reverse the animation direction.
|
|
111
|
-
*
|
|
112
|
-
* When true, the aurora flows in the opposite direction.
|
|
113
|
-
*
|
|
114
|
-
* @default false
|
|
115
|
-
*/
|
|
116
|
-
reverse?: boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Additional CSS classes for the container element.
|
|
119
|
-
*/
|
|
120
|
-
class?: any;
|
|
121
|
-
}
|
|
122
|
-
export interface AuroraSlots {
|
|
123
|
-
/**
|
|
124
|
-
* Default slot content rendered on top of the aurora background.
|
|
125
|
-
*
|
|
126
|
-
* Content is positioned with z-index above the aurora effect.
|
|
127
|
-
*/
|
|
128
|
-
default(): any;
|
|
129
|
-
}
|
|
130
|
-
declare const _default: typeof __VLS_export;
|
|
131
|
-
export default _default;
|
|
132
|
-
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<AuroraProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AuroraProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, AuroraSlots>;
|
|
133
|
-
type __VLS_WithSlots<T, S> = T & {
|
|
134
|
-
new (): {
|
|
135
|
-
$slots: S;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<script setup>
|
|
6
|
-
import { computed, ref, onMounted, watch } from "vue";
|
|
7
|
-
import { useColorMode } from "#imports";
|
|
8
|
-
import { resolveColor } from "../../composables/useColorResolver";
|
|
9
|
-
import {
|
|
10
|
-
adjustLightness,
|
|
11
|
-
oklchToRgb
|
|
12
|
-
} from "../../composables/useThemeColors";
|
|
13
|
-
import { createRepeatingGradient } from "../../composables/useGradient";
|
|
14
|
-
const {
|
|
15
|
-
pin = "top-right",
|
|
16
|
-
color = "primary",
|
|
17
|
-
speed = 50,
|
|
18
|
-
opacity = 50,
|
|
19
|
-
lightness = 70,
|
|
20
|
-
reverse = false,
|
|
21
|
-
...props
|
|
22
|
-
} = defineProps({
|
|
23
|
-
pin: { type: String, required: false },
|
|
24
|
-
color: { type: null, required: false },
|
|
25
|
-
speed: { type: Number, required: false },
|
|
26
|
-
opacity: { type: Number, required: false },
|
|
27
|
-
lightness: { type: Number, required: false },
|
|
28
|
-
dark: { type: Object, required: false },
|
|
29
|
-
variant: { type: String, required: false },
|
|
30
|
-
reverse: { type: Boolean, required: false },
|
|
31
|
-
class: { type: null, required: false }
|
|
32
|
-
});
|
|
33
|
-
defineSlots();
|
|
34
|
-
const isDark = ref(false);
|
|
35
|
-
onMounted(() => {
|
|
36
|
-
const colorMode = useColorMode();
|
|
37
|
-
isDark.value = colorMode.value === "dark";
|
|
38
|
-
watch(
|
|
39
|
-
() => colorMode.value,
|
|
40
|
-
(newValue) => {
|
|
41
|
-
isDark.value = newValue === "dark";
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
});
|
|
45
|
-
const variants = {
|
|
46
|
-
calm: { speed: 20, opacity: 30, blur: 15 },
|
|
47
|
-
energetic: { speed: 80, opacity: 70, blur: 8 },
|
|
48
|
-
cosmic: { speed: 50, opacity: 90, blur: 12 }
|
|
49
|
-
};
|
|
50
|
-
const effectiveSpeed = computed(
|
|
51
|
-
() => props.variant ? variants[props.variant].speed : speed
|
|
52
|
-
);
|
|
53
|
-
const effectiveOpacity = computed(
|
|
54
|
-
() => props.variant ? variants[props.variant].opacity : opacity
|
|
55
|
-
);
|
|
56
|
-
const effectiveBlur = computed(
|
|
57
|
-
() => props.variant ? variants[props.variant].blur : 10
|
|
58
|
-
);
|
|
59
|
-
const effectiveColor = computed(
|
|
60
|
-
() => isDark.value && props.dark?.color ? props.dark.color : color
|
|
61
|
-
);
|
|
62
|
-
const effectiveLightness = computed(
|
|
63
|
-
() => isDark.value && props.dark?.lightness !== void 0 ? props.dark.lightness : isDark.value ? 40 : lightness
|
|
64
|
-
);
|
|
65
|
-
const effectiveOpacityValue = computed(
|
|
66
|
-
() => isDark.value && props.dark?.opacity !== void 0 ? props.dark.opacity : effectiveOpacity.value
|
|
67
|
-
);
|
|
68
|
-
const baseColor = computed(() => resolveColor(effectiveColor.value));
|
|
69
|
-
const auroraColors = computed(() => {
|
|
70
|
-
const base = baseColor.value;
|
|
71
|
-
const baseLightness = effectiveLightness.value;
|
|
72
|
-
return [
|
|
73
|
-
oklchToRgb(adjustLightness(base, baseLightness - 10)),
|
|
74
|
-
oklchToRgb(adjustLightness(base, baseLightness + 5)),
|
|
75
|
-
oklchToRgb(adjustLightness(base, baseLightness)),
|
|
76
|
-
oklchToRgb(adjustLightness(base, baseLightness + 10)),
|
|
77
|
-
oklchToRgb(adjustLightness(base, baseLightness - 5))
|
|
78
|
-
];
|
|
79
|
-
});
|
|
80
|
-
const auroraGradient = computed(
|
|
81
|
-
() => createRepeatingGradient(auroraColors.value, 100)
|
|
82
|
-
);
|
|
83
|
-
const animationDuration = computed(() => {
|
|
84
|
-
const clampedSpeed = Math.max(1, Math.min(100, effectiveSpeed.value));
|
|
85
|
-
const duration = 120 - clampedSpeed * 0.9;
|
|
86
|
-
return `${duration}s`;
|
|
87
|
-
});
|
|
88
|
-
const animationState = computed(
|
|
89
|
-
() => effectiveSpeed.value === 0 ? "paused" : "running"
|
|
90
|
-
);
|
|
91
|
-
const animationDirection = computed(() => reverse ? "reverse" : "normal");
|
|
92
|
-
const auroraOpacityValue = computed(() => {
|
|
93
|
-
const clampedOpacity = Math.max(
|
|
94
|
-
0,
|
|
95
|
-
Math.min(100, effectiveOpacityValue.value)
|
|
96
|
-
);
|
|
97
|
-
return clampedOpacity / 100;
|
|
98
|
-
});
|
|
99
|
-
const auroraBlur = computed(() => `${effectiveBlur.value}px`);
|
|
100
|
-
const lineColor = computed(() => isDark.value ? "#000" : "#fff");
|
|
101
|
-
const lineColorAfter = computed(
|
|
102
|
-
() => isDark.value ? "rgba(0, 0, 0, 0.3)" : "#fff"
|
|
103
|
-
);
|
|
104
|
-
const filterInvert = computed(() => isDark.value ? "invert(0)" : "invert(1)");
|
|
105
|
-
const afterOpacity = computed(() => isDark.value ? 0.3 : 1);
|
|
106
|
-
const maskGradient = computed(() => {
|
|
107
|
-
if (!pin) return void 0;
|
|
108
|
-
const positions = {
|
|
109
|
-
"top-left": "ellipse at 0% 0%",
|
|
110
|
-
"top-right": "ellipse at 100% 0%",
|
|
111
|
-
"bottom-left": "ellipse at 0% 100%",
|
|
112
|
-
"bottom-right": "ellipse at 100% 100%",
|
|
113
|
-
top: "ellipse at 50% 0%",
|
|
114
|
-
bottom: "ellipse at 50% 100%",
|
|
115
|
-
left: "ellipse at 0% 50%",
|
|
116
|
-
right: "ellipse at 100% 50%"
|
|
117
|
-
};
|
|
118
|
-
return `radial-gradient(${positions[pin]}, black 10%, transparent 70%)`;
|
|
119
|
-
});
|
|
120
|
-
</script>
|
|
121
|
-
|
|
122
|
-
<template>
|
|
123
|
-
<div
|
|
124
|
-
class="relative flex h-full w-full items-center justify-center bg-zinc-50 text-slate-950 transition-bg dark:bg-zinc-900"
|
|
125
|
-
:class="props.class"
|
|
126
|
-
>
|
|
127
|
-
<div
|
|
128
|
-
class="absolute inset-0 overflow-hidden"
|
|
129
|
-
:style="maskGradient ? { maskImage: maskGradient } : {}"
|
|
130
|
-
>
|
|
131
|
-
<ClientOnly>
|
|
132
|
-
<div
|
|
133
|
-
class="aurora-effect pointer-events-none absolute -inset-2.5 h-full w-full will-change-transform animate-in fade-in duration-1000"
|
|
134
|
-
:style="{ opacity: auroraOpacityValue }"
|
|
135
|
-
/>
|
|
136
|
-
</ClientOnly>
|
|
137
|
-
</div>
|
|
138
|
-
|
|
139
|
-
<div class="relative z-10">
|
|
140
|
-
<slot />
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
143
|
-
</template>
|
|
144
|
-
|
|
145
|
-
<style scoped>
|
|
146
|
-
.aurora-effect{background-image:repeating-linear-gradient(100deg,v-bind(lineColor),v-bind(lineColor) 7%,transparent 10%,transparent 12%,v-bind(lineColor) 16%),v-bind(auroraGradient);background-size:200%,100%;filter:blur(v-bind(auroraBlur)) v-bind(filterInvert)}.aurora-effect,.aurora-effect:after{animation:aurora v-bind(animationDuration) linear infinite;animation-direction:v-bind(animationDirection);animation-play-state:v-bind(animationState);background-position:50% 50%,50% 50%}.aurora-effect:after{background-attachment:fixed;background-image:repeating-linear-gradient(100deg,v-bind(lineColorAfter),v-bind(lineColorAfter) 7%,transparent 10%,transparent 12%,v-bind(lineColorAfter) 16%),v-bind(auroraGradient);background-size:180%,100%;content:"";inset:0;mix-blend-mode:difference;opacity:v-bind(afterOpacity);position:absolute}@keyframes aurora{0%{background-position:50% 50%,50% 50%}to{background-position:350% 50%,350% 50%}}
|
|
147
|
-
</style>
|