Skip to content

Commit

Permalink
fix: additional global at-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Aug 20, 2021
1 parent 331050d commit 8d0def7
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 17 deletions.
13 changes: 13 additions & 0 deletions .task/build-csstype.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const generateType = async (packageUrl) => {
.withFixedMatchingSelector
.withFixedNestingSelectors
.withFixedProperties
.withFixedPropertyAtRule
.withFixedStretchValue
.withFixedSystemColor

Expand Down Expand Up @@ -128,6 +129,16 @@ class ModifiedString extends String {
)
}

get withFixedPropertyAtRule() {
return this.replace(
'type Inherits = "false" | "true";',
'type Inherits = "false" | "true" | boolean;'
).replace(
'initialValue?: string;',
'initialValue?: boolean | number | string',
)
}

get withFixedMatchingSelector() {
return this.replace(
/matches\(\)/g,
Expand Down Expand Up @@ -248,6 +259,8 @@ class ModifiedString extends String {
/"-[^"]+" *\| *\n?/g, ''
).replace(
/\n? *\| *"-[^\n]+(?=\n)/g, ''
).replace(
/\n MozFontFeatureSettings?: FontFeatureSettings;/, ''
)
}
}
Expand Down
14 changes: 8 additions & 6 deletions packages/core/types/css-util.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type * as CSS from './css'
import type * as Native from './css'
import type * as Config from './config'
import type * as ThemeUtil from './theme'
import type * as Util from './util'

export { Native }

/** CSS style declaration object. */
export interface CSSProperties extends CSS.StandardLonghandProperties, CSS.StandardShorthandProperties, CSS.SvgProperties {}
export interface CSSProperties extends Native.StandardLonghandProperties, Native.StandardShorthandProperties, Native.SvgProperties {}

type ValueByPropertyName<PropertyName> = PropertyName extends keyof CSSProperties ? CSSProperties[PropertyName] : never

Expand All @@ -29,7 +31,7 @@ export type CSS<
[K in keyof CSSProperties]?: (
| ValueByPropertyName<K>
| TokenByPropertyName<K, Theme, ThemeMap>
| CSS.Globals
| Native.Globals
| ThemeUtil.ScaleValue
| undefined
)
Expand All @@ -48,7 +50,7 @@ export type CSS<
? (
| ValueByPropertyName<P[0][$$PropertyValue]>
| TokenByPropertyName<P[0][$$PropertyValue], Theme, ThemeMap>
| CSS.Globals
| Native.Globals
| ThemeUtil.ScaleValue
| undefined
)
Expand All @@ -66,7 +68,7 @@ export type CSS<
? (
| ValueByPropertyName<P[$$PropertyValue]>
| TokenByPropertyName<P[$$PropertyValue], Theme, ThemeMap>
| CSS.Globals
| Native.Globals
| undefined
)
: $$ScaleValue extends keyof P
Expand All @@ -91,7 +93,7 @@ export type CSS<
: K extends keyof Utils
? unknown
: (
| CSS.Globals
| Native.Globals
| Util.Index
| undefined
)
Expand Down
4 changes: 2 additions & 2 deletions packages/core/types/css.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9344,7 +9344,7 @@ export namespace AtRule {

export interface Property {
inherits?: Inherits;
initialValue?: string;
initialValue?: boolean | OnlyStringNumeric
syntax?: string;
}

Expand Down Expand Up @@ -9452,7 +9452,7 @@ export namespace AtRule {

type Size = DataType.PageSize | "auto" | "landscape" | "portrait" | OnlyStringNumeric;

type Inherits = "false" | "true";
type Inherits = "false" | "true" | boolean;

type Height = DataType.ViewportLength | OnlyString;

Expand Down
14 changes: 8 additions & 6 deletions packages/react/types/css-util.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type * as CSS from './css'
import type * as Native from './css'
import type * as Config from './config'
import type * as ThemeUtil from './theme'
import type * as Util from './util'

export { Native }

/** CSS style declaration object. */
export interface CSSProperties extends CSS.StandardLonghandProperties, CSS.StandardShorthandProperties, CSS.SvgProperties {}
export interface CSSProperties extends Native.StandardLonghandProperties, Native.StandardShorthandProperties, Native.SvgProperties {}

type ValueByPropertyName<PropertyName> = PropertyName extends keyof CSSProperties ? CSSProperties[PropertyName] : never

Expand All @@ -29,7 +31,7 @@ export type CSS<
[K in keyof CSSProperties]?: (
| ValueByPropertyName<K>
| TokenByPropertyName<K, Theme, ThemeMap>
| CSS.Globals
| Native.Globals
| ThemeUtil.ScaleValue
| undefined
)
Expand All @@ -48,7 +50,7 @@ export type CSS<
? (
| ValueByPropertyName<P[0][$$PropertyValue]>
| TokenByPropertyName<P[0][$$PropertyValue], Theme, ThemeMap>
| CSS.Globals
| Native.Globals
| ThemeUtil.ScaleValue
| undefined
)
Expand All @@ -66,7 +68,7 @@ export type CSS<
? (
| ValueByPropertyName<P[$$PropertyValue]>
| TokenByPropertyName<P[$$PropertyValue], Theme, ThemeMap>
| CSS.Globals
| Native.Globals
| undefined
)
: $$ScaleValue extends keyof P
Expand All @@ -91,7 +93,7 @@ export type CSS<
: K extends keyof Utils
? unknown
: (
| CSS.Globals
| Native.Globals
| Util.Index
| undefined
)
Expand Down
4 changes: 2 additions & 2 deletions packages/react/types/css.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9344,7 +9344,7 @@ export namespace AtRule {

export interface Property {
inherits?: Inherits;
initialValue?: string;
initialValue?: boolean | OnlyStringNumeric
syntax?: string;
}

Expand Down Expand Up @@ -9452,7 +9452,7 @@ export namespace AtRule {

type Size = DataType.PageSize | "auto" | "landscape" | "portrait" | OnlyStringNumeric;

type Inherits = "false" | "true";
type Inherits = "false" | "true" | boolean;

type Height = DataType.ViewportLength | OnlyString;

Expand Down
14 changes: 13 additions & 1 deletion packages/react/types/stitches.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,20 @@ export default interface Stitches<
style: {
/** 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'?: unknown
} & {
[K in Prelude]: K extends '@import' ? string : CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
[K in Prelude]: K extends '@import'
? string
: K extends '@font-face'
? CSSUtil.Native.AtRule.FontFace | 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

0 comments on commit 8d0def7

Please sign in to comment.