-
Notifications
You must be signed in to change notification settings - Fork 348
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
22 changed files
with
101 additions
and
46 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
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
import { ArrayElementType } from '../../utils/types/array' | ||
export { defaultSizes as sizes, DefaultSizes as Sizes } from '../../composables' | ||
|
||
export const variables = [ | ||
'verticalAlign', | ||
'userSelect', | ||
'size', | ||
] as const | ||
|
||
export type Variables = ArrayElementType<typeof variables> |
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,13 @@ | ||
import { ArrayElementType } from '../../utils/types/array' | ||
import { defaultSizes } from '../../composables' | ||
|
||
export const variables = [] as const | ||
|
||
export type Variables = ArrayElementType<typeof variables> | ||
|
||
export const sizes = [ | ||
...defaultSizes, | ||
'auto', | ||
] as const | ||
|
||
export type Sizes = ArrayElementType<typeof sizes> |
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
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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import { ArrayElementType } from '../../utils/types/array' | ||
export { defaultSizes as sizes, DefaultSizes as Sizes } from '../../composables' | ||
|
||
const variables = [ | ||
'display', | ||
'numberItemMargin', | ||
'numberItemFontWeight', | ||
'numberItemCursor', | ||
'numberItemSize', | ||
'itemWrapperCursor', | ||
'size', | ||
'fontSize', | ||
'borderRadius', | ||
'fontWeight', | ||
'margin', | ||
] as const | ||
|
||
export type Variables = ArrayElementType<typeof variables> |
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,8 @@ | ||
import { useSizeProps } from '../../../composables' | ||
import { Sizes, Variables } from '../const' | ||
import { useVaRatingColorsProps } from '../hooks/useVaRatingColors' | ||
|
||
export const useRatingItemCommonProps = { | ||
...useVaRatingColorsProps, | ||
...useSizeProps<Variables, Sizes>(), | ||
} |
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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import { ArrayElementType } from '../../utils/types/array' | ||
export { defaultSizes as sizes, DefaultSizes as Sizes } from '../../composables' | ||
|
||
export const variables = [ | ||
'scrollbarGradientTo', | ||
'scrollbarSize', | ||
] as const | ||
|
||
export type Variables = ArrayElementType<typeof variables> |
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 |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import { PropType } from 'vue' | ||
import { SizesConfig } from '../services/component-config/theme' | ||
import { SizesConfig, SizeValue } from '../services/component-config/theme' | ||
import { ArrayElementType } from '../utils/types/array' | ||
|
||
export const defaultSizes = [ | ||
'small', | ||
'medium', | ||
'large', | ||
] as const | ||
|
||
export type DefaultSizes = ArrayElementType<typeof defaultSizes> | ||
|
||
/** | ||
* You could add these props to any component by destructuring them inside props option. | ||
* @example | ||
* props: { ...useSizeProps, componentsOwnProp, etc. } | ||
* It's better to add props at the beginning, to make sure that Component own props will be used instead in case of collision | ||
*/ | ||
export const useSizeProps = { | ||
export const useSizeProps = <Variables extends string, SizeName extends string>(defaultSize?: SizeName) => ({ | ||
size: { | ||
type: [String, Number], | ||
type: [String, Number] as PropType<SizeValue<SizeName>>, | ||
validator: (size: string | number) => { | ||
return typeof size === 'string' || typeof size === 'number' | ||
}, | ||
default: defaultSize, | ||
}, | ||
|
||
sizesConfig: { | ||
type: Object as PropType<SizesConfig<string, string>>, | ||
type: Object as PropType<SizesConfig<Variables, SizeName>>, | ||
}, | ||
} | ||
}) |
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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
export interface SizePreset<Variables extends string> { | ||
variables: Record<Variables, string>; | ||
variables: Partial<Record<Variables, string>>; | ||
} | ||
|
||
export type SizesConfig<Variables extends string, SizeName extends string> = Record<SizeName, SizePreset<Variables>>; | ||
/** | ||
* @see To allow union of string and string literals https://stackoverflow.com/questions/61047551/typescript-union-of-string-and-string-literals | ||
*/ | ||
export type SizeValue<T> = T | (string & {}) | number | ||
|
||
export type SizesConfig<Variables extends string, SizeName extends string> = Partial<Record<SizeValue<SizeName>, SizePreset<Variables>>>; | ||
|
||
export interface SizeProps<T extends SizesConfig<string, string>> { | ||
size?: (T extends SizesConfig<string, infer SizeName> ? SizeName : never) | string | number; | ||
size?: SizeValue<T extends SizesConfig<string, infer SizeName> ? SizeName : never>; | ||
sizesConfig?: 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