Skip to content

Commit

Permalink
Add context attributes and data props
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Unger committed Oct 30, 2023
1 parent 4447158 commit 5ac0104
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions web-ui/src/components/ufe-context/ufe-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@ import { getUfeRegistryAsync, UfeRegistry } from 'ufe-registry';
})
export class UfeContext {

// name of the context to render web components from contex configurations
@Prop() context: string

// selector to match the elements to render
@Prop() selector: string ;

// attributes will be propagated to rendered web components
@Prop() attributes: { [key: string]: string}

// if set, then the "data" property will be assigned to the rendered components
@Prop() data: any;

private ufeRegistry: UfeRegistry;

public async componentWillLoad() {
this.ufeRegistry = await getUfeRegistryAsync();
}





render() {
const contextElements = this.ufeRegistry.contextElements( this.context, this.selector );
this.ufeRegistry.preloadDependenciesAsync(contextElements);
Expand All @@ -30,6 +36,7 @@ export class UfeContext {
<Host>
<slot name="beforeALl"></slot>
{contextElements.map( el => {
el.attributes = Object.assign({}, el.attributes, this.attributes);
return (
<context-item>
<slot name="before-each"></slot>
Expand Down
1 change: 1 addition & 0 deletions web-ui/src/manifest.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"short_name": "{{app-title-short}}",
"start_url": "{{base-href}}",
"display": "fullscreen",
"display_override": ["window-controls-overlay"],
"icons": [{
"src": "{{app_icon_large}}",
"sizes": "512x512",
Expand Down

0 comments on commit 5ac0104

Please sign in to comment.