Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NcVNodes): add re-export in root export and add docs #5664

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/components/NcVNodes/NcVNodes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,53 @@
-
-->

<docs>
A util component to render a VNode or an array of VNodes from the prop or the default slot.

### Render the given or generated VNodes

```vue
<template>
<NcVNodes :vnodes="renderDiv()" />
</template>

<script>
export default {
methods: {
renderDiv() {
return this.$createElement('div', 'This div was created programmatically as a VNode')
},
}
}
</script>
```

### Render content in a conditional wrapper

```vue
<template>
<div>
<p>
<NcCheckboxRadioSwitch :checked.sync="shouldRenderNcNoteCard">Render text inside "NcNoteCard"</NcCheckboxRadioSwitch>
</p>
<component :is="shouldRenderNcNoteCard ? 'NcNoteCard' : 'NcVNodes'">
<p>This content is rendered {{ shouldRenderNcNoteCard ? 'with' : 'without' }} a "NcNoteCard" wrapper</p>
</component>
</div>
</template>

<script>
export default {
data() {
return {
shouldRenderNcNoteCard: true,
}
},
}
</script>
```
</docs>

<script>
export default {
name: 'NcVNodes',
Expand All @@ -39,6 +86,8 @@ export default {
* @return {object} The created VNode
*/
render(h) {
// eslint-disable-next-line jsdoc/check-tag-names
/** @slot Directly rendered content */
return this.vnodes || this.$slots?.default || this.$scopedSlots?.default?.()
},
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ export { default as NcSelectTags } from './NcSelectTags/index.js'
export { default as NcSettingsInputText } from './NcSettingsInputText/index.js'
export { default as NcSettingsSection } from './NcSettingsSection/index.js'
export { default as NcSettingsSelectGroup } from './NcSettingsSelectGroup/index.js'
export { default as NcTextArea } from './NcTextArea/index.js'
export { default as NcTextField } from './NcTextField/index.js'
export { default as NcTimezonePicker } from './NcTimezonePicker/index.js'
export { default as NcUserBubble } from './NcUserBubble/index.js'
export { default as NcUserStatusIcon } from './NcUserStatusIcon/index.js'
export { default as NcTextArea } from './NcTextArea/index.js'
export { default as NcVNodes } from './NcVNodes/index.js'
Loading