Skip to content

Commit

Permalink
feat(dynamic-component): stringify and parse array props
Browse files Browse the repository at this point in the history
  • Loading branch information
stfsy committed Jun 23, 2022
1 parent c3505eb commit 6c99f94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/docs/dynamic-component-display.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<option class="w-24 text-lg">true</option>
<option class="w-24 text-lg">false</option>
</select>
<input v-else-if="prop.allowInput && prop.type === 'Array'" :value="JSON.stringify(componentProps[prop.name])"
@input="castAndSet(prop, $event)"
class="text-base border-b-2 border-b-solid border-gray-900 w-20">
<input v-else-if="prop.allowInput" :value="componentProps[prop.name]"
@input="castAndSet(prop, $event)"
class="text-base border-b-2 border-b-solid border-gray-900 w-20">
Expand Down Expand Up @@ -145,6 +148,8 @@ function castAndSet(prop, event) {
} else {
componentProps.value[prop.name] = Boolean(value)
}
} else if (prop.type === 'Array') {
componentProps.value[prop.name] = JSON.parse(value)
} else if (prop.type === 'Number') {
componentProps.value[prop.name] = Number(value)
} else {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { default as DynamicComponentDisplay } from './components/docs/dynamic-co
export { default as DropDownMenuBannerItem } from './components/drop-down-menu-banner-item.vue';
export { default as DropDownMenuItem } from './components/drop-down-menu-item.vue';
export { default as DropDownMenu } from './components/drop-down-menu.vue';
export { default as FormElementErrorMessage } from './components/form-element-error-message.vue';
export { default as Headlines } from './components/headlines.vue';
export { default as NavButton } from './components/nav-button.vue';
export { default as NavLink } from './components/nav-link.vue';
Expand Down

0 comments on commit 6c99f94

Please sign in to comment.