Skip to content

Commit

Permalink
Improve: Rename config.queries to config.at
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed May 27, 2024
1 parent 0fddeaa commit 361968f
Show file tree
Hide file tree
Showing 261 changed files with 326 additions and 336 deletions.
2 changes: 1 addition & 1 deletion examples/angular-with-runtime-rendering/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/astro-with-runtime-rendering/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/astro-with-static-extraction/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/blank/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/laravel-with-runtime-rendering/master.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
variables: {},
utilities: {},
breakpoints: {},
queries: {},
at: {},
keyframes: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/laravel-with-static-extraction/master.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
variables: {},
utilities: {},
breakpoints: {},
queries: {},
at: {},
keyframes: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/lit/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/next.js-with-runtime-rendering/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/next.js-with-static-extraction/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/next.js/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/nuxt.js-with-runtime-rendering/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/nuxt.js-with-static-extraction/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/nuxt.js/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/react-with-static-extraction/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/react/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte-with-runtime-rendering/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte-with-static-extraction/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/vite-with-static-extraction/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/vue.js-with-static-extraction/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/vue.js/master.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
rules: {},
variables: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/webpack-with-static-extraction/master.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
variables: {},
utilities: {},
breakpoints: {},
queries: {},
at: {},
keyframes: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/webpack/master.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
variables: {},
utilities: {},
breakpoints: {},
queries: {},
at: {},
keyframes: {},
selectors: {},
functions: {}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/tests/extract/watch/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const config: Config = {
},
rules: {},
utilities: {},
queries: {},
at: {},
animations: {},
selectors: {},
functions: {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import screenSizes from '../tokens/screen-sizes'

const queries = {
const at = {
all: 'media all',
print: 'media print',
screen: 'media screen',
Expand All @@ -9,7 +7,6 @@ const queries = {
portrait: 'media (orientation:portrait)',
motion: 'media (prefers-reduced-motion:no-preference)',
'reduced-motion': 'media (prefers-reduced-motion:reduce)',
...screenSizes,
}

export default queries
export default at
10 changes: 5 additions & 5 deletions packages/core/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import queries from './queries'
import at from './at'
import selectors from './selectors'
import utilities from './utilities'
import animations from './animations'
Expand All @@ -10,7 +10,7 @@ import type { PropertiesHyphen } from 'csstype'
import type { Rule, RuleDefinition, ValueComponent } from '../rule'

const config: Config = {
queries,
at,
selectors,
utilities,
rules,
Expand All @@ -27,7 +27,7 @@ const config: Config = {

export {
config,
queries,
at,
selectors,
utilities,
rules,
Expand All @@ -42,7 +42,7 @@ export type VariableDefinition = { [key in '' | `@${string}` | string]?: Variabl
export type CSSKeyframes = { [key in 'from' | 'to' | string]: PropertiesHyphen }
export type AnimationDefinitions = { [key: string]: CSSKeyframes }
export type SelectorDefinitions = { [key: string]: string | string[] }
export type MediaQueryDefinitions = { [key: string]: number | string | MediaQueryDefinitions }
export type AtDefinitions = { [key: string]: number | string | AtDefinitions }
export type StyleDefinitions = { [key: string]: string | StyleDefinitions }
export type RuleDefinitions = { [key in keyof typeof rules | string]?: RuleDefinition }
export type VariableDefinitions = { [key in keyof typeof rules]?: VariableDefinition } & { [key: string]: VariableDefinition }
Expand All @@ -57,7 +57,7 @@ export type FunctionDefinitions = { [key: string]: FunctionDefinition }
export interface Config {
extends?: (Config | any)[]
styles?: StyleDefinitions
queries?: MediaQueryDefinitions
at?: AtDefinitions
selectors?: SelectorDefinitions
utilities?: UtilityDefinitions
variables?: VariableDefinitions
Expand Down
16 changes: 11 additions & 5 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class MasterCSS {
this.stylesBy = {}
this.selectors = {}
this.variables = {}
this.queries = {}
this.at = {}
this.animations = {}
this.Rules.length = 0
this.variablesNativeRules = {}
Expand All @@ -60,7 +60,7 @@ export default class MasterCSS {
transparent: undefined
}

const { styles, selectors, variables, utilities, queries, rules, animations } = this.config
const { styles, selectors, variables, utilities, at, rules, animations } = this.config

function escapeString(str: string) {
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
Expand Down Expand Up @@ -118,6 +118,12 @@ export default class MasterCSS {
}
colorVariableNames[flatName] = undefined
}
/**
* resolve `variables.screen-*` to `at.*`
*/
if (variable.name.startsWith('screen-') && variable.type === 'number') {
this.at[variable.name.slice(7)] = variable.value
}
const currentMode = replacedMode ?? mode
if (currentMode !== undefined) {
if (Object.prototype.hasOwnProperty.call(this.variables, flatName)) {
Expand Down Expand Up @@ -252,8 +258,8 @@ export default class MasterCSS {
}
}

if (queries) {
this.queries = flattenObject(queries)
if (at) {
Object.assign(this.at, flattenObject(at))
}

if (animations) {
Expand Down Expand Up @@ -1215,7 +1221,7 @@ export default interface MasterCSS {
stylesBy: Record<string, string[]>
selectors: Record<string, [RegExp, string[]][]>
variables: Record<string, Variable>
queries: Record<string, string | number>
at: Record<string, string | number>
variablesNativeRules: Record<string, NativeRule>
hasKeyframesRule: boolean
animations: Record<string, AnimationDefinitions & { usage?: number, native?: NativeRule }>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export { default as MasterCSS, default } from './core'
export { default as extendConfig } from './utils/extend-config'
export { default as reorderForReadableClasses } from './utils/reorder-for-readable-classes'
export { default as areRuleModesEqual } from './utils/are-rule-modes-equal'
export { default as areRuleQueriesEqual } from './utils/are-rule-queries-equal'
export { default as areRuleAtEqual } from './utils/are-rule-at-equal'
export { default as areRuleSelectorsEqual } from './utils/are-rule-selectors-equal'
export { default as areRuleStatesEqual } from './utils/are-rule-states-equal'
export { default as areRulesDuplicated } from './utils/are-rules-duplicated'
Expand Down
Loading

0 comments on commit 361968f

Please sign in to comment.