Skip to content

Commit

Permalink
Merge pull request #19183 from sonntag-philipp/sonntag-philipp/issues…
Browse files Browse the repository at this point in the history
…-19167-18858-custom-elements-manifest-update

Web-components: Fix custom-elements order of property application
  • Loading branch information
shilman authored Jun 9, 2023
2 parents 29be327 + 0bc5afc commit abfc677
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Object {
},
},
"type": Object {
"name": "void",
"name": "boolean",
},
},
"backSide": Object {
Expand Down Expand Up @@ -126,7 +126,7 @@ Object {
"name": "header",
"required": false,
"table": Object {
"category": "properties",
"category": "attributes",
"defaultValue": Object {
"summary": "\\"Your Message\\"",
},
Expand All @@ -152,7 +152,7 @@ Object {
"name": "rows",
"required": false,
"table": Object {
"category": "properties",
"category": "attributes",
"defaultValue": Object {
"summary": "[]",
},
Expand Down
17 changes: 14 additions & 3 deletions code/renderers/web-components/src/docs/custom-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,19 @@ interface Declaration {
}

function mapItem(item: TagItem, category: string): InputType {
const type =
category === 'properties' ? { name: item.type?.text || item.type } : { name: 'void' };
let type;
switch (category) {
case 'attributes':
case 'properties':
type = { name: item.type?.text || item.type };
break;
case 'slots':
type = { name: 'string' };
break;
default:
type = { name: 'void' };
break;
}

return {
name: item.name,
Expand Down Expand Up @@ -139,9 +150,9 @@ export const extractArgTypesFromElements = (tagName: string, customElements: Cus
const metaData = getMetaData(tagName, customElements);
return (
metaData && {
...mapData(metaData.attributes ?? [], 'attributes'),
...mapData(metaData.members ?? [], 'properties'),
...mapData(metaData.properties ?? [], 'properties'),
...mapData(metaData.attributes ?? [], 'attributes'),
...mapData(metaData.events ?? [], 'events'),
...mapData(metaData.slots ?? [], 'slots'),
...mapData(metaData.cssProperties ?? [], 'css custom properties'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
],
"slots": [
{
"description": "This is an unnamed slot (the default slot)",
"name": ""
"name": "prefix",
"description": "Label prefix"
}
],
"members": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ import './demo-wc-card';

export default {
component: 'demo-wc-card',
render: ({ backSide, header, rows, prefix }) =>
html`
<demo-wc-card .backSide="${backSide}" .header="${header}" .rows="${rows}"
><span slot="prefix">${prefix}</span>A simple card</demo-wc-card
>
`,
};

const Template = ({ backSide, header, rows }) =>
html`
<demo-wc-card .backSide="${backSide}" .header="${header}" .rows="${rows}"
>A simple card</demo-wc-card
>
`;
export const Front = {
args: { backSide: false, header: undefined, rows: [] },
};

export const Back = {
args: { backSide: true, header: undefined, rows: [] },
};

export const Front = Template.bind({});
Front.args = { backSide: false, header: undefined, rows: [] };
export const Prefix = {
args: { backSide: false, prefix: 'prefix:', header: 'my header', rows: [] },
};
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class DemoWcCard extends LitElement {
</div>
</div>
<div id="back" part="back">
<div class="header">${this.header}</div>
<div class="header"><slot name="prefix"></slot> ${this.header}</div>
<div class="content">
${this.rows.length === 0
Expand Down

0 comments on commit abfc677

Please sign in to comment.