-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from JakeGinnivan/topics/global-theme-type
Quick pass at removing theme generic param
- Loading branch information
Showing
11 changed files
with
93 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// TODO: Test if Global implements default theme | ||
// TODO: Test if css prop implements default theme | ||
// TODO: Test if ClassNames implements default theme | ||
// TODO: Test if utilities can be re-exported with custom theme and they respect the custom theme (Global -> implements the interface for styles callback; css prop -> implements the interface for callback; ClassNames -> implements the interface for css, theme) | ||
// TODO: Test if utilities can be re-exported with custom theme and they respect the custom theme | ||
// (Global -> implements the interface for styles callback; css prop -> implements the interface for callback; ClassNames -> implements the interface for css, theme) | ||
throw new Error('Tests not yet implemented') |
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 |
---|---|---|
|
@@ -24,8 +24,6 @@ export { | |
ObjectInterpolation | ||
} from '@emotion/css' | ||
|
||
export type AnyIfEmpty<T extends object> = keyof T extends never ? any : T | ||
|
||
export { EmotionCache, Interpolation, SerializedStyles, css } | ||
|
||
export const ThemeContext: Context<object> | ||
|
@@ -36,20 +34,15 @@ export function withEmotionCache<Props, RefType = any>( | |
|
||
export const jsx: typeof createElement | ||
|
||
export type InterpolationWithTheme<Theme> = | ||
| Interpolation | ||
| ((theme: Theme) => Interpolation) | ||
|
||
export interface GlobalProps<Theme> { | ||
styles: InterpolationWithTheme<Theme> | ||
export interface GlobalProps { | ||
styles: Interpolation<Emotion.Theme> | ||
} | ||
|
||
/** | ||
* @desc | ||
* JSX generic are supported only after [email protected] | ||
*/ | ||
export function Global<Theme extends {} = AnyIfEmpty<Emotion.Theme>>( | ||
props: GlobalProps<Theme> | ||
): ReactElement | ||
export function Global(props: GlobalProps): ReactElement | ||
|
||
export function keyframes( | ||
template: TemplateStringsArray, | ||
|
@@ -66,26 +59,24 @@ export type ClassNamesArg = | |
| { [className: string]: boolean | null | undefined } | ||
| ArrayClassNamesArg | ||
|
||
export interface ClassNamesContent<Theme> { | ||
export interface ClassNamesContent { | ||
css(template: TemplateStringsArray, ...args: Array<Interpolation>): string | ||
css(...args: Array<Interpolation>): string | ||
cx(...args: Array<ClassNamesArg>): string | ||
theme: Theme | ||
theme: Emotion.Theme | ||
} | ||
export interface ClassNamesProps<Theme> { | ||
children(content: ClassNamesContent<Theme>): ReactNode | ||
export interface ClassNamesProps { | ||
children(content: ClassNamesContent): ReactNode | ||
} | ||
/** | ||
* @desc | ||
* JSX generic are supported only after [email protected] | ||
*/ | ||
export function ClassNames<Theme extends {} = AnyIfEmpty<Emotion.Theme>>( | ||
props: ClassNamesProps<Theme> | ||
): ReactElement | ||
export function ClassNames(props: ClassNamesProps): ReactElement | ||
|
||
declare module 'react' { | ||
interface DOMAttributes<T> { | ||
css?: InterpolationWithTheme<AnyIfEmpty<Emotion.Theme>> | ||
css?: Interpolation | ||
} | ||
} | ||
|
||
|
@@ -102,7 +93,7 @@ declare global { | |
*/ | ||
|
||
interface IntrinsicAttributes { | ||
css?: InterpolationWithTheme<AnyIfEmpty<Emotion.Theme>> | ||
css?: Interpolation | ||
} | ||
} | ||
} |
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,5 +1,6 @@ | ||
// TODO: Test if withTheme implements default theme | ||
// TODO: Test if useTheme implements default theme | ||
// TODO: Test if ThemeProvider expects default theme | ||
// TODO: Test if utilities can be re-exported with custom theme and they respect the custom theme (withTheme -> component has theme props; useTheme -> has theme props; ThemeProvider -> provides the theme to children) | ||
// TODO: Test if utilities can be re-exported with custom theme and they respect the custom theme | ||
// (withTheme -> component has theme props; useTheme -> has theme props; ThemeProvider -> provides the theme to children) | ||
throw new Error('Tests not yet implemented') |
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.