Skip to content

Commit

Permalink
Add doc on slots.
Browse files Browse the repository at this point in the history
  • Loading branch information
francois2metz committed Apr 27, 2024
1 parent c7325f5 commit a604761
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
33 changes: 33 additions & 0 deletions docs/api/components.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,37 @@ ${componentInfo.events.map((event) => {
}).join('\n')}
` : '';


const formatBindings = (bindings) => {
if (!bindings) {
return ''
}
return bindings
.map(binding => {
const { name, description, type } = binding
if (!type) {
return ''
}
return `**${name}** \`${
type.name === 'union' && type.elements
? type.elements.map(({ name: insideName }) => insideName).join(', ')
: type.name
}\` - ${description}`
})
.join('\n')
}
const slotsMarkdown = componentInfo.slots ? `
## Slots
| Name | Description | Bindings |
| ------------- | ------------ | -------- |
${componentInfo.slots.map((slot) => {
const { description, bindings, name } = slot;
const readableBindings = bindings ? formatBindings(bindings) : '';
return [name, description, bindings].join('|');
}).join('\n')}
` : '';

return {
params: {
component: componentInfo.displayName,
Expand All @@ -50,6 +81,8 @@ ${propsMarkdown}
${eventsMarkdown}
${slotsMarkdown}
See [source](https://github.com/indoorequal/vue-maplibre-gl/tree/master/${componentInfo.sourceFiles[0]}).
`
};
Expand Down
8 changes: 8 additions & 0 deletions lib/components/marker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,12 @@ export default defineComponent({

return () => [h("div", slots.default ? slots.default({}) : undefined)];
},

/**
* Slot for popup component
* @slot default
*/
render() {
return null;
}
});
10 changes: 9 additions & 1 deletion lib/components/popup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,13 @@ export default defineComponent({
return () => [
h("div", { ref: root }, slots.default ? slots.default() : undefined),
];
},
}
,
/**
* Slot for popup content
* @slot default
*/
render() {
return null;
}
});

0 comments on commit a604761

Please sign in to comment.