-
-
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.
Added TypeScript types and tests for the emotion package.
- Loading branch information
1 parent
9e3617f
commit 7935e85
Showing
5 changed files
with
130 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "es2015", | ||
"strict": true, | ||
"allowSyntheticDefaultImports": true, | ||
"moduleResolution": "node" | ||
}, | ||
"include": [ | ||
"./*.ts", | ||
"./*.tsx" | ||
] | ||
} |
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,65 @@ | ||
import { | ||
sheet, | ||
useStylisPlugin, | ||
injectGlobal, | ||
flush, | ||
css, | ||
fontFace, | ||
hydrate | ||
} from '../'; | ||
|
||
sheet.speedy(true); | ||
sheet.inject(); | ||
sheet.insert('.foo { font-size: 1 };', 'some source map'); | ||
sheet.flush(); | ||
|
||
useStylisPlugin(() => {})([() => {}, () => {}])(null); | ||
|
||
flush(); | ||
|
||
const cssObject = { | ||
height: 100, | ||
width: '100%', | ||
display: (true as boolean) && 'block', | ||
position: undefined, | ||
color: null, | ||
':hover': { | ||
display: 'block' | ||
} | ||
}; | ||
|
||
const className: string = css` | ||
${(true as boolean) && ''} | ||
${'bar'} | ||
${css``} | ||
${1} | ||
${cssObject} | ||
`; | ||
|
||
const className2: string = css(cssObject); | ||
|
||
css(() => ({ | ||
height: 100 | ||
})); | ||
|
||
css([ | ||
{ display: 'none' }, | ||
[ | ||
{ position: false }, | ||
{ width: 100 } | ||
] | ||
]) | ||
|
||
css(null); | ||
|
||
fontFace` | ||
font-family: 'Foo'; | ||
`; | ||
|
||
injectGlobal` | ||
#foo { | ||
font-face: 'Foo'; | ||
} | ||
`; | ||
|
||
hydrate(['css-123', 'css-456']); |
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,45 @@ | ||
export type Interpolation = string | number | boolean | null | undefined | _Interpolation1 | _Interpolation2 | _Interpolation3; | ||
|
||
// HACK: See https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540 | ||
interface _Interpolation1 extends Record<string, Interpolation> {} | ||
interface _Interpolation2 extends Array<Interpolation> {} | ||
interface _Interpolation3 { | ||
(): Interpolation; | ||
} | ||
|
||
export type CreateStyles<TRet> = ((...values: Interpolation[]) => TRet) | ||
& ((strings: TemplateStringsArray, ...vars: Interpolation[]) => TRet); | ||
|
||
export interface StylisUse { | ||
// TODO: Make this more precise than just Function | ||
(plugin: Function | Function[] | null): StylisUse; | ||
} | ||
|
||
export interface StyleSheet { | ||
inject(): void; | ||
speedy(bool: boolean): void; | ||
insert(rule: string, sourceMap: string): void; | ||
flush(): void; | ||
} | ||
|
||
export const sheet: StyleSheet; | ||
|
||
export const useStylisPlugin: StylisUse; | ||
|
||
export const inserted: Record<string, boolean | undefined>; | ||
|
||
export const registered: Record<string, string | undefined>; | ||
|
||
export function flush(): void; | ||
|
||
export const css: CreateStyles<string>; | ||
|
||
export const injectGlobal: CreateStyles<void>; | ||
|
||
export const keyframes: CreateStyles<string>; | ||
|
||
export const fontFace: CreateStyles<void>; | ||
|
||
export function getRegisteredStyles(registeredStyles: string[], classNames: string): string; | ||
|
||
export function hydrate(ids: string[]): void; |