-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: TET-218 loader * fix: TET-218 explicity typed styles builder * fix: workaround of svg props TET-218 --------- Co-authored-by: Adrian Potępa <[email protected]>
- Loading branch information
1 parent
4828690
commit 90c3d4d
Showing
6 changed files
with
196 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import { LoaderConfig } from './Loader.styles'; | ||
import type { LoaderConfig } from './Loader.styles'; | ||
import type { LoaderAppearance, LoaderShape, LoaderSize } from './types'; | ||
|
||
import { DeepPartial } from '@/utility-types/DeepPartial'; | ||
|
||
export type LoaderProps = { | ||
appearance?: LoaderAppearance; | ||
size?: LoaderSize; | ||
progress?: number; | ||
shape: LoaderShape; | ||
custom?: DeepPartial<LoaderConfig>; | ||
custom?: LoaderConfig; | ||
}; |
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,100 +1,130 @@ | ||
import { SystemProps } from '@xstyled/styled-components'; | ||
import { SvgProperties } from 'csstype'; | ||
import { ThemeColor } from '@xstyled/styled-components'; | ||
import type { Property } from 'csstype'; | ||
|
||
import type { LoaderAppearance, LoaderShape, LoaderSize } from './types'; | ||
|
||
import { Theme } from '@/theme'; | ||
import { BaseProps } from '@/types/BaseProps'; | ||
|
||
export type SVGProps = Omit< | ||
BaseProps, | ||
| 'opacity' | ||
| 'display' | ||
| 'order' | ||
| 'cursor' | ||
| 'pointerEvents' | ||
| 'overflow' | ||
| 'visibility' | ||
| 'fill' | ||
| 'transform' | ||
| 'rotate' | ||
| 'scale' | ||
| 'stroke' | ||
| 'fontFamily' | ||
| 'fontSize' | ||
| 'fontStyle' | ||
| 'fontStyle' | ||
| 'fontVariant' | ||
| 'fontWeight' | ||
| 'letterSpacing' | ||
| 'textDecoration' | ||
> & { | ||
fill?: ThemeColor<Theme> | Property.Fill; | ||
strokeWidth?: Property.StrokeWidth<string | number>; | ||
strokeLinecap?: 'inherit' | 'round' | 'butt' | 'square'; | ||
}; | ||
|
||
export type LoaderConfig = { | ||
size: Record< | ||
LoaderShape, | ||
Record<LoaderSize, SystemProps & Pick<SvgProperties, 'strokeWidth'>> | ||
>; | ||
appearance: Record< | ||
LoaderAppearance, | ||
Record<'base' | 'progress', SystemProps> | ||
shape?: Partial< | ||
Record<LoaderShape, { size?: Partial<Record<LoaderSize, SVGProps>> }> | ||
>; | ||
svg: SystemProps; | ||
progress: SystemProps & Pick<SvgProperties, 'strokeLinecap'>; | ||
innerElements?: { | ||
base?: { | ||
appearance?: Partial<Record<LoaderAppearance, BaseProps>>; | ||
} & SVGProps; | ||
progress?: { | ||
appearance?: Partial<Record<LoaderAppearance, BaseProps>>; | ||
} & SVGProps; | ||
}; | ||
} & BaseProps; | ||
|
||
export const defaultConfig = { | ||
size: { | ||
fill: 'none', | ||
borderRadius: 'large', | ||
shape: { | ||
circle: { | ||
large: { | ||
w: 48, | ||
h: 48, | ||
strokeWidth: '2', | ||
}, | ||
medium: { | ||
w: 32, | ||
h: 32, | ||
strokeWidth: '2', | ||
}, | ||
small: { | ||
w: 20, | ||
h: 20, | ||
strokeWidth: '2', | ||
size: { | ||
large: { | ||
w: 48, | ||
h: 48, | ||
strokeWidth: '2', | ||
}, | ||
medium: { | ||
w: 32, | ||
h: 32, | ||
strokeWidth: '2', | ||
}, | ||
small: { | ||
w: 20, | ||
h: 20, | ||
strokeWidth: '2', | ||
}, | ||
}, | ||
}, | ||
bar: { | ||
large: { | ||
w: 128, | ||
h: 8, | ||
strokeWidth: '8', | ||
}, | ||
medium: { | ||
w: 128, | ||
h: 6, | ||
strokeWidth: '6', | ||
}, | ||
small: { | ||
w: 128, | ||
h: 4, | ||
strokeWidth: '4', | ||
size: { | ||
large: { | ||
w: 128, | ||
h: 8, | ||
strokeWidth: '8', | ||
}, | ||
medium: { | ||
w: 128, | ||
h: 6, | ||
strokeWidth: '6', | ||
}, | ||
small: { | ||
w: 128, | ||
h: 4, | ||
strokeWidth: '4', | ||
}, | ||
}, | ||
}, | ||
}, | ||
appearance: { | ||
primary: { | ||
base: { | ||
stroke: 'interaction-neutral-subtle-normal', | ||
}, | ||
progress: { | ||
stroke: 'interaction-default-normal', | ||
}, | ||
}, | ||
inverted: { | ||
base: { | ||
stroke: 'interaction-inverted-normal', | ||
}, | ||
progress: { | ||
stroke: 'interaction-default-normal', | ||
}, | ||
}, | ||
white: { | ||
base: { | ||
stroke: 'interaction-inverted-normal', | ||
opacity: 0.4, | ||
}, | ||
progress: { | ||
stroke: 'interaction-inverted-normal', | ||
innerElements: { | ||
base: { | ||
appearance: { | ||
primary: { | ||
stroke: 'interaction-neutral-subtle-normal', | ||
}, | ||
inverted: { | ||
stroke: 'interaction-inverted-normal', | ||
}, | ||
white: { | ||
stroke: 'interaction-inverted-normal', | ||
opacity: 0.4, | ||
}, | ||
greyscale: { | ||
stroke: 'interaction-neutral-subtle-normal', | ||
}, | ||
}, | ||
}, | ||
greyscale: { | ||
base: { | ||
stroke: 'interaction-neutral-subtle-normal', | ||
}, | ||
progress: { | ||
stroke: 'interaction-neutral-normal', | ||
progress: { | ||
strokeLinecap: 'round', | ||
appearance: { | ||
primary: { | ||
stroke: 'interaction-default-normal', | ||
}, | ||
inverted: { | ||
stroke: 'interaction-default-normal', | ||
}, | ||
white: { | ||
stroke: 'interaction-inverted-normal', | ||
}, | ||
greyscale: { | ||
stroke: 'interaction-neutral-normal', | ||
}, | ||
}, | ||
}, | ||
}, | ||
svg: { | ||
fill: 'none', | ||
borderRadius: 'large', | ||
}, | ||
progress: { | ||
strokeLinecap: 'round', | ||
}, | ||
} satisfies LoaderConfig; |
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
Oops, something went wrong.