Bugfix/context provider storybook (#699)

* move context-provider element to src/core to make it available to everything

* add extra documentation to the context-provider element

* fix imports from storybook

* import context-provider in app to make it globally available

* import umb-context-provider
This commit is contained in:
Jacob Overgaard
2023-05-09 11:44:45 +02:00
committed by GitHub
parent ed60e8715f
commit 593102ba3d
4 changed files with 12 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ import 'element-internals-polyfill';
import './core/router/router-slot.element';
import './core/router/variant-router-slot.element';
import './core/context-provider/context-provider.element';
import { UUIIconRegistryEssential } from '@umbraco-ui/uui';
import { css, html } from 'lit';

View File

@@ -2,12 +2,21 @@ import { html } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
import type { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
/**
* Provides a value to the context down the DOM tree.
*
* @remarks This element is a wrapper around the `provideContext` function.
* @slot - The context will be available to all descendants given in the default slot.
* @throws {Error} If the key property is not set.
* @throws {Error} If the value property is not set.
*/
@customElement('umb-context-provider')
export class UmbContextProviderElement extends UmbLitElement {
/**
* The value to provide to the context.
* @required
* @optional
*/
@property({ type: Object, attribute: false })
create?: (host: UmbControllerHostElement) => unknown;
@@ -24,7 +33,7 @@ export class UmbContextProviderElement extends UmbLitElement {
* @required
*/
@property({ type: String })
key!: string;
key!: string | UmbContextToken;
connectedCallback() {
super.connectedCallback();

View File

@@ -1,6 +1,5 @@
import { html } from 'lit';
import { UmbInstallerContext } from '../installer.context';
import '../../../storybook/utils/context-provider/context-provider.element';
export const installerContextProvider = (story: any, installerContext = new UmbInstallerContext()) => html`
<umb-context-provider