-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add dev docs for custom component extension
- Loading branch information
Showing
3 changed files
with
68 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
docs/extension-system/extension-types/custom-components.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: 'Custom component extensions' | ||
date: 2024-02-14T00:00:00+00:00 | ||
weight: 60 | ||
geekdocRepo: https://github.com/owncloud/web | ||
geekdocEditPath: edit/master/docs/extension-system/extension-types | ||
geekdocFilePath: custom-components.md | ||
geekdocCollapseSection: true | ||
--- | ||
|
||
{{< toc >}} | ||
|
||
## Extension Type CustomComponent | ||
|
||
CustomComponent extensions need to define one or multiple `extensionPointId`s as render target. A `CustomComponentTarget` component for this very | ||
extension point needs to be mounted in the current view. | ||
|
||
### Configuration | ||
|
||
To define a custom component extension, you implement the `CustomComponentExtension` interface. | ||
Here's how it looks like: | ||
|
||
```typescript | ||
interface CustomComponentExtension { | ||
id: string, | ||
type: 'customComponent', | ||
extensionPointIds: string[], | ||
content: Slot | ||
} | ||
``` | ||
|
||
For `id`, `type`, and `extensionPointIds`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in the top level docs. | ||
|
||
The `content` object configures the actual custom component to render in the target extension point. | ||
|
||
### Example | ||
|
||
A simple example for a custom component extension would be the `NyanCat` progress bar component, being | ||
targeted at the `global-progress-bar` extension point as render target. | ||
|
||
```typescript | ||
({ | ||
id: 'com.github.owncloud.web.app.progress-bars.nyan-cat', | ||
type: 'customComponent', | ||
extensionPointIds: ['app.runtime.global-progress-bar'], | ||
content: (slots) => [h(NyanCat, slots)], | ||
userPreference: { | ||
optionLabel: $gettext('Nyan Cat progress bar') | ||
} | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters