@@ -6,16 +6,20 @@ import ReactLiveScope from '../../theme/ReactLiveScope';
66type ComponentItemProps = {
77 componentName : string ;
88 props : Record < string , unknown > ;
9- }
9+ } ;
1010const ComponentItem = ( props : ComponentItemProps ) => {
1111 const { componentName, props : componentProps } = props ;
1212 const isComponentExists = ! ! ReactLiveScope [ componentName ] ;
1313 const propString = Object . keys ( componentProps ) . reduce ( ( acc , key ) => {
1414 const propValue = componentProps [ key ] ;
15- if ( typeof propValue === 'object' ) {
16- return `${ acc } ${ key } ={${ JSON . stringify ( propValue ) } } ` ;
15+ switch ( typeof propValue ) {
16+ case 'object' :
17+ return `${ acc } ${ key } ={${ JSON . stringify ( propValue ) } } ` ;
18+ case 'string' :
19+ return `${ acc } ${ key } ="${ propValue } " ` ;
20+ default :
21+ return `${ acc } ${ key } ={${ propValue } } ` ;
1722 }
18- return `${ acc } ${ key } ={${ propValue } } ` ;
1923 } , '' ) ;
2024
2125 const code = isComponentExists ? `<${ componentName } ${ propString } />` : '<Text>Component Not Found</Text>' ;
@@ -31,13 +35,12 @@ type Item = {
3135 component ?: string ;
3236 props ?: any ;
3337 value ?: any ;
34- }
38+ } ;
3539type ContentItemProps = {
3640 item : Item ;
3741 componentName : string ;
38- }
42+ } ;
3943export const ContentItem = ( { item, componentName} : ContentItemProps ) => {
40-
4144 const getFigmaEmbed = item => {
4245 const value = item . value ;
4346 const height = item . height || 450 ;
0 commit comments