MCPcopy Create free account
hub / github.com/chakra-ui/panda / getStyleObjects

Method getStyleObjects

packages/core/src/static-css.ts:224–263  ·  view source on GitHub ↗

* This transforms a static css config into the same format as in the ParserResult, * so that it can be processed by the same logic as styles found in app code. * * e.g. * @example { css: [{ color: ['red', 'blue'] }] } => { css: [{ color: 'red }, { color: 'blue }] } * @example { css: [

(options: StaticCssOptions)

Source from the content-addressed store, hash-verified

222 *
223 */
224 getStyleObjects(options: StaticCssOptions) {
225 const { css = [], patterns = {} } = options
226
227 const results: StaticCssResults = {
228 css: [],
229 recipes: [],
230 patterns: [],
231 }
232
233 css.forEach((rule) => {
234 const cssObjects = this.getCssRuleObjects(rule)
235 results.css.push(...cssObjects)
236 })
237
238 const recipes = (options.recipes ?? {}) as Record<string, RecipeRule[]>
239
240 Object.entries(recipes).forEach(([recipe, rules]) => {
241 const recipeNode = this.getRecipeNode(recipe)
242 if (!recipeNode) return
243
244 // adds the recipe.base to the results
245 results.recipes.push({ [recipe]: {} })
246
247 if (recipeNode.config.compoundVariants) {
248 results.css.push(...this.getRecipeCompoundVariantCssObjects(recipeNode))
249 }
250
251 rules.forEach((rule) => {
252 results.recipes.push(...this.getRecipeRuleObjects(recipe, rule, recipeNode))
253 })
254 })
255
256 Object.entries(patterns).forEach(([pattern, rules]) => {
257 rules.forEach((rule) => {
258 results.patterns.push(...this.getPatternRuleObjects(pattern, rule))
259 })
260 })
261
262 return results
263 }
264
265 process = (options: StaticCssOptions, stylesheet?: Stylesheet): StaticCssEngine => {
266 const { context } = this

Callers 1

StaticCssClass · 0.95

Calls 2

forEachMethod · 0.80
entriesMethod · 0.80

Tested by

no test coverage detected