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

Function formatProps

packages/generator/src/shared.ts:18–25  ·  view source on GitHub ↗
(props: Record<string, string | null | undefined>, options: FormatPropsOptions = {})

Source from the content-addressed store, hash-verified

16}
17
18export const formatProps = (props: Record<string, string | null | undefined>, options: FormatPropsOptions = {}) => {
19 const { keyValueSeparator = ': ', propSeparator = ', ', quoteStyle = 'single' } = options
20 const quote = quoteStyle === 'single' ? "'" : quoteStyle === 'double' ? '"' : ''
21 return Object.entries(props)
22 .filter(([_, value]) => value != null)
23 .map(([key, value]) => `${key}${keyValueSeparator}${quote}${value}${quote}`)
24 .join(propSeparator)
25}
26
27export const formatJsxComponent = (component: string, props: Record<string, string | null | undefined>) => {
28 const formattedProps = formatProps(props, { keyValueSeparator: '=', propSeparator: ' ', quoteStyle: 'double' })

Callers 4

generateColorPaletteSpecFunction · 0.90
formatJsxComponentFunction · 0.85
generateJsxExampleFunction · 0.85
generateJsxExamplesFunction · 0.85

Calls 3

filterMethod · 0.80
entriesMethod · 0.80
joinMethod · 0.65

Tested by

no test coverage detected