Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
b8b899fe
Unverified
Commit
b8b899fe
authored
3 years ago
by
Bekerle, Patrizio
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation for overriding slots in nested web components
parent
e3594e1d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#47522
passed
3 years ago
Stage: test
Stage: deploy
Stage: e2e
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/common/README.md
+44
-0
44 additions, 0 deletions
packages/common/README.md
packages/common/package.json
+1
-1
1 addition, 1 deletion
packages/common/package.json
packages/file-handling/package.json
+1
-1
1 addition, 1 deletion
packages/file-handling/package.json
with
46 additions
and
2 deletions
packages/common/README.md
+
44
−
0
View file @
b8b899fe
...
...
@@ -38,3 +38,47 @@ You can use this web component to show translated html.
```
The English or German text will be shown according to the
`lang`
attribute.
## Overriding slots in nested web components
If slots are used in web components then it is best to derive your component class from
`DBPLitElement`
and subscribe to the attribute
`html-overrides`
everywhere you use it with
`subscribe="html-overrides"`
.
This way integrators who are using topics or activities are able to globally override these slots
in their root html.
Example of the part of an
`index.html`
file for overriding the
`auth-info`
text in all Nextcloud
file pickers of the signature topic:
```
html
<dbp-signature
html-overrides=
"global-override"
></dbp-signature>
<template
id=
"global-override"
>
<template
id=
"dbp-nextcloud-file-picker"
>
<div
slot=
"auth-info"
>
<dbp-translated
subscribe=
"lang"
>
<div
slot=
"de"
>
Deutscher Text
</div>
<div
slot=
"en"
>
English Text
</div>
</dbp-translated>
</div>
</template>
</template>
```
By using
`html-overrides="global-override"`
in the topic
`dbp-signature`
you are able to define
a template with
`id="global-override"`
that can hold one or more other templates for different components.
In our case we have a template
`id="dbp-nextcloud-file-picker"`
, because we want to override slots
in the component
`dbp-nextcloud-file-picker`
inside the signature topic.
You can define one or more slots in that template that should be overridden.
In our example we only want to override the slot
`auth-info`
, that holds additional text to add in
the Nextcloud file picker component.
We are using the
`dbp-translated`
component to insert translated text at the specified position
in the Nextcloud file picker.
This diff is collapsed.
Click to expand it.
packages/common/package.json
+
1
−
1
View file @
b8b899fe
{
"name"
:
"@dbp-toolkit/common"
,
"homepage"
:
"https://gitlab.tugraz.at/dbp/web-components/toolkit/-/tree/master/packages/common"
,
"version"
:
"0.2.
8
"
,
"version"
:
"0.2.
9
"
,
"module"
:
"index.js"
,
"license"
:
"LGPL-2.1-or-later"
,
"repository"
:
{
...
...
This diff is collapsed.
Click to expand it.
packages/file-handling/package.json
+
1
−
1
View file @
b8b899fe
{
"name"
:
"@dbp-toolkit/file-handling"
,
"homepage"
:
"https://gitlab.tugraz.at/dbp/web-components/toolkit/-/tree/master/packages/file-handling"
,
"version"
:
"0.2.
6
"
,
"version"
:
"0.2.
7
"
,
"main"
:
"src/index.js"
,
"license"
:
"LGPL-2.1-or-later"
,
"repository"
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment