-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
b8949ce
commit bcb6c03
Showing
9 changed files
with
245 additions
and
67 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Theme, StrictTheme } from 'system-props'; | ||
|
||
interface AppTheme extends StrictTheme { | ||
colors: { | ||
gray10: string; | ||
gray20: string; | ||
gray30: string; | ||
blue10: string; | ||
blue20: string; | ||
blue30: string; | ||
}; | ||
space: { | ||
$0: string; | ||
$1: string; | ||
$3: string; | ||
$4: string; | ||
}; | ||
breakpoints: { | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
} | ||
|
||
declare module 'system-props' { | ||
export interface Theme extends AppTheme {} | ||
} | ||
|
||
export const theme: Theme = { | ||
colors: { | ||
gray10: '#333', | ||
gray20: '#666', | ||
gray30: '#999', | ||
blue10: 'skyblue', | ||
blue20: 'teal', | ||
blue30: 'blue', | ||
}, | ||
space: { | ||
$0: '0px', | ||
$1: '4px', | ||
$3: '8px', | ||
$4: '12px', | ||
}, | ||
breakpoints: { | ||
small: '42em', | ||
medium: '52em', | ||
large: '60em', | ||
}, | ||
}; |
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,8 +1,14 @@ | ||
export { betterGet as get } from './core/get'; | ||
export { createSystem } from './core/createSystem'; | ||
export { ResponsiveProp } from '@/types'; | ||
|
||
export * from './props'; | ||
export * from './pseudos'; | ||
export * from './propNames'; | ||
export * from './shouldForwardProp'; | ||
export { | ||
ResponsiveProp, | ||
Theme, | ||
LooseTheme, | ||
StrictTheme, | ||
ColorProps, | ||
} from './types'; |
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,47 +1,82 @@ | ||
import { Theme, ResponsiveProp } from './types'; | ||
import { ColorProps } from './props/color'; | ||
import { SpaceProps } from './props/space'; | ||
import { LayoutProps } from './props/layout'; | ||
|
||
interface LooseTheme { | ||
[x: string]: any; | ||
} | ||
|
||
// interface LocalTheme extends LooseTheme { | ||
// colors: { | ||
// blue100: string; | ||
// blue200: string; | ||
// blue300: string; | ||
// blue400: string; | ||
// blue500: string; | ||
// blue600: string; | ||
// blue700: string; | ||
// blue800: string; | ||
// blue900: string; | ||
// reds: [string, string, string]; | ||
// }; | ||
// space: [number, number, number, number]; | ||
// } | ||
|
||
interface LocalTheme extends Theme { | ||
colors: { | ||
blue100: 'blue'; | ||
blue200: 'blue'; | ||
blue300: 'blue'; | ||
blue400: 'blue'; | ||
blue500: 'blue'; | ||
blue600: 'blue'; | ||
blue700: 'blue'; | ||
blue800: 'blue'; | ||
blue100: string; | ||
blue200: string; | ||
blue300: string; | ||
blue400: string; | ||
blue500: string; | ||
blue600: string; | ||
blue700: string; | ||
blue800: string; | ||
blue900: string; | ||
red100: string; | ||
red200: string; | ||
}; | ||
space: { | ||
250: '2px'; | ||
500: '4px'; | ||
1000: '8px'; | ||
}; | ||
breakpoints: { | ||
320: '320px'; | ||
640: '640px'; | ||
0: string; | ||
1: string; | ||
2: string; | ||
}; | ||
} | ||
|
||
// const theme: LocalTheme = { | ||
// colors: { | ||
// blue100: 'blue', | ||
// blue200: 'blue', | ||
// blue300: 'blue', | ||
// blue400: 'blue', | ||
// blue500: 'blue', | ||
// blue600: 'blue', | ||
// blue700: 'blue', | ||
// blue800: 'blue', | ||
// blue900: 'blue', | ||
// reds: ['one', 'two', 'three'], | ||
// }, | ||
// space: [0, 4, 8, 12], | ||
// }; | ||
|
||
type NewColorProps = { | ||
[K in keyof ColorProps]?: | ||
| ResponsiveProp<keyof LocalTheme['colors']> | ||
| ColorProps[K]; | ||
[K in keyof ColorProps]?: LocalTheme extends Theme | ||
? ResponsiveProp<keyof LocalTheme['colors']> | ||
: ColorProps[K]; | ||
}; | ||
|
||
type NewSpaceProps = { | ||
[K in keyof SpaceProps]?: SpaceProps[K] | keyof LocalTheme['space']; | ||
[K in keyof SpaceProps]?: LocalTheme extends Theme | ||
? ResponsiveProp<keyof LocalTheme['space']> | ||
: SpaceProps[K]; | ||
}; | ||
|
||
interface Props extends NewSpaceProps, NewColorProps {} | ||
|
||
const foo: Props = { | ||
px: (theme) => theme.colors.blue100, | ||
backgroundColor: { | ||
320: 'blue100', | ||
640: 'blue200', | ||
}, | ||
bg: ['blue100', 'blue200', 'blue900'], | ||
mx: 1000, | ||
const bar: Props = { | ||
bg: 'red100', | ||
color: 'red100', | ||
fill: 'blue100', | ||
margin: 1, | ||
}; |
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
Oops, something went wrong.