File size: 624 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import type { SystemContext } from "@chakra-ui/react"
import { pretty } from "./pretty.js"

export function generateCondition(sys: SystemContext) {
  const keys = sys.conditions.keys().concat("base")
  const result = `
      export interface Conditions {
        ${keys
          .map((key) => {
            if (key === "base") {
              return `/** The base (=no conditions) styles to apply  */\n${key}: string`
            }
            const value = sys.conditions.resolve(key)
            return `/** \`${value}\` */\n'${key}': string`
          })
          .join("\n")}
      }
      `
  return pretty(result)
}