-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from EPA-WG/develop
0.0.17
- Loading branch information
Showing
7 changed files
with
126 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# custom-element | ||
`Declarative Custom Element` (DCE) is a part of pure `Declarative Web Application` stack. A proof of concept as a part of | ||
[WCCG in Declarative custom elements](https://github.com/w3c/webcomponents-cg/issues/32#issuecomment-1321037301) and [Declarative Web Application](https://github.com/EPA-WG/dwa#readme) | ||
discussion. The functionality of DCE and its data access does not require programming using JavaScript. | ||
discussion. **NO-JS** The functionality of DCE and its data access does not require programming using JavaScript. | ||
|
||
It allows to define custom HTML tag with template filled from slots, attributes and data `slice` as of now from | ||
[local-storage][local-storage-demo], [http-request][http-request-demo], [location][location-demo]. | ||
|
@@ -133,10 +133,19 @@ constructor creates XML with | |
|
||
DOM content is replaced with results of instance XML transformation by declaration XSLT. | ||
|
||
# `tag` attribute | ||
allows to define the Custom Element tag registered by `window.customElements.define()`. | ||
|
||
If omitted, the tag is auto-generated and the content is rendered inline. | ||
```html | ||
<custom-element> my tag is {tag} </custom-element> | ||
``` | ||
See [demo](https://unpkg.com/@epa-wg/[email protected]/demo/external-template.html) for `tag` attribute use. | ||
|
||
# `src` attribute | ||
allows to refer either external template or template within external library by `#id` hash in URL. | ||
|
||
See [demo](demo/external-template.html) with various samples. | ||
See [demo](https://unpkg.com/@epa-wg/[email protected]/demo/external-template.html) with various samples. | ||
|
||
## types of template | ||
* HTML with DCE syntax ( slots, data slices, xslt operators, etc. ) | ||
|
@@ -308,9 +317,9 @@ within template | |
[github-image]: https://cdnjs.cloudflare.com/ajax/libs/octicons/8.5.0/svg/mark-github.svg | ||
[npm-image]: https://img.shields.io/npm/v/@epa-wg/custom-element.svg | ||
[npm-url]: https://npmjs.org/package/@epa-wg/custom-element | ||
[coverage-image]: https://unpkg.com/@epa-wg/[email protected].16/coverage/coverage.svg | ||
[coverage-url]: https://unpkg.com/@epa-wg/[email protected].16/coverage/lcov-report/index.html | ||
[storybook-url]: https://unpkg.com/@epa-wg/[email protected].16/storybook-static/index.html?path=/story/welcome--introduction | ||
[coverage-image]: https://unpkg.com/@epa-wg/[email protected].17/coverage/coverage.svg | ||
[coverage-url]: https://unpkg.com/@epa-wg/[email protected].17/coverage/lcov-report/index.html | ||
[storybook-url]: https://unpkg.com/@epa-wg/[email protected].17/storybook-static/index.html?path=/story/welcome--introduction | ||
[sandbox-url]: https://stackblitz.com/github/EPA-WG/custom-element?file=index.html | ||
[webcomponents-url]: https://www.webcomponents.org/element/@epa-wg/custom-element | ||
[webcomponents-img]: https://img.shields.io/badge/webcomponents.org-published-blue.svg | ||
|
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 |
---|---|---|
@@ -1,4 +1,35 @@ | ||
export function log(x: any): void; | ||
|
||
/** | ||
* @summary Declarative Custom Element as W3C proposal PoC with native(XSLT) based templating | ||
* ```html | ||
* <custom-element tag="my-element"> | ||
* <template> | ||
* <xsl:param name="p1" >default_P1</xsl:param> | ||
* <style> | ||
* color:green; | ||
* b{ color: blue;} | ||
* input:checked+b{ color: darkblue; text-shadow: 0 0 4px springgreen;} | ||
* </style> | ||
* <label> | ||
* green | ||
* <input type="checkbox" value="Glowing Blue" checked/><b>blue</b> | ||
* </label> | ||
* p1:{$p1} | ||
* </template> | ||
* </custom-element> | ||
* <my-element p1="abc"></my-element> | ||
* ``` | ||
* | ||
* @extends HTMLElement | ||
* @tag custom-element | ||
* @tag-name custom-element | ||
* @attr {boolean} hidden - hides DCE definition to prevent visual appearance of content. Wrap the payload into template tag to prevent applying the inline CSS in global scope. | ||
* @attr {string} tag - HTML tag for Custom Element. Used for window.customElements.define(). If not set, would be generated and DCE instance rendered inline. | ||
* @attr {string} src - full, relative, or hash URL to DCE template. | ||
* | ||
*/ | ||
export class CustomElement extends HTMLElement { | ||
static observedAttributes : string[]; | ||
} | ||
export default CustomElement; |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,70 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/web-types", | ||
"name": "@epa-wg/custom-element", | ||
"version": "0.0.17", | ||
"js-types-syntax": "typescript", | ||
"description-markup": "markdown", | ||
"contributions": { | ||
"html": { | ||
"elements": [ | ||
{ | ||
"name": "custom-element", | ||
"description": "Declarative Custom Element as W3C proposal PoC with native(XSLT) based templating", | ||
"doc-url": "https://github.com/EPA-WG/custom-element?tab=readme-ov-file#custom-element", | ||
"attributes": [ | ||
{ | ||
"name": "hidden", | ||
"description": "hides DCE definition to prevent visual appearance of content. Wrap the payload into template tag to prevent applying the inline CSS in global scope.", | ||
"required": false, | ||
"doc-url": "https://developer.mozilla.org/en-US/docs/web/html/global_attributes/hidden", | ||
"value": { | ||
"type": "boolean" | ||
} | ||
}, | ||
{ | ||
"name": "tag", | ||
"description": "HTML tag for Custom Element. Used for window.customElements.define(). If not set, would be generated and DCE instance rendered inline. ", | ||
"default": "", | ||
"required": false, | ||
"doc-url": "https://github.com/EPA-WG/custom-element?tab=readme-ov-file#tag-attribute", | ||
"value": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "src", | ||
"description": "full, relative, or hash URL to DCE template.", | ||
"default": "", | ||
"required": false, | ||
"doc-url": "https://github.com/EPA-WG/custom-element?tab=readme-ov-file#src-attribute", | ||
"value": { | ||
"type": "URL" | ||
} | ||
} | ||
], | ||
"slots": [], | ||
"js": { | ||
"events": [ | ||
{ | ||
"name": "value:changed", | ||
"description": "Emitted when data changes. Can be used for state serialization in hydration flow" | ||
} | ||
], | ||
"properties": [ | ||
{ | ||
"name": "value", | ||
"type": "string", | ||
"default": "", | ||
"description": "DCE state. Can be used for state serialization in hydration flow. Format TBD, most likely encoded XML string" | ||
} | ||
] | ||
}, | ||
"css": { | ||
"properties": [ | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |