-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
63 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type Fn = (...args: any[]) => any | ||
|
||
export type Flat<T> = T extends Fn ? T : T extends object ? { [K in keyof T]: T[K] } : T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { computed, type MaybeRefOrGetter, toValue } from 'vue' | ||
|
||
import type { Flat } from '@/types' | ||
|
||
type CssVars<N extends string, T extends Record<string, string> = {}> = { | ||
[K in keyof T as `--${N}-${string & K}`]: T[K] | ||
} | ||
|
||
export function createCssVar<N extends string, T extends Record<string, string>>(name: N, cssVars: T) { | ||
const result = Object.entries(cssVars).reduce((acc, [key, value]) => { | ||
// @ts-ignore | ||
acc[`--${name}-${key}`] = value | ||
return acc | ||
}, {} as Flat<CssVars<N, T>>) | ||
return result | ||
} | ||
|
||
export function useCssVar<N extends string, T extends Record<string, string>>(name: N, getter: MaybeRefOrGetter<T>) { | ||
return computed(() => createCssVar(name, toValue(getter))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d52a2e1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
elenext – ./
elenext-jaskang.vercel.app
elenext.vercel.app
elenext.jaskang.vip
elenext-git-main-jaskang.vercel.app