-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css): add makeTheme constrained identity function
Defined presets in a typesafe way. You can read more on CIFs at: https://kentcdodds.com/blog/how-to-write-a-constrained-identity-function-in-typescript
- Loading branch information
Showing
45 changed files
with
1,379 additions
and
1,365 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,9 +1,9 @@ | ||
import '@emotion/react' | ||
|
||
import { Theme } from '@theme-ui/css' | ||
|
||
interface ThemeUITheme extends Theme {} | ||
|
||
declare module '@emotion/react' { | ||
export interface Theme extends ThemeUITheme {} | ||
} | ||
import '@emotion/react' | ||
|
||
import { Theme } from '@theme-ui/css' | ||
|
||
interface ThemeUITheme extends Theme {} | ||
|
||
declare module '@emotion/react' { | ||
export interface Theme extends ThemeUITheme {} | ||
} |
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,15 @@ | ||
import type { ColorModesScale, Theme, ThemeStyles } from './types' | ||
|
||
/** | ||
* Constrained identity function used to constrain user's theme type to Theme | ||
* while preserving its exact type. | ||
*/ | ||
export const makeTheme = <T extends Theme>(theme: T): T => theme | ||
|
||
/** | ||
* Constrained identity function used to create a styles dictionary | ||
* assignable to ThemeStyles while preserving its exact type. | ||
*/ | ||
export const makeStyles = <T extends ThemeStyles>(styles: T): T => styles | ||
|
||
export const makeColorsScale = <T extends ColorModesScale>(colors: T) => colors |
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,4 @@ | ||
{ | ||
"main": "dist/theme-ui-css-utils.cjs.js", | ||
"module": "dist/theme-ui-css-utils.esm.js" | ||
} |
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 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 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
Oops, something went wrong.