Skip to content

Commit

Permalink
added brand-app docs (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
UcDust committed Jul 1, 2022
1 parent 8fb3045 commit 21036ef
Show file tree
Hide file tree
Showing 9 changed files with 6,021 additions and 129 deletions.
3 changes: 2 additions & 1 deletion brand-app/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ import "./pages/page-ucdlib-pages";
import "./pages/page-ucdlib-sils-permalink";
import "./pages/page-ucdlib-branding-bar";
import "./pages/page-ucdlib-sils-search-redirect";
import "./pages/page-ucdlib-md";
import "./pages/page-ucdlib-md";
import "./pages/page-ucdlib-properties";
6,022 changes: 5,899 additions & 123 deletions brand-app/package-lock.json

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions brand-app/pages/page-ucdlib-properties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { LitElement } from 'lit';
import {render, styles} from "./page-ucdlib-properties.tpl.js";

import {Mixin, MainDomElement} from '../../elements/utils/mixins';
import {BrandedPageElement, MdElement} from "../utils/index.js";

export default class PageUcdlibProperties extends Mixin(LitElement)
.with(MainDomElement, BrandedPageElement, MdElement) {

static get properties() {
return {

};
}

static get styles() {
return styles();
}

constructor() {
super();
this.render = render.bind(this);
}

/**
* @method firstUpdated
* @description Lit method called when element is first updated.
*/
firstUpdated() {
// document.querySelector('#entered-md').addEventListener('keyup', this._updateDisplayedMarkdown.bind(this));
}

/**
* @method _updateDisplayedMarkdown
* @description Helper method to update the ucdlib-md element with entered textarea text.
*/
_updateDisplayedMarkdown() {
// document.querySelector('#md-renderer').data = document.querySelector('#entered-md').value;
}

/**
* @method disconnectedCallback
* @description Web Component lifecycle method when the componenent is disposed of
*/
disconnectedCallback() {
// document.querySelector('#entered-md').removeEventListener('keyup', this._updateDisplayedMarkdown.bind(this));
}

}

customElements.define('page-ucdlib-properties', PageUcdlibProperties);
54 changes: 54 additions & 0 deletions brand-app/pages/page-ucdlib-properties.tpl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { html, css } from 'lit';
// import '@ucd-lib/theme-elements/ucdlib/ucdlib-md/ucdlib-md';

export function styles() {
const elementStyles = css`
:host {
display: block;
}
`;

return [elementStyles];
}

export function render() {
return html`
${this.pageTitle("Hydrate Complex Properties of a Web Component")}
<p>The <code>ucdlib-properties</code> element along with the <code>SSRPropertiesController</code> can be used to inject data into properties of a web component</p>
<h2>Using the component</h2>
${this.examplePanel(html`
<ucdlib-my-cool-component>
<ucdlib-properties type="json">
{"testing":"ok", "complex" : {"values": 1, "can-be": "nested"}}
</ucdlib-properties>
</ucdlib-my-cool-component>
`)}
<p>
In this case, <code>ucdlib-my-cool-component</code> is your custom component. In your custom components <code>connectedCallback</code>, connect the <code>SSRPropertiesController</code>
</p>
${this.examplePanel(html`
connectedCallback() {
super.connectedCallback();
this.propertiesController = new SSRPropertiesController(this);
}
`)}
<p>
The json data inside <code>ucdlib-properties</code> contains the properties that will be injected into your custom component. You can also use the <code>request-update</code> attribute
force a rerender, useful if you're adding properties that didn't exist in the custom component and you want to ensure it rerenders.
</p>
${this.examplePanel(html`
<ucdlib-my-cool-component>
<ucdlib-properties type="json" request-update>
{"testing":"ok", "complex" : {"values": 1, "can-be": "nested"}}
</ucdlib-properties>
</ucdlib-my-cool-component>
`)}
`;
}
2 changes: 2 additions & 0 deletions brand-app/pages/ucdlib-md.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Component class for translating/displaying markdown into sanitized html
| --- | --- | --- |
| data | <code>String</code> | text to hold markdown code |
| renderer | <code>Object</code> | an object holding element functions to override the default markdown behavior Format: reference the Marked Renderer documentation at https://marked.js.org/using_pro#renderer |
| use | <code>Object</code> | marked use object |
| options | <code>Object</code> | marked options object |

<a name="updated"></a>

Expand Down
6 changes: 6 additions & 0 deletions brand-app/pages/ucdlib-properties.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<a name="UcdlibProperties"></a>

### UcdlibProperties
Component class for declaritively wrapping complex properties and passing into parent component using SSRPropertiesController

**Kind**: global class
1 change: 1 addition & 0 deletions brand-app/ucdlib-theme-brand-app.tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ return html`
<li><a href="#ucdlib-sils-permalink">SILS Permalinks</a></li>
</ul>
<li><a href="#ucdlib-md">Markdown</a></li>
<li><a href="#ucdlib-properties">Properties</a></li>
</ul>
<ul link-text="Brand Guides" href="#overview">
Expand Down
4 changes: 2 additions & 2 deletions elements/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
//------------------------------------
// Library styles
//------------------------------------



// Avoid screen flash before components are registered
ucdlib-properties:not(:defined) {
display: none;
}

0 comments on commit 21036ef

Please sign in to comment.