MCPcopy
hub / github.com/premieroctet/openchakra / buildStyledProps

Function buildStyledProps

src/utils/code.ts:33–66  ·  view source on GitHub ↗
(propsNames: string[], childComponent: IComponent)

Source from the content-addressed store, hash-verified

31}
32
33const buildStyledProps = (propsNames: string[], childComponent: IComponent) => {
34 let propsContent = ``
35
36 propsNames.forEach((propName: string) => {
37 const propsValue = childComponent.props[propName]
38
39 if (
40 propName.toLowerCase().includes('icon') &&
41 childComponent.type !== 'Icon'
42 ) {
43 if (Object.keys(icons).includes(propsValue)) {
44 let operand = `={<${propsValue} />}`
45
46 propsContent += `${propName}${operand} `
47 }
48 } else if (propName !== 'children' && propsValue) {
49 let operand = `='${propsValue}'`
50
51 if (propsValue === true || propsValue === 'true') {
52 operand = ``
53 } else if (
54 propsValue === 'false' ||
55 isBoolean(propsValue) ||
56 !isNaN(propsValue)
57 ) {
58 operand = `={${propsValue}}`
59 }
60
61 propsContent += `${propName}${operand} `
62 }
63 })
64
65 return propsContent
66}
67
68const buildBlock = ({
69 component,

Callers 1

buildBlockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected