Skip to content

Commit

Permalink
Revert "Fix globalCss types to support multiple arguments (#1012)" (#…
Browse files Browse the repository at this point in the history
…1017)

This reverts commit 4938d6d.
  • Loading branch information
hadihallak authored May 2, 2022
1 parent 4938d6d commit 74c3b96
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 169 deletions.
76 changes: 1 addition & 75 deletions packages/core/tests/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createStitches, FontFace } from '../types/index'
import { createStitches } from '../types/index'

const { css, globalCss, keyframes } = createStitches({
utils: {
Expand Down Expand Up @@ -148,77 +148,3 @@ PotatoButton({
}
},
})

/* -------------------------------------------------------------------------------------------------
* Issue #1010
* -----------------------------------------------------------------------------------------------*/
const fontFaceArray: FontFace[] = [
{
fontFamily: "Inter",
src: `url(file.woff2) format("woff2")`,
fontDisplay: "swap"
}
];
const styles = {
"@font-face": fontFaceArray,
body: {
// Falbacking to a serif font so it's easier to see that the swap is hapenning
fontFamily: "Inter, serif"
}
};
void function Test() {
globalCss(styles)
}

/* -------------------------------------------------------------------------------------------------
* Issue #842
* -----------------------------------------------------------------------------------------------*/
void function Test() {
globalCss(
{
"@font-face": [
{
fontFamily: "Roboto",
fontStyle: "normal",
fontWeight: "100",
src: "url('/Roboto-Thin.ttf') format('truetype')"
}
]
}, {
body: {
color: "red"
}
}, {
"@property thing": {
inherits: true,
syntax: "$plue"
}
}, {
"@keyframes fancy-frame": {
something: {
color: "$red"
}
}
}
)


globalCss(
{
body: {
color: "red"
}
}, {
"@property thing": {
inherits: true,
syntax: "$plue"
}
}, {
"@keyframes fancy-frame": {
something: {
color: "$red"
}
}
}
)
}
43 changes: 25 additions & 18 deletions packages/core/types/stitches.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,37 @@ export default interface Stitches<
themeMap: ThemeMap
utils: Utils
},
prefix: Prefix
/** The **prefix** property defined.
*
* [Read Documentation](https://stitches.dev/docs/variants)
*/
prefix: Prefix,
globalCss: {
<Styles extends ({ [K: string]: any })[], CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>>(
...styles: {
[K in keyof Styles]:
CSS
& {
/** The **@import** CSS at-rule imports style rules from other style sheets. */
'@import'?: string | string[]
<Styles extends { [K: string]: any }>(
...styles: (
{
/** The **@import** CSS at-rule imports style rules from other style sheets. */
'@import'?: unknown

/** The **@font-face** CSS at-rule specifies a custom font with which to display text. */
'@font-face'?: CSSUtil.Native.AtRule.FontFace | Array<CSSUtil.Native.AtRule.FontFace>
} & {
[KA in `@property ${string}`]: CSSUtil.Native.AtRule.Property
} & {
[KS in `@keyframes ${string}`]: {
[KeyFrame in string]: CSS
}
}
}
/** The **@font-face** CSS at-rule specifies a custom font with which to display text. */
'@font-face'?: unknown
}
& {
[K in keyof Styles]: (
K extends '@import'
? string | string[]
: K extends '@font-face'
? CSSUtil.Native.AtRule.FontFace | Array<CSSUtil.Native.AtRule.FontFace>
: K extends `@keyframes ${string}`
? {
[KeyFrame in string]: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
}
: K extends `@property ${string}`
? CSSUtil.Native.AtRule.Property
: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
)
}
)[]
): {
(): string
}
Expand Down
53 changes: 0 additions & 53 deletions packages/react/tests/types.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,56 +203,3 @@ const styles = {
void function Test() {
globalCss(styles)
}

/* -------------------------------------------------------------------------------------------------
* Issue #842
* -----------------------------------------------------------------------------------------------*/
void function Test() {
globalCss(
{
"@font-face": [
{
fontFamily: "Roboto",
fontStyle: "normal",
fontWeight: "100",
src: "url('/Roboto-Thin.ttf') format('truetype')"
}
]
}, {
body: {
color: "red"
}
}, {
"@property thing": {
inherits: true,
syntax: "$plue"
}
}, {
"@keyframes fancy-frame": {
something: {
color: "$red"
}
}
}
)


globalCss(
{
body: {
color: "red"
}
}, {
"@property thing": {
inherits: true,
syntax: "$plue"
}
}, {
"@keyframes fancy-frame": {
something: {
color: "$red"
}
}
}
)
}
53 changes: 30 additions & 23 deletions packages/react/types/stitches.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,41 @@ export default interface Stitches<
themeMap: ThemeMap
utils: Utils
},
prefix: Prefix
/** The **prefix** property defined.
*
* [Read Documentation](https://stitches.dev/docs/variants)
*/
prefix: Prefix,
globalCss: {
<Styles extends ({ [K: string]: any })[], CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>>(
...styles: {
[K in keyof Styles]:
CSS
& {
/** The **@import** CSS at-rule imports style rules from other style sheets. */
'@import'?: string | string[]
globalCss: {
<Styles extends { [K: string]: any }>(
...styles: (
{
/** The **@import** CSS at-rule imports style rules from other style sheets. */
'@import'?: unknown

/** The **@font-face** CSS at-rule specifies a custom font with which to display text. */
'@font-face'?: CSSUtil.Native.AtRule.FontFace | Array<CSSUtil.Native.AtRule.FontFace>
} & {
[KA in `@property ${string}`]: CSSUtil.Native.AtRule.Property
} & {
[KS in `@keyframes ${string}`]: {
[KeyFrame in string]: CSS
}
}
}
): {
(): string
}
},
/** The **@font-face** CSS at-rule specifies a custom font with which to display text. */
'@font-face'?: unknown
}
& {
[K in keyof Styles]: (
K extends '@import'
? string | string[]
: K extends '@font-face'
? CSSUtil.Native.AtRule.FontFace | Array<CSSUtil.Native.AtRule.FontFace>
: K extends `@keyframes ${string}`
? {
[KeyFrame in string]: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
}
: K extends `@property ${string}`
? CSSUtil.Native.AtRule.Property
: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
)
}
)[]
): {
(): string
}
},
keyframes: {
(style: {
[offset: string]: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
Expand Down

0 comments on commit 74c3b96

Please sign in to comment.