@mkbabb/glass-ui 0.2.0
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/README.md +172 -0
- package/dist/glass-ui.css +1 -0
- package/dist/glass-ui.js +10019 -0
- package/dist/index.d.ts +6619 -0
- package/package.json +65 -0
- package/src/components/custom/aurora/Aurora.vue +34 -0
- package/src/components/custom/aurora/composables/color.ts +122 -0
- package/src/components/custom/aurora/composables/useAurora.ts +355 -0
- package/src/components/custom/aurora/index.ts +8 -0
- package/src/components/custom/confirm-dialog/ConfirmDialog.vue +88 -0
- package/src/components/custom/confirm-dialog/index.ts +1 -0
- package/src/components/custom/controls/DarkModeToggle.vue +96 -0
- package/src/components/custom/controls/index.ts +1 -0
- package/src/components/custom/dock/DockLayerGroup.vue +21 -0
- package/src/components/custom/dock/DockPopover.vue +263 -0
- package/src/components/custom/dock/GlassDock.vue +276 -0
- package/src/components/custom/dock/composables/index.ts +16 -0
- package/src/components/custom/dock/composables/isTeleportedTarget.ts +19 -0
- package/src/components/custom/dock/composables/useDockActionBar.ts +33 -0
- package/src/components/custom/dock/composables/useDockState.ts +301 -0
- package/src/components/custom/dock/composables/useDockTransition.ts +146 -0
- package/src/components/custom/dock/composables/useLayerTransition.ts +135 -0
- package/src/components/custom/dock/composables/usePopupMutex.ts +83 -0
- package/src/components/custom/dock/index.ts +9 -0
- package/src/components/custom/expandable-container/ExpandableContainer.vue +64 -0
- package/src/components/custom/expandable-container/index.ts +1 -0
- package/src/components/custom/glass-panel/GlassPanel.vue +98 -0
- package/src/components/custom/glass-panel/index.ts +2 -0
- package/src/components/custom/icon-tooltip/IconTooltip.vue +20 -0
- package/src/components/custom/icon-tooltip/index.ts +1 -0
- package/src/components/custom/index.ts +15 -0
- package/src/components/custom/infinite-scroll/InfiniteScroll.vue +55 -0
- package/src/components/custom/infinite-scroll/composables/index.ts +2 -0
- package/src/components/custom/infinite-scroll/composables/types.ts +23 -0
- package/src/components/custom/infinite-scroll/composables/useInfiniteScroll.ts +73 -0
- package/src/components/custom/infinite-scroll/index.ts +1 -0
- package/src/components/custom/labeled-field/LabeledInput.vue +29 -0
- package/src/components/custom/labeled-field/LabeledSelect.vue +59 -0
- package/src/components/custom/labeled-field/LabeledSlider.vue +32 -0
- package/src/components/custom/labeled-field/LabeledSwitch.vue +27 -0
- package/src/components/custom/labeled-field/index.ts +4 -0
- package/src/components/custom/metaballs/MetaballCanvas.vue +23 -0
- package/src/components/custom/metaballs/index.ts +4 -0
- package/src/components/custom/metaballs/shaders.ts +63 -0
- package/src/components/custom/metaballs/types.ts +29 -0
- package/src/components/custom/metaballs/useMetaballs.ts +252 -0
- package/src/components/custom/search/FuzzySearch.vue +589 -0
- package/src/components/custom/search/SearchBar.vue +44 -0
- package/src/components/custom/search/composables/fuzzySearchIndex.ts +224 -0
- package/src/components/custom/search/composables/index.ts +5 -0
- package/src/components/custom/search/composables/types.ts +34 -0
- package/src/components/custom/search/composables/useFuzzySearch.ts +115 -0
- package/src/components/custom/search/index.ts +7 -0
- package/src/components/custom/sidebar/ProgressiveSidebar.vue +256 -0
- package/src/components/custom/sidebar/composables/index.ts +6 -0
- package/src/components/custom/sidebar/composables/useScrollTracker.ts +242 -0
- package/src/components/custom/sidebar/composables/useSidebarFollow.ts +247 -0
- package/src/components/custom/sidebar/composables/useSidebarState.ts +72 -0
- package/src/components/custom/sidebar/composables/useTreeIndex.ts +152 -0
- package/src/components/custom/sidebar/index.ts +15 -0
- package/src/components/custom/sidebar/types.ts +50 -0
- package/src/components/custom/tabs/BouncyTabs.vue +39 -0
- package/src/components/custom/tabs/BouncyToggle.vue +352 -0
- package/src/components/custom/tabs/UnderlineTabs.vue +115 -0
- package/src/components/custom/tabs/index.ts +5 -0
- package/src/components/custom/timeline/GlassTimeline.vue +174 -0
- package/src/components/custom/timeline/index.ts +1 -0
- package/src/components/custom/typewriter/TypewriterText.vue +239 -0
- package/src/components/custom/typewriter/composables/index.ts +1 -0
- package/src/components/custom/typewriter/composables/useTypewriter.ts +413 -0
- package/src/components/custom/typewriter/index.ts +7 -0
- package/src/components/custom/typewriter/types.ts +159 -0
- package/src/components/custom/typewriter/utils/keyboard.ts +213 -0
- package/src/components/custom/typewriter/utils/pausePatterns.ts +55 -0
- package/src/components/custom/typewriter/utils/timing.ts +104 -0
- package/src/components/custom/typewriter/utils/typoStateMachine.ts +197 -0
- package/src/components/index.ts +2 -0
- package/src/components/ui/accordion/Accordion.vue +19 -0
- package/src/components/ui/accordion/AccordionContent.vue +24 -0
- package/src/components/ui/accordion/AccordionItem.vue +24 -0
- package/src/components/ui/accordion/AccordionTrigger.vue +39 -0
- package/src/components/ui/accordion/index.ts +4 -0
- package/src/components/ui/alert/Alert.vue +20 -0
- package/src/components/ui/alert/AlertDescription.vue +17 -0
- package/src/components/ui/alert/AlertTitle.vue +17 -0
- package/src/components/ui/alert/index.ts +23 -0
- package/src/components/ui/avatar/Avatar.vue +21 -0
- package/src/components/ui/avatar/AvatarFallback.vue +11 -0
- package/src/components/ui/avatar/AvatarImage.vue +9 -0
- package/src/components/ui/avatar/index.ts +24 -0
- package/src/components/ui/badge/Badge.vue +16 -0
- package/src/components/ui/badge/index.ts +25 -0
- package/src/components/ui/button/Button.vue +26 -0
- package/src/components/ui/button/index.ts +43 -0
- package/src/components/ui/card/Card.vue +28 -0
- package/src/components/ui/card/CardContent.vue +14 -0
- package/src/components/ui/card/CardDescription.vue +14 -0
- package/src/components/ui/card/CardFooter.vue +14 -0
- package/src/components/ui/card/CardHeader.vue +14 -0
- package/src/components/ui/card/CardTitle.vue +21 -0
- package/src/components/ui/card/index.ts +6 -0
- package/src/components/ui/carousel/Carousel.vue +53 -0
- package/src/components/ui/carousel/CarouselContent.vue +35 -0
- package/src/components/ui/carousel/CarouselItem.vue +24 -0
- package/src/components/ui/carousel/CarouselNext.vue +40 -0
- package/src/components/ui/carousel/CarouselPrevious.vue +40 -0
- package/src/components/ui/carousel/index.ts +10 -0
- package/src/components/ui/carousel/interface.ts +26 -0
- package/src/components/ui/carousel/useCarousel.ts +56 -0
- package/src/components/ui/checkbox/Checkbox.vue +33 -0
- package/src/components/ui/checkbox/index.ts +1 -0
- package/src/components/ui/collapsible/Collapsible.vue +15 -0
- package/src/components/ui/collapsible/CollapsibleContent.vue +11 -0
- package/src/components/ui/collapsible/CollapsibleTrigger.vue +11 -0
- package/src/components/ui/collapsible/index.ts +3 -0
- package/src/components/ui/combobox/Combobox.vue +17 -0
- package/src/components/ui/combobox/ComboboxAnchor.vue +23 -0
- package/src/components/ui/combobox/ComboboxEmpty.vue +21 -0
- package/src/components/ui/combobox/ComboboxGroup.vue +27 -0
- package/src/components/ui/combobox/ComboboxInput.vue +41 -0
- package/src/components/ui/combobox/ComboboxItem.vue +24 -0
- package/src/components/ui/combobox/ComboboxItemIndicator.vue +23 -0
- package/src/components/ui/combobox/ComboboxList.vue +29 -0
- package/src/components/ui/combobox/ComboboxSeparator.vue +21 -0
- package/src/components/ui/combobox/ComboboxViewport.vue +23 -0
- package/src/components/ui/combobox/index.ts +12 -0
- package/src/components/ui/command/Command.vue +30 -0
- package/src/components/ui/command/CommandDialog.vue +21 -0
- package/src/components/ui/command/CommandEmpty.vue +20 -0
- package/src/components/ui/command/CommandGroup.vue +29 -0
- package/src/components/ui/command/CommandInput.vue +33 -0
- package/src/components/ui/command/CommandItem.vue +26 -0
- package/src/components/ui/command/CommandList.vue +27 -0
- package/src/components/ui/command/CommandSeparator.vue +23 -0
- package/src/components/ui/command/CommandShortcut.vue +14 -0
- package/src/components/ui/command/index.ts +9 -0
- package/src/components/ui/context-menu/ContextMenu.vue +15 -0
- package/src/components/ui/context-menu/ContextMenuCheckboxItem.vue +40 -0
- package/src/components/ui/context-menu/ContextMenuContent.vue +36 -0
- package/src/components/ui/context-menu/ContextMenuGroup.vue +11 -0
- package/src/components/ui/context-menu/ContextMenuItem.vue +34 -0
- package/src/components/ui/context-menu/ContextMenuLabel.vue +25 -0
- package/src/components/ui/context-menu/ContextMenuPortal.vue +11 -0
- package/src/components/ui/context-menu/ContextMenuRadioGroup.vue +19 -0
- package/src/components/ui/context-menu/ContextMenuRadioItem.vue +40 -0
- package/src/components/ui/context-menu/ContextMenuSeparator.vue +20 -0
- package/src/components/ui/context-menu/ContextMenuShortcut.vue +14 -0
- package/src/components/ui/context-menu/ContextMenuSub.vue +19 -0
- package/src/components/ui/context-menu/ContextMenuSubContent.vue +35 -0
- package/src/components/ui/context-menu/ContextMenuSubTrigger.vue +34 -0
- package/src/components/ui/context-menu/ContextMenuTrigger.vue +13 -0
- package/src/components/ui/context-menu/index.ts +14 -0
- package/src/components/ui/data-table/DataTable.vue +167 -0
- package/src/components/ui/data-table/DataTablePagination.vue +112 -0
- package/src/components/ui/data-table/index.ts +3 -0
- package/src/components/ui/data-table/types.ts +48 -0
- package/src/components/ui/dialog/Dialog.vue +14 -0
- package/src/components/ui/dialog/DialogClose.vue +11 -0
- package/src/components/ui/dialog/DialogContent.vue +61 -0
- package/src/components/ui/dialog/DialogDescription.vue +24 -0
- package/src/components/ui/dialog/DialogFooter.vue +19 -0
- package/src/components/ui/dialog/DialogHeader.vue +16 -0
- package/src/components/ui/dialog/DialogScrollContent.vue +65 -0
- package/src/components/ui/dialog/DialogTitle.vue +29 -0
- package/src/components/ui/dialog/DialogTrigger.vue +11 -0
- package/src/components/ui/dialog/index.ts +9 -0
- package/src/components/ui/drawer/Drawer.vue +19 -0
- package/src/components/ui/drawer/DrawerContent.vue +28 -0
- package/src/components/ui/drawer/DrawerDescription.vue +20 -0
- package/src/components/ui/drawer/DrawerFooter.vue +14 -0
- package/src/components/ui/drawer/DrawerHeader.vue +14 -0
- package/src/components/ui/drawer/DrawerOverlay.vue +18 -0
- package/src/components/ui/drawer/DrawerTitle.vue +20 -0
- package/src/components/ui/drawer/index.ts +8 -0
- package/src/components/ui/dropdown-menu/DropdownMenu.vue +14 -0
- package/src/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +40 -0
- package/src/components/ui/dropdown-menu/DropdownMenuContent.vue +44 -0
- package/src/components/ui/dropdown-menu/DropdownMenuGroup.vue +11 -0
- package/src/components/ui/dropdown-menu/DropdownMenuItem.vue +28 -0
- package/src/components/ui/dropdown-menu/DropdownMenuLabel.vue +24 -0
- package/src/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +19 -0
- package/src/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +40 -0
- package/src/components/ui/dropdown-menu/DropdownMenuSeparator.vue +22 -0
- package/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue +14 -0
- package/src/components/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
- package/src/components/ui/dropdown-menu/DropdownMenuSubContent.vue +36 -0
- package/src/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +33 -0
- package/src/components/ui/dropdown-menu/DropdownMenuTrigger.vue +13 -0
- package/src/components/ui/dropdown-menu/index.ts +16 -0
- package/src/components/ui/hover-card/HoverCard.vue +14 -0
- package/src/components/ui/hover-card/HoverCardContent.vue +41 -0
- package/src/components/ui/hover-card/HoverCardTrigger.vue +11 -0
- package/src/components/ui/hover-card/index.ts +3 -0
- package/src/components/ui/index.ts +41 -0
- package/src/components/ui/input/Input.vue +24 -0
- package/src/components/ui/input/index.ts +1 -0
- package/src/components/ui/label/Label.vue +27 -0
- package/src/components/ui/label/index.ts +1 -0
- package/src/components/ui/multi-select/MultiSelect.vue +141 -0
- package/src/components/ui/multi-select/index.ts +7 -0
- package/src/components/ui/notification/Notification.vue +85 -0
- package/src/components/ui/notification/index.ts +1 -0
- package/src/components/ui/number-field/NumberField.vue +23 -0
- package/src/components/ui/number-field/NumberFieldContent.vue +14 -0
- package/src/components/ui/number-field/NumberFieldDecrement.vue +25 -0
- package/src/components/ui/number-field/NumberFieldIncrement.vue +25 -0
- package/src/components/ui/number-field/NumberFieldInput.vue +8 -0
- package/src/components/ui/number-field/index.ts +5 -0
- package/src/components/ui/popover/Popover.vue +15 -0
- package/src/components/ui/popover/PopoverContent.vue +61 -0
- package/src/components/ui/popover/PopoverTrigger.vue +11 -0
- package/src/components/ui/popover/index.ts +3 -0
- package/src/components/ui/progress/Progress.vue +39 -0
- package/src/components/ui/progress/index.ts +1 -0
- package/src/components/ui/radio-group/RadioGroup.vue +25 -0
- package/src/components/ui/radio-group/RadioGroupItem.vue +39 -0
- package/src/components/ui/radio-group/index.ts +2 -0
- package/src/components/ui/scroll-area/ScrollArea.vue +29 -0
- package/src/components/ui/scroll-area/ScrollBar.vue +30 -0
- package/src/components/ui/scroll-area/index.ts +2 -0
- package/src/components/ui/scroll-pane/ScrollPane.vue +25 -0
- package/src/components/ui/scroll-pane/ScrollPaneHeader.vue +75 -0
- package/src/components/ui/scroll-pane/index.ts +2 -0
- package/src/components/ui/select/Select.vue +15 -0
- package/src/components/ui/select/SelectContent.vue +57 -0
- package/src/components/ui/select/SelectGroup.vue +19 -0
- package/src/components/ui/select/SelectItem.vue +47 -0
- package/src/components/ui/select/SelectItemText.vue +11 -0
- package/src/components/ui/select/SelectLabel.vue +13 -0
- package/src/components/ui/select/SelectScrollDownButton.vue +24 -0
- package/src/components/ui/select/SelectScrollUpButton.vue +24 -0
- package/src/components/ui/select/SelectSeparator.vue +17 -0
- package/src/components/ui/select/SelectTrigger.vue +45 -0
- package/src/components/ui/select/SelectValue.vue +11 -0
- package/src/components/ui/select/index.ts +11 -0
- package/src/components/ui/separator/Separator.vue +35 -0
- package/src/components/ui/separator/index.ts +1 -0
- package/src/components/ui/sheet/Sheet.vue +14 -0
- package/src/components/ui/sheet/SheetClose.vue +11 -0
- package/src/components/ui/sheet/SheetContent.vue +56 -0
- package/src/components/ui/sheet/SheetDescription.vue +22 -0
- package/src/components/ui/sheet/SheetFooter.vue +19 -0
- package/src/components/ui/sheet/SheetHeader.vue +16 -0
- package/src/components/ui/sheet/SheetTitle.vue +22 -0
- package/src/components/ui/sheet/SheetTrigger.vue +11 -0
- package/src/components/ui/sheet/index.ts +31 -0
- package/src/components/ui/skeleton/Skeleton.vue +14 -0
- package/src/components/ui/skeleton/index.ts +1 -0
- package/src/components/ui/slider/Slider.vue +66 -0
- package/src/components/ui/slider/index.ts +1 -0
- package/src/components/ui/switch/Switch.vue +37 -0
- package/src/components/ui/switch/index.ts +1 -0
- package/src/components/ui/table/Table.vue +16 -0
- package/src/components/ui/table/TableBody.vue +14 -0
- package/src/components/ui/table/TableCaption.vue +14 -0
- package/src/components/ui/table/TableCell.vue +14 -0
- package/src/components/ui/table/TableEmpty.vue +39 -0
- package/src/components/ui/table/TableFooter.vue +16 -0
- package/src/components/ui/table/TableHead.vue +21 -0
- package/src/components/ui/table/TableHeader.vue +14 -0
- package/src/components/ui/table/TableRow.vue +21 -0
- package/src/components/ui/table/index.ts +9 -0
- package/src/components/ui/tabs/Tabs.vue +15 -0
- package/src/components/ui/tabs/TabsContent.vue +22 -0
- package/src/components/ui/tabs/TabsIndicator.vue +22 -0
- package/src/components/ui/tabs/TabsList.vue +25 -0
- package/src/components/ui/tabs/TabsTrigger.vue +29 -0
- package/src/components/ui/tabs/index.ts +5 -0
- package/src/components/ui/tags-input/TagsInput.vue +22 -0
- package/src/components/ui/tags-input/TagsInputInput.vue +19 -0
- package/src/components/ui/tags-input/TagsInputItem.vue +22 -0
- package/src/components/ui/tags-input/TagsInputItemDelete.vue +24 -0
- package/src/components/ui/tags-input/TagsInputItemText.vue +19 -0
- package/src/components/ui/tags-input/index.ts +5 -0
- package/src/components/ui/textarea/Textarea.vue +24 -0
- package/src/components/ui/textarea/index.ts +1 -0
- package/src/components/ui/toast/Toast.vue +57 -0
- package/src/components/ui/toast/ToastAction.vue +30 -0
- package/src/components/ui/toast/ToastClose.vue +31 -0
- package/src/components/ui/toast/ToastDescription.vue +25 -0
- package/src/components/ui/toast/ToastTitle.vue +25 -0
- package/src/components/ui/toast/Toaster.vue +31 -0
- package/src/components/ui/toast/index.ts +8 -0
- package/src/components/ui/toast/use-toast.ts +136 -0
- package/src/components/ui/toggle/Toggle.vue +35 -0
- package/src/components/ui/toggle/index.ts +27 -0
- package/src/components/ui/toggle-group/ToggleGroup.vue +34 -0
- package/src/components/ui/toggle-group/ToggleGroupItem.vue +35 -0
- package/src/components/ui/toggle-group/index.ts +2 -0
- package/src/components/ui/tooltip/Tooltip.vue +14 -0
- package/src/components/ui/tooltip/TooltipContent.vue +31 -0
- package/src/components/ui/tooltip/TooltipProvider.vue +11 -0
- package/src/components/ui/tooltip/TooltipTrigger.vue +11 -0
- package/src/components/ui/tooltip/index.ts +4 -0
- package/src/composables/glass/index.ts +8 -0
- package/src/composables/glass/useGlassRenderer.ts +252 -0
- package/src/composables/glass/webgl/frostShader.ts +221 -0
- package/src/composables/glass/webgpu/glassShader.wgsl +173 -0
- package/src/composables/index.ts +32 -0
- package/src/composables/infinite-scroll/index.ts +2 -0
- package/src/composables/infinite-scroll/types.ts +25 -0
- package/src/composables/infinite-scroll/useInfiniteScroll.ts +101 -0
- package/src/composables/interaction/index.ts +5 -0
- package/src/composables/interaction/useHeightTransition.ts +82 -0
- package/src/composables/interaction/useHoverPopover.ts +64 -0
- package/src/composables/interaction/useHoverToggle.ts +103 -0
- package/src/composables/interaction/useLeaveTimer.ts +17 -0
- package/src/composables/interaction/useTouchGate.ts +207 -0
- package/src/composables/pagination/index.ts +2 -0
- package/src/composables/pagination/useOffsetPagination.ts +70 -0
- package/src/composables/prng.ts +32 -0
- package/src/composables/useCharSplit.ts +31 -0
- package/src/composables/useClipboard.ts +46 -0
- package/src/composables/useGlobalDark.ts +61 -0
- package/src/composables/useKeyboardShortcuts.ts +205 -0
- package/src/composables/useWatercolorBlob.ts +136 -0
- package/src/composables/virtual/index.ts +22 -0
- package/src/composables/virtual/useVirtualSectionWindow.ts +338 -0
- package/src/composables/virtual/useWindowedStore.ts +86 -0
- package/src/composables/virtual/virtualSectionLayout.ts +212 -0
- package/src/index.ts +9 -0
- package/src/styles/animations.css +233 -0
- package/src/styles/cards.css +66 -0
- package/src/styles/dock.css +221 -0
- package/src/styles/floating-panel.css +49 -0
- package/src/styles/glass.css +266 -0
- package/src/styles/index.css +26 -0
- package/src/styles/scroll-pane.css +10 -0
- package/src/styles/theme.css +138 -0
- package/src/styles/tokens.css +333 -0
- package/src/styles/transitions.css +226 -0
- package/src/styles/typography.css +277 -0
- package/src/styles/utilities.css +697 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/index.ts +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mkbabb/glass-ui",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Glassmorphic design system — Vue 3.5 components, reka-ui primitives, Tailwind CSS v4 tokens",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"*.css"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./src/index.ts"
|
|
14
|
+
},
|
|
15
|
+
"./styles": "./src/styles/index.css",
|
|
16
|
+
"./styles/*": "./src/styles/*"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"dev": "vite",
|
|
24
|
+
"build": "vite build",
|
|
25
|
+
"typecheck": "vue-tsc --noEmit"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=22"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@vueuse/core": "^14.0",
|
|
32
|
+
"class-variance-authority": "^0.7",
|
|
33
|
+
"clsx": "^2.0",
|
|
34
|
+
"embla-carousel-vue": "^8.0",
|
|
35
|
+
"reka-ui": "^2.0",
|
|
36
|
+
"tailwind-merge": "^3.0",
|
|
37
|
+
"tailwindcss": "^4.0",
|
|
38
|
+
"vue": "^3.5"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"embla-carousel-vue": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@tailwindcss/postcss": "^4.1.11",
|
|
47
|
+
"@tailwindcss/vite": "^4.2.2",
|
|
48
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
49
|
+
"@vueuse/core": "^14.2.1",
|
|
50
|
+
"class-variance-authority": "^0.7.1",
|
|
51
|
+
"clsx": "^2.1.1",
|
|
52
|
+
"embla-carousel-vue": "^8.6.0",
|
|
53
|
+
"lucide-vue-next": "^0.525.0",
|
|
54
|
+
"reka-ui": "^2.0.0",
|
|
55
|
+
"tailwind-merge": "^3.3.1",
|
|
56
|
+
"tailwindcss": "^4.1.11",
|
|
57
|
+
"tw-animate-css": "^1.2.5",
|
|
58
|
+
"typescript": "^5.8.3",
|
|
59
|
+
"vaul-vue": "^0.2.0",
|
|
60
|
+
"vite": "^7.0.6",
|
|
61
|
+
"vite-plugin-dts": "^4.5.4",
|
|
62
|
+
"vue": "^3.5.18",
|
|
63
|
+
"vue-tsc": "^2.2.0"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import { useAurora, type AuroraConfig } from "./composables/useAurora";
|
|
4
|
+
|
|
5
|
+
export interface AuroraProps {
|
|
6
|
+
colors?: string[];
|
|
7
|
+
blobCount?: number;
|
|
8
|
+
baseRadius?: number;
|
|
9
|
+
blur?: number;
|
|
10
|
+
speed?: number;
|
|
11
|
+
alphaLight?: number;
|
|
12
|
+
alphaDark?: number;
|
|
13
|
+
orbitAmplitude?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const props = defineProps<AuroraProps>();
|
|
17
|
+
const canvasRef = ref<HTMLCanvasElement | null>(null);
|
|
18
|
+
const { config } = useAurora(canvasRef, {
|
|
19
|
+
colors: props.colors,
|
|
20
|
+
blobCount: props.blobCount,
|
|
21
|
+
baseRadius: props.baseRadius,
|
|
22
|
+
blur: props.blur,
|
|
23
|
+
speed: props.speed,
|
|
24
|
+
alphaLight: props.alphaLight,
|
|
25
|
+
alphaDark: props.alphaDark,
|
|
26
|
+
orbitAmplitude: props.orbitAmplitude,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
defineExpose({ config });
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<canvas ref="canvasRef" aria-hidden="true" />
|
|
34
|
+
</template>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OKLCH color math for derived palette generation.
|
|
3
|
+
*
|
|
4
|
+
* Pipeline: sRGB [0–255] → linear sRGB → OKLab → OKLCh (polar)
|
|
5
|
+
* Manipulate L (lightness) and H (hue) in perceptually uniform space,
|
|
6
|
+
* then convert back: OKLCh → OKLab → linear sRGB → sRGB [0–255].
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export function clamp(v: number, min: number, max: number): number {
|
|
10
|
+
return v < min ? min : v > max ? max : v;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function linearize(c: number): number {
|
|
14
|
+
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function delinearize(c: number): number {
|
|
18
|
+
return c <= 0.0031308
|
|
19
|
+
? 12.92 * c
|
|
20
|
+
: 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function srgbToOKLab(
|
|
24
|
+
r: number,
|
|
25
|
+
g: number,
|
|
26
|
+
b: number,
|
|
27
|
+
): [number, number, number] {
|
|
28
|
+
const lr = linearize(r);
|
|
29
|
+
const lg = linearize(g);
|
|
30
|
+
const lb = linearize(b);
|
|
31
|
+
|
|
32
|
+
const l_ = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
33
|
+
const m_ = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
34
|
+
const s_ = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
35
|
+
|
|
36
|
+
return [
|
|
37
|
+
0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_,
|
|
38
|
+
1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_,
|
|
39
|
+
0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_,
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function oklabToOklch(
|
|
44
|
+
L: number,
|
|
45
|
+
a: number,
|
|
46
|
+
b: number,
|
|
47
|
+
): [number, number, number] {
|
|
48
|
+
const C = Math.sqrt(a * a + b * b);
|
|
49
|
+
const H = ((Math.atan2(b, a) * 180) / Math.PI + 360) % 360;
|
|
50
|
+
return [L, C, H];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function oklchToOklab(
|
|
54
|
+
L: number,
|
|
55
|
+
C: number,
|
|
56
|
+
H: number,
|
|
57
|
+
): [number, number, number] {
|
|
58
|
+
const rad = (H * Math.PI) / 180;
|
|
59
|
+
return [L, C * Math.cos(rad), C * Math.sin(rad)];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function oklabToRgb255(
|
|
63
|
+
L: number,
|
|
64
|
+
a: number,
|
|
65
|
+
b: number,
|
|
66
|
+
): [number, number, number] {
|
|
67
|
+
const l_ = L + 0.3963377774 * a + 0.2158037573 * b;
|
|
68
|
+
const m_ = L - 0.1055613458 * a - 0.0638541728 * b;
|
|
69
|
+
const s_ = L - 0.0894841775 * a - 1.291485548 * b;
|
|
70
|
+
|
|
71
|
+
const l = l_ * l_ * l_;
|
|
72
|
+
const m = m_ * m_ * m_;
|
|
73
|
+
const s = s_ * s_ * s_;
|
|
74
|
+
|
|
75
|
+
const r = +4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;
|
|
76
|
+
const g = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;
|
|
77
|
+
const bv = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;
|
|
78
|
+
|
|
79
|
+
return [
|
|
80
|
+
clamp(Math.round(delinearize(r) * 255), 0, 255),
|
|
81
|
+
clamp(Math.round(delinearize(g) * 255), 0, 255),
|
|
82
|
+
clamp(Math.round(delinearize(bv) * 255), 0, 255),
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** sRGB [0–255] → OKLCh [L:0–1, C:0–~0.4, H:0–360°]. */
|
|
87
|
+
export function rgbToOklch(
|
|
88
|
+
r: number,
|
|
89
|
+
g: number,
|
|
90
|
+
b: number,
|
|
91
|
+
): [number, number, number] {
|
|
92
|
+
const [L, a, b_] = srgbToOKLab(r / 255, g / 255, b / 255);
|
|
93
|
+
return oklabToOklch(L, a, b_);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** OKLCh → sRGB [0–255] (clamped & rounded). */
|
|
97
|
+
export function oklchToRgb(
|
|
98
|
+
L: number,
|
|
99
|
+
C: number,
|
|
100
|
+
H: number,
|
|
101
|
+
): [number, number, number] {
|
|
102
|
+
const [la, a, b] = oklchToOklab(L, C, H);
|
|
103
|
+
return oklabToRgb255(la, a, b);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Parse a CSS color string to [r, g, b] (0-255) using browser's canvas parser.
|
|
108
|
+
*/
|
|
109
|
+
let _parseCtx: CanvasRenderingContext2D | null = null;
|
|
110
|
+
export function cssToRgb(css: string): [number, number, number] {
|
|
111
|
+
if (!_parseCtx) {
|
|
112
|
+
const c = document.createElement("canvas");
|
|
113
|
+
c.width = c.height = 1;
|
|
114
|
+
_parseCtx = c.getContext("2d", { willReadFrequently: true })!;
|
|
115
|
+
}
|
|
116
|
+
_parseCtx.clearRect(0, 0, 1, 1);
|
|
117
|
+
_parseCtx.fillStyle = "#808080";
|
|
118
|
+
_parseCtx.fillStyle = css;
|
|
119
|
+
_parseCtx.fillRect(0, 0, 1, 1);
|
|
120
|
+
const d = _parseCtx.getImageData(0, 0, 1, 1).data;
|
|
121
|
+
return [d[0]!, d[1]!, d[2]!];
|
|
122
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import {
|
|
2
|
+
onBeforeUnmount,
|
|
3
|
+
onMounted,
|
|
4
|
+
reactive,
|
|
5
|
+
isReactive,
|
|
6
|
+
watch,
|
|
7
|
+
toValue,
|
|
8
|
+
type Ref,
|
|
9
|
+
type MaybeRef,
|
|
10
|
+
} from "vue";
|
|
11
|
+
import { clamp, cssToRgb, rgbToOklch, oklchToRgb } from "./color";
|
|
12
|
+
|
|
13
|
+
// ── Config ──────────────────────────────────────────────────────────────────
|
|
14
|
+
|
|
15
|
+
export interface AuroraConfig {
|
|
16
|
+
/** "explicit" uses the `colors` array. "derived" generates palette from baseColor via OKLCH. */
|
|
17
|
+
colorMode: "explicit" | "derived";
|
|
18
|
+
/** Explicit color array (CSS strings). Used when colorMode === "explicit". */
|
|
19
|
+
colors: string[];
|
|
20
|
+
|
|
21
|
+
/** OKLCH lightness shift for large blobs (first half). Used when colorMode === "derived". */
|
|
22
|
+
lShiftLarge: number;
|
|
23
|
+
/** OKLCH lightness shift for small blobs (second half). */
|
|
24
|
+
lShiftSmall: number;
|
|
25
|
+
/** OKLCH hue rotation for large blobs (degrees). */
|
|
26
|
+
hueShiftLarge: number;
|
|
27
|
+
/** OKLCH hue rotation for small blobs (degrees). */
|
|
28
|
+
hueShiftSmall: number;
|
|
29
|
+
|
|
30
|
+
blobCount: number;
|
|
31
|
+
baseRadius: number;
|
|
32
|
+
radiusVariance: number;
|
|
33
|
+
/** Fraction of blobs anchored to viewport vs page (0 = all page, 1 = all viewport). */
|
|
34
|
+
viewportAnchorRatio: number;
|
|
35
|
+
|
|
36
|
+
blur: number;
|
|
37
|
+
speed: number;
|
|
38
|
+
orbitAmplitude: number;
|
|
39
|
+
blendMode: GlobalCompositeOperation;
|
|
40
|
+
|
|
41
|
+
/** Gradient stop positions (fraction of blob radius). */
|
|
42
|
+
gradStop2: number;
|
|
43
|
+
gradStop3: number;
|
|
44
|
+
gradStop4: number;
|
|
45
|
+
|
|
46
|
+
alphaLight: number;
|
|
47
|
+
alphaDark: number;
|
|
48
|
+
|
|
49
|
+
/** "none" = transparent clear, "theme" = white/black based on dark mode, "color" = baseColor tint. */
|
|
50
|
+
surfaceMode: "none" | "theme" | "color";
|
|
51
|
+
surfaceAlpha: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const DEFAULT_AURORA_CONFIG: AuroraConfig = {
|
|
55
|
+
colorMode: "explicit",
|
|
56
|
+
colors: ["#c084fc", "#60a5fa", "#f472b6", "#34d399", "#fbbf24", "#fb923c", "#a78bfa", "#38bdf8"],
|
|
57
|
+
lShiftLarge: 0.15,
|
|
58
|
+
lShiftSmall: 0.10,
|
|
59
|
+
hueShiftLarge: 25,
|
|
60
|
+
hueShiftSmall: 55,
|
|
61
|
+
blobCount: 8,
|
|
62
|
+
baseRadius: 0.32,
|
|
63
|
+
radiusVariance: 0.08,
|
|
64
|
+
viewportAnchorRatio: 0.5,
|
|
65
|
+
blur: 80,
|
|
66
|
+
speed: 0.4,
|
|
67
|
+
orbitAmplitude: 0.12,
|
|
68
|
+
blendMode: "source-over",
|
|
69
|
+
gradStop2: 0.35,
|
|
70
|
+
gradStop3: 0.65,
|
|
71
|
+
gradStop4: 1.0,
|
|
72
|
+
alphaLight: 0.35,
|
|
73
|
+
alphaDark: 0.18,
|
|
74
|
+
surfaceMode: "none",
|
|
75
|
+
surfaceAlpha: 0,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** Preset: atmosphere-style (single base color, OKLCH-derived palette, surface fill). */
|
|
79
|
+
export const ATMOSPHERE_PRESET: Partial<AuroraConfig> = {
|
|
80
|
+
colorMode: "derived",
|
|
81
|
+
blobCount: 10,
|
|
82
|
+
baseRadius: 0.10,
|
|
83
|
+
radiusVariance: 0.015,
|
|
84
|
+
viewportAnchorRatio: 1.0,
|
|
85
|
+
blur: 8,
|
|
86
|
+
speed: 0.10,
|
|
87
|
+
orbitAmplitude: 0.45,
|
|
88
|
+
gradStop2: 0.30,
|
|
89
|
+
gradStop3: 0.60,
|
|
90
|
+
gradStop4: 1.00,
|
|
91
|
+
alphaLight: 0.33,
|
|
92
|
+
alphaDark: 0.09,
|
|
93
|
+
surfaceMode: "theme",
|
|
94
|
+
surfaceAlpha: 0.97,
|
|
95
|
+
lShiftLarge: 0.15,
|
|
96
|
+
lShiftSmall: 0.10,
|
|
97
|
+
hueShiftLarge: 25,
|
|
98
|
+
hueShiftSmall: 55,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// ── Internals ───────────────────────────────────────────────────────────────
|
|
102
|
+
|
|
103
|
+
interface Blob {
|
|
104
|
+
anchorX: number;
|
|
105
|
+
anchorY: number;
|
|
106
|
+
mode: "viewport" | "page";
|
|
107
|
+
radius: number;
|
|
108
|
+
color: [number, number, number];
|
|
109
|
+
phaseX: number;
|
|
110
|
+
phaseY: number;
|
|
111
|
+
freqX: number;
|
|
112
|
+
freqY: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const PHI = 1.618033988749895;
|
|
116
|
+
const SQRT2 = 1.4142135623730951;
|
|
117
|
+
|
|
118
|
+
function isDarkMode(): boolean {
|
|
119
|
+
return (
|
|
120
|
+
document.documentElement.classList.contains("dark") ||
|
|
121
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function rgba(r: number, g: number, b: number, a: number): string {
|
|
126
|
+
return `rgba(${clamp(Math.round(r), 0, 255)},${clamp(Math.round(g), 0, 255)},${clamp(Math.round(b), 0, 255)},${a})`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ── Composable ──────────────────────────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Unified aurora/atmosphere background composable.
|
|
133
|
+
*
|
|
134
|
+
* Two color modes:
|
|
135
|
+
* - **explicit**: Uses the `colors` array directly (aurora default)
|
|
136
|
+
* - **derived**: Generates palette from a single `baseColor` via OKLCH shifts (atmosphere style)
|
|
137
|
+
*
|
|
138
|
+
* @param canvasRef — template ref to the `<canvas>` element
|
|
139
|
+
* @param userConfig — reactive config object (mutations propagate live) or partial overrides
|
|
140
|
+
* @param baseColor — reactive CSS color for "derived" mode
|
|
141
|
+
*/
|
|
142
|
+
export function useAurora(
|
|
143
|
+
canvasRef: Ref<HTMLCanvasElement | null>,
|
|
144
|
+
userConfig?: Partial<AuroraConfig> | AuroraConfig,
|
|
145
|
+
baseColor?: MaybeRef<string>,
|
|
146
|
+
) {
|
|
147
|
+
const cfg: AuroraConfig = isReactive(userConfig)
|
|
148
|
+
? (userConfig as AuroraConfig)
|
|
149
|
+
: reactive<AuroraConfig>({ ...DEFAULT_AURORA_CONFIG, ...userConfig });
|
|
150
|
+
|
|
151
|
+
let blobs: Blob[] = [];
|
|
152
|
+
let animId = 0;
|
|
153
|
+
let dark = false;
|
|
154
|
+
let dpr = 1;
|
|
155
|
+
let observer: MutationObserver | null = null;
|
|
156
|
+
let mediaQuery: MediaQueryList | null = null;
|
|
157
|
+
|
|
158
|
+
/** Derive palette from a single base color via OKLCH lightness/hue shifts. */
|
|
159
|
+
function deriveColors(count: number): Array<[number, number, number]> {
|
|
160
|
+
const cssColor = toValue(baseColor) ?? "#c084fc";
|
|
161
|
+
const [r, g, b] = cssToRgb(cssColor);
|
|
162
|
+
const [L, C, H] = rgbToOklch(r, g, b);
|
|
163
|
+
|
|
164
|
+
const colors: Array<[number, number, number]> = [];
|
|
165
|
+
for (let i = 0; i < count; i++) {
|
|
166
|
+
const isSmall = i >= Math.ceil(count / 2);
|
|
167
|
+
const lShift = isSmall ? cfg.lShiftSmall : cfg.lShiftLarge;
|
|
168
|
+
const hShift = isSmall ? cfg.hueShiftSmall : cfg.hueShiftLarge;
|
|
169
|
+
const sign = i % 2 === 0 ? 1 : -1;
|
|
170
|
+
const lAmount = lShift * (0.5 + (i / count) * 0.5) * sign;
|
|
171
|
+
const hAmount = hShift * ((i + 1) / count) * (i % 3 === 0 ? -1 : 1);
|
|
172
|
+
colors.push(oklchToRgb(clamp(L + lAmount, 0, 1), C, (H + hAmount + 360) % 360));
|
|
173
|
+
}
|
|
174
|
+
return colors;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function getSurface(): { rgb: [number, number, number]; alpha: number } {
|
|
178
|
+
if (cfg.surfaceMode === "none") return { rgb: [0, 0, 0], alpha: 0 };
|
|
179
|
+
if (cfg.surfaceMode === "color") {
|
|
180
|
+
const cssColor = toValue(baseColor) ?? "#c084fc";
|
|
181
|
+
return { rgb: cssToRgb(cssColor), alpha: cfg.surfaceAlpha };
|
|
182
|
+
}
|
|
183
|
+
return { rgb: dark ? [10, 10, 15] : [255, 255, 255], alpha: cfg.surfaceAlpha };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function buildBlobs() {
|
|
187
|
+
const canvas = canvasRef.value;
|
|
188
|
+
if (!canvas) return;
|
|
189
|
+
|
|
190
|
+
const vw = canvas.width / dpr;
|
|
191
|
+
const vh = canvas.height / dpr;
|
|
192
|
+
const diagonal = Math.sqrt(vw * vw + vh * vh);
|
|
193
|
+
const pageHeight = Math.max(document.documentElement.scrollHeight, vh);
|
|
194
|
+
|
|
195
|
+
const vpCount = Math.round(cfg.blobCount * cfg.viewportAnchorRatio);
|
|
196
|
+
const pageCount = cfg.blobCount - vpCount;
|
|
197
|
+
const goldenAngle = Math.PI * (3 - Math.sqrt(5));
|
|
198
|
+
|
|
199
|
+
const colorList: Array<[number, number, number]> =
|
|
200
|
+
cfg.colorMode === "derived"
|
|
201
|
+
? deriveColors(cfg.blobCount)
|
|
202
|
+
: cfg.colors.map(c => cssToRgb(c));
|
|
203
|
+
|
|
204
|
+
blobs = [];
|
|
205
|
+
|
|
206
|
+
for (let i = 0; i < vpCount; i++) {
|
|
207
|
+
const ci = i % colorList.length;
|
|
208
|
+
const radiusFrac = cfg.baseRadius + ((i / Math.max(vpCount, 1)) - 0.5) * cfg.radiusVariance * 2;
|
|
209
|
+
const angle = i * goldenAngle;
|
|
210
|
+
blobs.push({
|
|
211
|
+
anchorX: 0.5 + Math.cos(angle) * 0.3,
|
|
212
|
+
anchorY: 0.5 + Math.sin(angle) * 0.35,
|
|
213
|
+
mode: "viewport" as const,
|
|
214
|
+
radius: diagonal * Math.max(radiusFrac, 0.12),
|
|
215
|
+
color: colorList[ci],
|
|
216
|
+
phaseX: (i * PHI * Math.PI * 2) % (Math.PI * 2),
|
|
217
|
+
phaseY: (i * SQRT2 * Math.PI * 2) % (Math.PI * 2),
|
|
218
|
+
freqX: 0.0002 + i * 0.00005,
|
|
219
|
+
freqY: 0.00018 + i * 0.00006,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
for (let i = 0; i < pageCount; i++) {
|
|
224
|
+
const ci = (vpCount + i) % colorList.length;
|
|
225
|
+
const radiusFrac = cfg.baseRadius + ((i / Math.max(pageCount, 1)) - 0.5) * cfg.radiusVariance * 2;
|
|
226
|
+
const angle = (vpCount + i) * goldenAngle;
|
|
227
|
+
const yPage = ((i + 0.5) / pageCount) * pageHeight;
|
|
228
|
+
blobs.push({
|
|
229
|
+
anchorX: 0.5 + Math.cos(angle) * 0.35,
|
|
230
|
+
anchorY: yPage,
|
|
231
|
+
mode: "page" as const,
|
|
232
|
+
radius: diagonal * Math.max(radiusFrac, 0.12),
|
|
233
|
+
color: colorList[ci],
|
|
234
|
+
phaseX: ((vpCount + i) * PHI * Math.PI * 2) % (Math.PI * 2),
|
|
235
|
+
phaseY: ((vpCount + i) * SQRT2 * Math.PI * 2) % (Math.PI * 2),
|
|
236
|
+
freqX: 0.00025 + i * 0.00006,
|
|
237
|
+
freqY: 0.0002 + i * 0.00007,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function resize() {
|
|
243
|
+
const canvas = canvasRef.value;
|
|
244
|
+
if (!canvas) return;
|
|
245
|
+
const vw = window.innerWidth;
|
|
246
|
+
const vh = window.innerHeight;
|
|
247
|
+
if (vw === 0 || vh === 0) return;
|
|
248
|
+
dpr = Math.min(window.devicePixelRatio, 1.5);
|
|
249
|
+
canvas.width = Math.ceil(vw * dpr);
|
|
250
|
+
canvas.height = Math.ceil(vh * dpr);
|
|
251
|
+
buildBlobs();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function draw(time: number) {
|
|
255
|
+
const canvas = canvasRef.value;
|
|
256
|
+
if (!canvas) return;
|
|
257
|
+
const ctx = canvas.getContext("2d");
|
|
258
|
+
if (!ctx) return;
|
|
259
|
+
|
|
260
|
+
const vw = canvas.width / dpr;
|
|
261
|
+
const vh = canvas.height / dpr;
|
|
262
|
+
if (vw === 0 || vh === 0) { animId = requestAnimationFrame(draw); return; }
|
|
263
|
+
|
|
264
|
+
const scrollY = window.scrollY;
|
|
265
|
+
ctx.save();
|
|
266
|
+
ctx.scale(dpr, dpr);
|
|
267
|
+
|
|
268
|
+
// Surface fill
|
|
269
|
+
const surface = getSurface();
|
|
270
|
+
if (surface.alpha > 0) {
|
|
271
|
+
ctx.globalAlpha = surface.alpha;
|
|
272
|
+
ctx.globalCompositeOperation = "source-over";
|
|
273
|
+
ctx.filter = "none";
|
|
274
|
+
ctx.fillStyle = rgba(surface.rgb[0], surface.rgb[1], surface.rgb[2], 1);
|
|
275
|
+
ctx.fillRect(0, 0, vw, vh);
|
|
276
|
+
ctx.globalAlpha = 1;
|
|
277
|
+
} else {
|
|
278
|
+
ctx.clearRect(0, 0, vw, vh);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
ctx.filter = `blur(${cfg.blur}px) saturate(140%)`;
|
|
282
|
+
ctx.globalCompositeOperation = cfg.blendMode;
|
|
283
|
+
|
|
284
|
+
const alpha = dark ? cfg.alphaDark : cfg.alphaLight;
|
|
285
|
+
const alphaScale = cfg.surfaceMode === "theme" ? (dark ? 0.6 : 2.2) : 1.0;
|
|
286
|
+
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
287
|
+
const speedMul = reducedMotion ? 0.05 : cfg.speed;
|
|
288
|
+
|
|
289
|
+
for (const blob of blobs) {
|
|
290
|
+
let cx: number, cy: number;
|
|
291
|
+
if (blob.mode === "viewport") {
|
|
292
|
+
cx = blob.anchorX * vw;
|
|
293
|
+
cy = blob.anchorY * vh;
|
|
294
|
+
} else {
|
|
295
|
+
cx = blob.anchorX * vw;
|
|
296
|
+
cy = blob.anchorY - scrollY;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
cx += Math.sin(time * blob.freqX * speedMul + blob.phaseX) * vw * cfg.orbitAmplitude;
|
|
300
|
+
cy += Math.cos(time * blob.freqY * speedMul + blob.phaseY) * vh * cfg.orbitAmplitude;
|
|
301
|
+
|
|
302
|
+
if (cy + blob.radius < -blob.radius * 0.5 || cy - blob.radius > vh + blob.radius * 0.5) continue;
|
|
303
|
+
|
|
304
|
+
const [r, g, b] = blob.color;
|
|
305
|
+
const desat = dark ? 0.7 : 1.0;
|
|
306
|
+
const dr = Math.round(r * desat + 128 * (1 - desat));
|
|
307
|
+
const dg = Math.round(g * desat + 128 * (1 - desat));
|
|
308
|
+
const db = Math.round(b * desat + 128 * (1 - desat));
|
|
309
|
+
|
|
310
|
+
const peakAlpha = alpha * alphaScale;
|
|
311
|
+
|
|
312
|
+
const grad = ctx.createRadialGradient(cx, cy, 0, cx, cy, blob.radius);
|
|
313
|
+
grad.addColorStop(0, rgba(dr, dg, db, peakAlpha));
|
|
314
|
+
grad.addColorStop(cfg.gradStop2, rgba(dr, dg, db, peakAlpha * 0.6));
|
|
315
|
+
grad.addColorStop(cfg.gradStop3, rgba(dr, dg, db, peakAlpha * 0.2));
|
|
316
|
+
grad.addColorStop(cfg.gradStop4, rgba(dr, dg, db, 0));
|
|
317
|
+
|
|
318
|
+
ctx.fillStyle = grad;
|
|
319
|
+
ctx.fillRect(cx - blob.radius, cy - blob.radius, blob.radius * 2, blob.radius * 2);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
ctx.restore();
|
|
323
|
+
animId = requestAnimationFrame(draw);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function onThemeChange() { dark = isDarkMode(); }
|
|
327
|
+
|
|
328
|
+
onMounted(() => {
|
|
329
|
+
dark = isDarkMode();
|
|
330
|
+
observer = new MutationObserver(onThemeChange);
|
|
331
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
|
|
332
|
+
mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
333
|
+
mediaQuery.addEventListener("change", onThemeChange);
|
|
334
|
+
resize();
|
|
335
|
+
window.addEventListener("resize", resize);
|
|
336
|
+
animId = requestAnimationFrame(draw);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
onBeforeUnmount(() => {
|
|
340
|
+
cancelAnimationFrame(animId);
|
|
341
|
+
window.removeEventListener("resize", resize);
|
|
342
|
+
observer?.disconnect();
|
|
343
|
+
mediaQuery?.removeEventListener("change", onThemeChange);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
watch(
|
|
347
|
+
() => [cfg.colors, cfg.blobCount, cfg.baseRadius, cfg.radiusVariance,
|
|
348
|
+
cfg.viewportAnchorRatio, cfg.colorMode, cfg.lShiftLarge, cfg.lShiftSmall,
|
|
349
|
+
cfg.hueShiftLarge, cfg.hueShiftSmall, toValue(baseColor)],
|
|
350
|
+
() => buildBlobs(),
|
|
351
|
+
{ deep: true },
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
return { config: cfg };
|
|
355
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Transition name="fade">
|
|
3
|
+
<div
|
|
4
|
+
v-if="open"
|
|
5
|
+
class="absolute inset-0 z-popover grid place-items-center bg-black/50 rounded-2xl"
|
|
6
|
+
@click.self="!loading && (open = false)"
|
|
7
|
+
@keydown.escape="!loading && (open = false)"
|
|
8
|
+
>
|
|
9
|
+
<Transition name="confirm-panel" appear>
|
|
10
|
+
<div
|
|
11
|
+
v-if="open"
|
|
12
|
+
class="w-[calc(100%-2rem)] sm:max-w-sm bg-card text-card-foreground border border-border rounded-2xl shadow-lg"
|
|
13
|
+
>
|
|
14
|
+
<div class="p-6 grid gap-4">
|
|
15
|
+
<div class="grid gap-2">
|
|
16
|
+
<h2 class="font-display text-lg font-semibold leading-none tracking-tight">
|
|
17
|
+
{{ title }}
|
|
18
|
+
</h2>
|
|
19
|
+
<div class="font-mono-code text-sm text-muted-foreground">
|
|
20
|
+
<slot>{{ description }}</slot>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="flex justify-end gap-2">
|
|
24
|
+
<Button
|
|
25
|
+
variant="outline"
|
|
26
|
+
class="cursor-pointer rounded-full"
|
|
27
|
+
:disabled="loading"
|
|
28
|
+
@click="open = false"
|
|
29
|
+
>
|
|
30
|
+
Cancel
|
|
31
|
+
</Button>
|
|
32
|
+
<Button
|
|
33
|
+
:variant="destructive ? 'destructive' : 'default'"
|
|
34
|
+
class="cursor-pointer gap-1.5 rounded-full"
|
|
35
|
+
:disabled="loading"
|
|
36
|
+
@click="onConfirm"
|
|
37
|
+
>
|
|
38
|
+
<LoaderCircle
|
|
39
|
+
v-if="loading"
|
|
40
|
+
class="size-4 animate-spin"
|
|
41
|
+
/>
|
|
42
|
+
<slot name="action">{{ confirmLabel }}</slot>
|
|
43
|
+
</Button>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</Transition>
|
|
48
|
+
</div>
|
|
49
|
+
</Transition>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup lang="ts">
|
|
53
|
+
import { LoaderCircle } from "lucide-vue-next";
|
|
54
|
+
import { Button } from "../../ui/button";
|
|
55
|
+
|
|
56
|
+
const props = defineProps<{
|
|
57
|
+
title: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
confirmLabel: string;
|
|
60
|
+
destructive?: boolean;
|
|
61
|
+
loading?: boolean;
|
|
62
|
+
}>();
|
|
63
|
+
|
|
64
|
+
const open = defineModel<boolean>("open", { default: false });
|
|
65
|
+
const emit = defineEmits<{ confirm: [] }>();
|
|
66
|
+
|
|
67
|
+
function onConfirm() {
|
|
68
|
+
if (props.loading) return;
|
|
69
|
+
emit("confirm");
|
|
70
|
+
open.value = false;
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<style scoped>
|
|
75
|
+
.confirm-panel-enter-active {
|
|
76
|
+
transition: opacity var(--duration-normal) var(--ease-out),
|
|
77
|
+
transform var(--duration-normal) var(--ease-out);
|
|
78
|
+
}
|
|
79
|
+
.confirm-panel-leave-active {
|
|
80
|
+
transition: opacity var(--duration-fast) var(--ease-in),
|
|
81
|
+
transform var(--duration-fast) var(--ease-in);
|
|
82
|
+
}
|
|
83
|
+
.confirm-panel-enter-from,
|
|
84
|
+
.confirm-panel-leave-to {
|
|
85
|
+
opacity: 0;
|
|
86
|
+
transform: scale(0.95);
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ConfirmDialog } from "./ConfirmDialog.vue";
|