Hi @break-stuff ,
When creating a different attribute name vs a property name using Lit's @property() decorator, the property is picked up by Storybook docs, but the attribute is not.
Minimal reproduction (minor changes to lit-starter-kit)
break-stuff/lit-starter-kit@main...scottnath:lit-starter-kit:main
I adjusted variation in the lit-starter-kit to be:
@property({ type: String, attribute: 'data-variation' })
variation?: 'default' | 'primary' | 'hollow' | 'transparent';
meaning the attribute is data-variation but the property is just variation.
I added two stories, and the first one AttrVsProp shows the attribute data-variation as empty and this.variation is not configured. In the second, PropVsAttr the attribute data-variation is populated correctly and this.variation has the correct content
export const AttrVsProp: Story = {
args: {
'default-slot': 'My Button',
variation: 'primary'
},
};
export const PropVsAttr: Story = {
args: {
'default-slot': 'My Button',
'data-variation': 'primary'
},
};
Is there a way to configure either cem-creation or the break-stuff tools to have this work as expected (both attribute and property properly populate the component and storybook controls when used) or is this a bug?
thank you for any help,
Scott
Hi @break-stuff ,
When creating a different attribute name vs a property name using Lit's
@property()decorator, the property is picked up by Storybook docs, but the attribute is not.Minimal reproduction (minor changes to lit-starter-kit)
break-stuff/lit-starter-kit@main...scottnath:lit-starter-kit:main
I adjusted
variationin the lit-starter-kit to be:meaning the attribute is
data-variationbut the property is justvariation.I added two stories, and the first one
AttrVsPropshows the attributedata-variationas empty andthis.variationis not configured. In the second,PropVsAttrthe attributedata-variationis populated correctly andthis.variationhas the correct contentIs there a way to configure either cem-creation or the break-stuff tools to have this work as expected (both attribute and property properly populate the component and storybook controls when used) or is this a bug?
thank you for any help,
Scott