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
|
@@ -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,120 +0,0 @@
|
|
|
1
|
-
import { type ColorInput } from "../../composables/useColorResolver.js";
|
|
2
|
-
import type { ComponentConfig } from "../../types/tv.js";
|
|
3
|
-
import backgroundFlickeringGridTheme from "../../themes/background-flickering-grid.js";
|
|
4
|
-
type BackgroundFlickeringGrid = ComponentConfig<typeof backgroundFlickeringGridTheme>;
|
|
5
|
-
/**
|
|
6
|
-
* FlickeringGrid - An animated canvas-based grid background component
|
|
7
|
-
*/
|
|
8
|
-
export interface FlickeringGridProps {
|
|
9
|
-
/**
|
|
10
|
-
* The square size of the grid (before scaling)
|
|
11
|
-
* @default 8
|
|
12
|
-
*/
|
|
13
|
-
size?: number;
|
|
14
|
-
/**
|
|
15
|
-
* The gap between grid squares
|
|
16
|
-
* @default 8
|
|
17
|
-
*/
|
|
18
|
-
gap?: number;
|
|
19
|
-
/**
|
|
20
|
-
* Animation speed (higher = faster flicker)
|
|
21
|
-
* Scale from 1 (slowest) to 10 (fastest)
|
|
22
|
-
* @default 5
|
|
23
|
-
*/
|
|
24
|
-
speed?: number;
|
|
25
|
-
/**
|
|
26
|
-
* Apply fade/vignette effect with directional masking
|
|
27
|
-
* - 'radial': Radial fade from center (spotlight effect)
|
|
28
|
-
* - 'left', 'right', 'top', 'bottom': Linear fade from specified edge
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
fade?: "radial" | "left" | "right" | "top" | "bottom";
|
|
32
|
-
/**
|
|
33
|
-
* Color for the grid. Supports:
|
|
34
|
-
* - Nuxt UI semantic: 'primary', 'secondary', 'success', 'info', 'warning', 'error', 'neutral'
|
|
35
|
-
* - Tailwind colors: 'blue-500', 'red-600', 'slate-200', etc.
|
|
36
|
-
* - Direct values: '#3b82f6', 'oklch(0.6 0.15 250)', 'rgb(59, 130, 246)'
|
|
37
|
-
*
|
|
38
|
-
* This controls the base hue/color of the grid. Use `lightness` to adjust how bright/washed out it appears.
|
|
39
|
-
*
|
|
40
|
-
* @example 'primary' - Nuxt UI semantic color
|
|
41
|
-
* @example 'blue-500' - Tailwind color
|
|
42
|
-
* @example '#3b82f6' - Direct hex color value
|
|
43
|
-
*
|
|
44
|
-
* @default 'neutral'
|
|
45
|
-
*/
|
|
46
|
-
color?: ColorInput;
|
|
47
|
-
/**
|
|
48
|
-
* Lightness adjustment in OKLCH color space (0-100).
|
|
49
|
-
*
|
|
50
|
-
* Controls how bright or washed-out the color appears WITHOUT changing transparency.
|
|
51
|
-
* This modifies the color itself, making it closer to white (higher values) or more saturated (lower values).
|
|
52
|
-
*
|
|
53
|
-
* Think of it as a "color brightness" slider:
|
|
54
|
-
* - Lower values (70-80): Darker, more saturated, vibrant colors
|
|
55
|
-
* - Medium values (85-92): Balanced, natural colors
|
|
56
|
-
* - Higher values (93-100): Very light, pastel, washed-out colors (approaching white)
|
|
57
|
-
*
|
|
58
|
-
* Use cases:
|
|
59
|
-
* - Subtle background: `color="blue-500" lightness={95}` → Very light blue tint
|
|
60
|
-
* - Bold accent: `color="blue-500" lightness={75}` → Vibrant, saturated blue
|
|
61
|
-
* - Combined with opacity: `lightness={90} opacity={0.3}` → Medium-tone color, very transparent
|
|
62
|
-
*
|
|
63
|
-
* Range: 0-100
|
|
64
|
-
* @default 95
|
|
65
|
-
*/
|
|
66
|
-
lightness?: number;
|
|
67
|
-
/**
|
|
68
|
-
* Opacity/transparency of the grid squares (0-100).
|
|
69
|
-
*
|
|
70
|
-
* Controls how see-through the grid is WITHOUT changing the color itself.
|
|
71
|
-
* This is pure transparency - the color stays the same, just more/less visible.
|
|
72
|
-
*
|
|
73
|
-
* Think of it as a "visibility" slider:
|
|
74
|
-
* - 0: Completely invisible (transparent)
|
|
75
|
-
* - 30: Very subtle, barely visible
|
|
76
|
-
* - 50: Medium visibility
|
|
77
|
-
* - 80: Bold, prominent
|
|
78
|
-
* - 100: Fully opaque, no transparency
|
|
79
|
-
*
|
|
80
|
-
* Use cases:
|
|
81
|
-
* - Gentle texture: `opacity={20}` → Barely visible background pattern
|
|
82
|
-
* - Strong effect: `opacity={80}` → Prominent, eye-catching grid
|
|
83
|
-
* - Combined with lightness: `lightness={95} opacity={50}` → Light color, medium transparency
|
|
84
|
-
*
|
|
85
|
-
* Range: 0-100
|
|
86
|
-
* @default 50
|
|
87
|
-
*/
|
|
88
|
-
opacity?: number;
|
|
89
|
-
/**
|
|
90
|
-
* Dark mode overrides for color, lightness, and opacity.
|
|
91
|
-
*
|
|
92
|
-
* Allows you to customize the grid appearance specifically for dark mode.
|
|
93
|
-
* Any property not specified will use the default light mode value.
|
|
94
|
-
*
|
|
95
|
-
* @example { color: 'blue-300', lightness: 90, opacity: 0.3 }
|
|
96
|
-
*/
|
|
97
|
-
dark?: {
|
|
98
|
-
color?: ColorInput;
|
|
99
|
-
lightness?: number;
|
|
100
|
-
opacity?: number;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* UI slot customization
|
|
104
|
-
*/
|
|
105
|
-
ui?: BackgroundFlickeringGrid["slots"];
|
|
106
|
-
}
|
|
107
|
-
export interface FlickeringGridSlots {
|
|
108
|
-
/**
|
|
109
|
-
* Default slot content rendered on top of the grid
|
|
110
|
-
*/
|
|
111
|
-
default(): any;
|
|
112
|
-
}
|
|
113
|
-
declare const _default: typeof __VLS_export;
|
|
114
|
-
export default _default;
|
|
115
|
-
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FlickeringGridProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FlickeringGridProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, FlickeringGridSlots>;
|
|
116
|
-
type __VLS_WithSlots<T, S> = T & {
|
|
117
|
-
new (): {
|
|
118
|
-
$slots: S;
|
|
119
|
-
};
|
|
120
|
-
};
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import backgroundFlickeringGridTheme from "../../themes/background-flickering-grid";
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<script setup>
|
|
6
|
-
import { ref, computed, onMounted, onBeforeUnmount, watch } from "vue";
|
|
7
|
-
import { useColorMode } from "#imports";
|
|
8
|
-
import { tv } from "../../utils/tv";
|
|
9
|
-
import theme from "../../themes/background-flickering-grid";
|
|
10
|
-
import { adjustLightness, darkenColor, oklchToRgb } from "../../composables/useThemeColors";
|
|
11
|
-
import {
|
|
12
|
-
resolveColor
|
|
13
|
-
} from "../../composables/useColorResolver";
|
|
14
|
-
const {
|
|
15
|
-
size = 8,
|
|
16
|
-
gap = 9,
|
|
17
|
-
speed = 5,
|
|
18
|
-
color = "neutral",
|
|
19
|
-
lightness = 95,
|
|
20
|
-
opacity = 50,
|
|
21
|
-
...props
|
|
22
|
-
} = defineProps({
|
|
23
|
-
size: { type: Number, required: false },
|
|
24
|
-
gap: { type: Number, required: false },
|
|
25
|
-
speed: { type: Number, required: false },
|
|
26
|
-
fade: { type: String, required: false },
|
|
27
|
-
color: { type: null, required: false },
|
|
28
|
-
lightness: { type: Number, required: false },
|
|
29
|
-
opacity: { type: Number, required: false },
|
|
30
|
-
dark: { type: Object, required: false },
|
|
31
|
-
ui: { type: null, required: false }
|
|
32
|
-
});
|
|
33
|
-
const colorMode = useColorMode();
|
|
34
|
-
const isDark = computed(() => colorMode.value === "dark");
|
|
35
|
-
const effectiveColor = computed(() => {
|
|
36
|
-
if (isDark.value && props.dark?.color) {
|
|
37
|
-
return props.dark.color;
|
|
38
|
-
}
|
|
39
|
-
return color;
|
|
40
|
-
});
|
|
41
|
-
const effectiveLightness = computed(() => {
|
|
42
|
-
if (isDark.value && props.dark?.lightness !== void 0) {
|
|
43
|
-
return props.dark.lightness;
|
|
44
|
-
}
|
|
45
|
-
return lightness;
|
|
46
|
-
});
|
|
47
|
-
const effectiveOpacity = computed(() => {
|
|
48
|
-
const opacityValue = isDark.value && props.dark?.opacity !== void 0 ? props.dark.opacity : opacity;
|
|
49
|
-
return opacityValue / 100;
|
|
50
|
-
});
|
|
51
|
-
const internalSpeed = computed(() => {
|
|
52
|
-
return speed * 0.01;
|
|
53
|
-
});
|
|
54
|
-
defineSlots();
|
|
55
|
-
const ui = computed(() => tv(theme)());
|
|
56
|
-
const maskStyle = computed(() => {
|
|
57
|
-
if (!props.fade) return {};
|
|
58
|
-
let maskImage;
|
|
59
|
-
switch (props.fade) {
|
|
60
|
-
case "radial":
|
|
61
|
-
maskImage = "radial-gradient(circle at center, black 20%, transparent 90%)";
|
|
62
|
-
break;
|
|
63
|
-
case "left":
|
|
64
|
-
maskImage = "linear-gradient(to right, transparent 0%, black 30%)";
|
|
65
|
-
break;
|
|
66
|
-
case "right":
|
|
67
|
-
maskImage = "linear-gradient(to left, transparent 0%, black 30%)";
|
|
68
|
-
break;
|
|
69
|
-
case "top":
|
|
70
|
-
maskImage = "linear-gradient(to bottom, transparent 0%, black 30%)";
|
|
71
|
-
break;
|
|
72
|
-
case "bottom":
|
|
73
|
-
maskImage = "linear-gradient(to top, transparent 0%, black 30%)";
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
return {};
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
maskImage,
|
|
80
|
-
WebkitMaskImage: maskImage
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
const containerRef = ref();
|
|
84
|
-
const canvasRef = ref();
|
|
85
|
-
const context = ref(null);
|
|
86
|
-
const isInView = ref(false);
|
|
87
|
-
const gridParams = ref(null);
|
|
88
|
-
function parseColor(color2) {
|
|
89
|
-
const match = color2.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
90
|
-
if (match && match[1] && match[2] && match[3]) {
|
|
91
|
-
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
92
|
-
}
|
|
93
|
-
return [255, 255, 255];
|
|
94
|
-
}
|
|
95
|
-
const gridColors = computed(() => {
|
|
96
|
-
const baseColor = resolveColor(effectiveColor.value);
|
|
97
|
-
const adjustedColor = adjustLightness(baseColor, effectiveLightness.value);
|
|
98
|
-
const baseRgb = oklchToRgb(adjustedColor);
|
|
99
|
-
const darkerColor = darkenColor(adjustedColor, 10);
|
|
100
|
-
const flickerRgb = oklchToRgb(darkerColor);
|
|
101
|
-
return {
|
|
102
|
-
base: parseColor(baseRgb),
|
|
103
|
-
flicker: parseColor(flickerRgb)
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
function lerp(a, b, t) {
|
|
107
|
-
return a + (b - a) * t;
|
|
108
|
-
}
|
|
109
|
-
function lerpColor(a, b, t) {
|
|
110
|
-
if (!a || a.length !== 3) a = [255, 255, 255];
|
|
111
|
-
if (!b || b.length !== 3) b = [255, 255, 255];
|
|
112
|
-
return [
|
|
113
|
-
Math.round(lerp(a[0], b[0], t)),
|
|
114
|
-
Math.round(lerp(a[1], b[1], t)),
|
|
115
|
-
Math.round(lerp(a[2], b[2], t))
|
|
116
|
-
];
|
|
117
|
-
}
|
|
118
|
-
function rgbToString(rgb, alpha = 1) {
|
|
119
|
-
return `rgba(${rgb[0]},${rgb[1]},${rgb[2]},${alpha})`;
|
|
120
|
-
}
|
|
121
|
-
function setupCanvas(canvas, width, height) {
|
|
122
|
-
const dpr = window.devicePixelRatio || 1;
|
|
123
|
-
canvas.width = width * dpr;
|
|
124
|
-
canvas.height = height * dpr;
|
|
125
|
-
canvas.style.width = `${width}px`;
|
|
126
|
-
canvas.style.height = `${height}px`;
|
|
127
|
-
const cols = Math.floor(width / (size + gap));
|
|
128
|
-
const rows = Math.floor(height / (size + gap));
|
|
129
|
-
const squares = new Float32Array(cols * rows);
|
|
130
|
-
for (let i = 0; i < squares.length; i++) {
|
|
131
|
-
squares[i] = Math.random() * effectiveOpacity.value;
|
|
132
|
-
}
|
|
133
|
-
return { cols, rows, squares, dpr };
|
|
134
|
-
}
|
|
135
|
-
function updateSquares(squares, deltaTime) {
|
|
136
|
-
for (let i = 0; i < squares.length; i++) {
|
|
137
|
-
if (Math.random() < internalSpeed.value * deltaTime) {
|
|
138
|
-
squares[i] = Math.random() * effectiveOpacity.value;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function drawGrid(ctx, canvasWidth, canvasHeight, cols, rows, squares, dpr) {
|
|
143
|
-
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
144
|
-
ctx.fillStyle = "transparent";
|
|
145
|
-
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
|
|
146
|
-
const colors = gridColors.value;
|
|
147
|
-
for (let i = 0; i < cols; i++) {
|
|
148
|
-
for (let j = 0; j < rows; j++) {
|
|
149
|
-
const idx = i * rows + j;
|
|
150
|
-
const opacity2 = squares[idx] ?? 0;
|
|
151
|
-
let cellColor = colors.base;
|
|
152
|
-
let cellAlpha = opacity2;
|
|
153
|
-
if (opacity2 > 0.5 * effectiveOpacity.value) {
|
|
154
|
-
const blendT = (opacity2 - 0.5 * effectiveOpacity.value) / (0.5 * effectiveOpacity.value);
|
|
155
|
-
cellColor = lerpColor(colors.base, colors.flicker, blendT);
|
|
156
|
-
cellAlpha = Math.min(1, opacity2 + 0.2);
|
|
157
|
-
}
|
|
158
|
-
ctx.fillStyle = rgbToString(cellColor, cellAlpha);
|
|
159
|
-
ctx.fillRect(
|
|
160
|
-
i * (size + gap) * dpr,
|
|
161
|
-
j * (size + gap) * dpr,
|
|
162
|
-
size * dpr,
|
|
163
|
-
size * dpr
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
function updateCanvasSize() {
|
|
169
|
-
const newWidth = containerRef.value?.clientWidth || 0;
|
|
170
|
-
const newHeight = containerRef.value?.clientHeight || 0;
|
|
171
|
-
if (canvasRef.value) {
|
|
172
|
-
gridParams.value = setupCanvas(canvasRef.value, newWidth, newHeight);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
let animationFrameId;
|
|
176
|
-
let resizeObserver;
|
|
177
|
-
let intersectionObserver;
|
|
178
|
-
let lastTime = 0;
|
|
179
|
-
function animate(time) {
|
|
180
|
-
if (!isInView.value || !gridParams.value || !context.value) return;
|
|
181
|
-
const deltaTime = (time - lastTime) / 1e3;
|
|
182
|
-
lastTime = time;
|
|
183
|
-
updateSquares(gridParams.value.squares, deltaTime);
|
|
184
|
-
drawGrid(
|
|
185
|
-
context.value,
|
|
186
|
-
canvasRef.value.width,
|
|
187
|
-
canvasRef.value.height,
|
|
188
|
-
gridParams.value.cols,
|
|
189
|
-
gridParams.value.rows,
|
|
190
|
-
gridParams.value.squares,
|
|
191
|
-
gridParams.value.dpr
|
|
192
|
-
);
|
|
193
|
-
animationFrameId = requestAnimationFrame(animate);
|
|
194
|
-
}
|
|
195
|
-
onMounted(() => {
|
|
196
|
-
if (!canvasRef.value || !containerRef.value) return;
|
|
197
|
-
context.value = canvasRef.value.getContext("2d");
|
|
198
|
-
if (!context.value) return;
|
|
199
|
-
updateCanvasSize();
|
|
200
|
-
resizeObserver = new ResizeObserver(() => {
|
|
201
|
-
updateCanvasSize();
|
|
202
|
-
});
|
|
203
|
-
intersectionObserver = new IntersectionObserver(
|
|
204
|
-
(entries) => {
|
|
205
|
-
const entry = entries[0];
|
|
206
|
-
if (!entry) return;
|
|
207
|
-
isInView.value = entry.isIntersecting;
|
|
208
|
-
if (isInView.value) {
|
|
209
|
-
lastTime = performance.now();
|
|
210
|
-
animationFrameId = requestAnimationFrame(animate);
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
{ threshold: 0 }
|
|
214
|
-
);
|
|
215
|
-
resizeObserver.observe(containerRef.value);
|
|
216
|
-
intersectionObserver.observe(canvasRef.value);
|
|
217
|
-
});
|
|
218
|
-
onBeforeUnmount(() => {
|
|
219
|
-
if (animationFrameId) cancelAnimationFrame(animationFrameId);
|
|
220
|
-
resizeObserver?.disconnect();
|
|
221
|
-
intersectionObserver?.disconnect();
|
|
222
|
-
});
|
|
223
|
-
watch(
|
|
224
|
-
[
|
|
225
|
-
() => size,
|
|
226
|
-
() => gap,
|
|
227
|
-
() => color,
|
|
228
|
-
() => lightness,
|
|
229
|
-
() => opacity,
|
|
230
|
-
() => props.dark?.color,
|
|
231
|
-
() => props.dark?.lightness,
|
|
232
|
-
() => props.dark?.opacity
|
|
233
|
-
],
|
|
234
|
-
() => {
|
|
235
|
-
updateCanvasSize();
|
|
236
|
-
}
|
|
237
|
-
);
|
|
238
|
-
</script>
|
|
239
|
-
|
|
240
|
-
<template>
|
|
241
|
-
<div ref="containerRef" :class="ui.base({ class: [props.ui?.base] })">
|
|
242
|
-
<ClientOnly>
|
|
243
|
-
<canvas ref="canvasRef" :class="ui.canvas({ class: props.ui?.canvas })" :style="maskStyle" />
|
|
244
|
-
</ClientOnly>
|
|
245
|
-
<slot />
|
|
246
|
-
</div>
|
|
247
|
-
</template>
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { type ColorInput } from "../../composables/useColorResolver.js";
|
|
2
|
-
import type { ComponentConfig } from "../../types/tv.js";
|
|
3
|
-
import backgroundFlickeringGridTheme from "../../themes/background-flickering-grid.js";
|
|
4
|
-
type BackgroundFlickeringGrid = ComponentConfig<typeof backgroundFlickeringGridTheme>;
|
|
5
|
-
/**
|
|
6
|
-
* FlickeringGrid - An animated canvas-based grid background component
|
|
7
|
-
*/
|
|
8
|
-
export interface FlickeringGridProps {
|
|
9
|
-
/**
|
|
10
|
-
* The square size of the grid (before scaling)
|
|
11
|
-
* @default 8
|
|
12
|
-
*/
|
|
13
|
-
size?: number;
|
|
14
|
-
/**
|
|
15
|
-
* The gap between grid squares
|
|
16
|
-
* @default 8
|
|
17
|
-
*/
|
|
18
|
-
gap?: number;
|
|
19
|
-
/**
|
|
20
|
-
* Animation speed (higher = faster flicker)
|
|
21
|
-
* Scale from 1 (slowest) to 10 (fastest)
|
|
22
|
-
* @default 5
|
|
23
|
-
*/
|
|
24
|
-
speed?: number;
|
|
25
|
-
/**
|
|
26
|
-
* Apply fade/vignette effect with directional masking
|
|
27
|
-
* - 'radial': Radial fade from center (spotlight effect)
|
|
28
|
-
* - 'left', 'right', 'top', 'bottom': Linear fade from specified edge
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
fade?: "radial" | "left" | "right" | "top" | "bottom";
|
|
32
|
-
/**
|
|
33
|
-
* Color for the grid. Supports:
|
|
34
|
-
* - Nuxt UI semantic: 'primary', 'secondary', 'success', 'info', 'warning', 'error', 'neutral'
|
|
35
|
-
* - Tailwind colors: 'blue-500', 'red-600', 'slate-200', etc.
|
|
36
|
-
* - Direct values: '#3b82f6', 'oklch(0.6 0.15 250)', 'rgb(59, 130, 246)'
|
|
37
|
-
*
|
|
38
|
-
* This controls the base hue/color of the grid. Use `lightness` to adjust how bright/washed out it appears.
|
|
39
|
-
*
|
|
40
|
-
* @example 'primary' - Nuxt UI semantic color
|
|
41
|
-
* @example 'blue-500' - Tailwind color
|
|
42
|
-
* @example '#3b82f6' - Direct hex color value
|
|
43
|
-
*
|
|
44
|
-
* @default 'neutral'
|
|
45
|
-
*/
|
|
46
|
-
color?: ColorInput;
|
|
47
|
-
/**
|
|
48
|
-
* Lightness adjustment in OKLCH color space (0-100).
|
|
49
|
-
*
|
|
50
|
-
* Controls how bright or washed-out the color appears WITHOUT changing transparency.
|
|
51
|
-
* This modifies the color itself, making it closer to white (higher values) or more saturated (lower values).
|
|
52
|
-
*
|
|
53
|
-
* Think of it as a "color brightness" slider:
|
|
54
|
-
* - Lower values (70-80): Darker, more saturated, vibrant colors
|
|
55
|
-
* - Medium values (85-92): Balanced, natural colors
|
|
56
|
-
* - Higher values (93-100): Very light, pastel, washed-out colors (approaching white)
|
|
57
|
-
*
|
|
58
|
-
* Use cases:
|
|
59
|
-
* - Subtle background: `color="blue-500" lightness={95}` → Very light blue tint
|
|
60
|
-
* - Bold accent: `color="blue-500" lightness={75}` → Vibrant, saturated blue
|
|
61
|
-
* - Combined with opacity: `lightness={90} opacity={0.3}` → Medium-tone color, very transparent
|
|
62
|
-
*
|
|
63
|
-
* Range: 0-100
|
|
64
|
-
* @default 95
|
|
65
|
-
*/
|
|
66
|
-
lightness?: number;
|
|
67
|
-
/**
|
|
68
|
-
* Opacity/transparency of the grid squares (0-100).
|
|
69
|
-
*
|
|
70
|
-
* Controls how see-through the grid is WITHOUT changing the color itself.
|
|
71
|
-
* This is pure transparency - the color stays the same, just more/less visible.
|
|
72
|
-
*
|
|
73
|
-
* Think of it as a "visibility" slider:
|
|
74
|
-
* - 0: Completely invisible (transparent)
|
|
75
|
-
* - 30: Very subtle, barely visible
|
|
76
|
-
* - 50: Medium visibility
|
|
77
|
-
* - 80: Bold, prominent
|
|
78
|
-
* - 100: Fully opaque, no transparency
|
|
79
|
-
*
|
|
80
|
-
* Use cases:
|
|
81
|
-
* - Gentle texture: `opacity={20}` → Barely visible background pattern
|
|
82
|
-
* - Strong effect: `opacity={80}` → Prominent, eye-catching grid
|
|
83
|
-
* - Combined with lightness: `lightness={95} opacity={50}` → Light color, medium transparency
|
|
84
|
-
*
|
|
85
|
-
* Range: 0-100
|
|
86
|
-
* @default 50
|
|
87
|
-
*/
|
|
88
|
-
opacity?: number;
|
|
89
|
-
/**
|
|
90
|
-
* Dark mode overrides for color, lightness, and opacity.
|
|
91
|
-
*
|
|
92
|
-
* Allows you to customize the grid appearance specifically for dark mode.
|
|
93
|
-
* Any property not specified will use the default light mode value.
|
|
94
|
-
*
|
|
95
|
-
* @example { color: 'blue-300', lightness: 90, opacity: 0.3 }
|
|
96
|
-
*/
|
|
97
|
-
dark?: {
|
|
98
|
-
color?: ColorInput;
|
|
99
|
-
lightness?: number;
|
|
100
|
-
opacity?: number;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* UI slot customization
|
|
104
|
-
*/
|
|
105
|
-
ui?: BackgroundFlickeringGrid["slots"];
|
|
106
|
-
}
|
|
107
|
-
export interface FlickeringGridSlots {
|
|
108
|
-
/**
|
|
109
|
-
* Default slot content rendered on top of the grid
|
|
110
|
-
*/
|
|
111
|
-
default(): any;
|
|
112
|
-
}
|
|
113
|
-
declare const _default: typeof __VLS_export;
|
|
114
|
-
export default _default;
|
|
115
|
-
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FlickeringGridProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FlickeringGridProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, FlickeringGridSlots>;
|
|
116
|
-
type __VLS_WithSlots<T, S> = T & {
|
|
117
|
-
new (): {
|
|
118
|
-
$slots: S;
|
|
119
|
-
};
|
|
120
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import colors from "tailwindcss/colors";
|
|
2
|
-
/**
|
|
3
|
-
* Nuxt UI semantic colors
|
|
4
|
-
*/
|
|
5
|
-
declare const SEMANTIC_COLORS: readonly ["primary", "secondary", "success", "info", "warning", "error", "neutral"];
|
|
6
|
-
export type SemanticColor = (typeof SEMANTIC_COLORS)[number];
|
|
7
|
-
/**
|
|
8
|
-
* Tailwind color names
|
|
9
|
-
*/
|
|
10
|
-
type TailwindColorName = keyof typeof colors;
|
|
11
|
-
/**
|
|
12
|
-
* Tailwind color shades
|
|
13
|
-
*/
|
|
14
|
-
type TailwindShade = "50" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | "950";
|
|
15
|
-
/**
|
|
16
|
-
* Tailwind color format: colorName-shade (e.g., 'blue-500', 'red-600')
|
|
17
|
-
*/
|
|
18
|
-
export type TailwindColor = `${TailwindColorName}-${TailwindShade}`;
|
|
19
|
-
/**
|
|
20
|
-
* Supported color input formats
|
|
21
|
-
*/
|
|
22
|
-
export type ColorInput = SemanticColor | TailwindColor | (string & {});
|
|
23
|
-
/**
|
|
24
|
-
* Resolve a color input to an actual color value
|
|
25
|
-
* Supports:
|
|
26
|
-
* - Nuxt UI semantic colors: 'primary', 'secondary', etc.
|
|
27
|
-
* - Tailwind colors: 'blue-500', 'red-600', etc.
|
|
28
|
-
* - Direct color values: '#3b82f6', 'oklch(0.6 0.15 250)', etc.
|
|
29
|
-
*
|
|
30
|
-
* @param colorInput - The color string to resolve
|
|
31
|
-
* @param fallback - Fallback color if resolution fails (default: 'neutral')
|
|
32
|
-
* @returns The resolved color value
|
|
33
|
-
*/
|
|
34
|
-
export declare function resolveColor(colorInput: string | undefined, fallback?: SemanticColor): string;
|
|
35
|
-
/**
|
|
36
|
-
* Resolve a color and ensure it returns an OKLCH string
|
|
37
|
-
* Useful when you need consistent color space for manipulation
|
|
38
|
-
*/
|
|
39
|
-
export declare function resolveColorAsOklch(colorInput: string | undefined, fallback?: SemanticColor): string;
|
|
40
|
-
export {};
|