I'm currently working on a story within Storybook for a Stencil component. It appears that all props function as expected when they are in lowercase. However, when a prop is written in camelCase, it doesn't seem to work properly. I've attempted using both camelCase and 'dash-case', but nothing seems to resolve the issue.
The Stencil component code:
import {Component, Prop, h} from '@stencil/core';
@Component({
tag: 'text-input',
shadow: true,
})
export class TextInput {
@Prop() label: string;
@Prop() inputId: string;
render() {
return (
<div class="text-input">
<label htmlFor={this.inputId}>{this.label}</label>
<input type="text" id={this.inputId} />
</div>
)
}
}
The corresponding Storybook story:
export default {
title: 'Components/Text Input',
argTypes: {
label: {control: 'text'},
inputid : {control: 'text'},
}
};
const Template = (args) => {
let tag = `<text-input label="${args.label}" inputId="${args.inputid}"></text-input>`;
return tag
};
export const Default = Template.bind({});
Default.args = {
label: 'First name:',
inputid: 'Input1'
};
In this case, inputId
is the problematic prop while label
works perfectly fine. Even renaming
inputId="${args.inputid}"
to input-id="${args.inputid}"
does not resolve the issue. The only solution is to change the Stencil prop to all-lowercase inputid
.
Any insights on how to address this challenge? Is there a way to maintain Stencil props in camelCase format and have them function correctly in Storybook?