Skip to content

Commit

Permalink
fix(781):Ensure Consistency between Storybook Documentation and Codeb…
Browse files Browse the repository at this point in the history
…ase Property Names
  • Loading branch information
RubirajAccenture committed Feb 21, 2024
1 parent e73c650 commit 5b5ebae
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
34 changes: 17 additions & 17 deletions packages/ui-library/src/components/form-label/index.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ BlrFormLabel.storyName = 'Form Label';

const defaultParams: BlrFormLabelType = {
theme: 'Light',
labelSize: 'md',
labelText: 'Label-text',
sizeVariant: 'md',
label: 'Label-text',
labelAppendix: '(Appendix)',
variant: 'label',
hasError: false,
forValue: 'Form Label',
};
BlrFormLabel.args = defaultParams;
Expand All @@ -150,24 +150,24 @@ export const SizeVariant = () => {
<div class="stories-form-label">
${WrappedBlrFormLabelRenderFunction({
...defaultParams,
labelSize: 'sm',
labelText: 'Form label SM',
sizeVariant: 'sm',
label: 'Form label SM',
labelAppendix: '(Appendix SM)',
})}
</div>
<div class="stories-form-label">
${WrappedBlrFormLabelRenderFunction({
...defaultParams,
labelSize: 'md',
labelText: 'Form label MD',
sizeVariant: 'md',
label: 'Form label MD',
labelAppendix: '(Appendix MD)',
})}
</div>
<div class="stories-form-label">
${WrappedBlrFormLabelRenderFunction({
...defaultParams,
labelSize: 'lg',
labelText: 'Form label LG',
sizeVariant: 'lg',
label: 'Form label LG',
labelAppendix: '(Appendix LG)',
})}
</div>`;
Expand All @@ -183,20 +183,20 @@ export const LabelAppendix = () => {
return html`
${WrappedBlrFormLabelRenderFunction({
...defaultParams,
labelSize: 'lg',
labelText: 'Form label',
sizeVariant: 'lg',
label: 'Form label',
labelAppendix: '(required)',
})}
${WrappedBlrFormLabelRenderFunction({
...defaultParams,
labelSize: 'lg',
labelText: 'Form label',
sizeVariant: 'lg',
label: 'Form label',
labelAppendix: '(optional)',
})}
${WrappedBlrFormLabelRenderFunction({
...defaultParams,
labelSize: 'lg',
labelText: 'Form label',
sizeVariant: 'lg',
label: 'Form label',
labelAppendix: ' ',
})}
`;
Expand All @@ -212,9 +212,9 @@ LabelAppendix.story = { name: ' ' };
export const HasError = () => {
return html` ${WrappedBlrFormLabelRenderFunction({
...defaultParams,
labelText: 'Error',
label: 'Error',
labelAppendix: '(with Appendix)',
variant: 'error',
hasError: true,
})}`;
};
HasError.story = { name: ' ' };
12 changes: 6 additions & 6 deletions packages/ui-library/src/components/form-label/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { LitElement } from 'lit';

const sampleParams: BlrFormLabelType = {
theme: 'Light',
labelText: 'Label text',
label: 'Label text',
labelAppendix: 'Appendix txt',
forValue: 'for_txt',
variant: 'label',
hasError: false,
};

// The label is not creating a shadow root itself, but errors if it is outside
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('blr-form-label', () => {
const element = await fixture(
WrappedBlrFormLabelRenderFunction({
...sampleParams,
labelText: 'New label',
label: 'New label',
labelAppendix: '',
})
);
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('blr-form-label', () => {
const element = await fixture(
WrappedBlrFormLabelRenderFunction({
...sampleParams,
labelText: 'New label',
label: 'New label',
labelAppendix: '',
})
);
Expand All @@ -102,7 +102,7 @@ describe('blr-form-label', () => {
const element = await fixture(
WrappedBlrFormLabelRenderFunction({
...sampleParams,
variant: 'error',
hasError: true,
})
);
const blrLabel = querySelectorDeep('label.blr-form-label', element.getRootNode() as HTMLElement);
Expand All @@ -120,7 +120,7 @@ describe('blr-form-label', () => {
});

it('has a size sm when "size" is set to "sm" ', async () => {
const element = await fixture(WrappedBlrFormLabelRenderFunction({ ...sampleParams, labelSize: 'sm' }));
const element = await fixture(WrappedBlrFormLabelRenderFunction({ ...sampleParams, sizeVariant: 'sm' }));

const label = querySelectorDeep('label', element.getRootNode() as HTMLElement);
const className = label?.className;
Expand Down
18 changes: 9 additions & 9 deletions packages/ui-library/src/components/form-label/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import { classMap } from 'lit-html/directives/class-map.js';
import { property } from 'lit/decorators.js';
import { ThemeType } from '../../foundation/_tokens-generated/index.themes';
import { formLight, formDark } from '../../foundation/semantic-tokens/form.css';
import { InputSizesType, LabelVariantType } from '../../globals/types';
import { InputSizesType } from '../../globals/types';

export class BlrFormLabel extends LitElement {
static styles = [];

@property() labelText = '';
@property() label = '';
@property() labelAppendix?: string;
@property() labelSize?: InputSizesType = 'md';
@property() sizeVariant?: InputSizesType = 'md';
@property() forValue: string | undefined;
@property() theme: ThemeType = 'Light';
@property() variant: LabelVariantType = 'label';
@property() hasError: boolean = false;

private _error: Error | null = null;

Expand Down Expand Up @@ -42,25 +42,25 @@ export class BlrFormLabel extends LitElement {
}

protected render() {
if (this.labelSize && !this._error) {
if (this.sizeVariant && !this._error) {
const dynamicStyles = this.theme === 'Light' ? [formLight] : [formDark];

const labelClasses = classMap({
'blr-form-label': true,
[`${this.labelSize}`]: this.labelSize,
[`${this.variant}`]: this.variant,
[`${this.sizeVariant}`]: this.sizeVariant,
[`${this.hasError}`]: this.hasError,
});

const spanClasses = classMap({
'blr-form-label-appendix': true,
[`${this.labelSize}`]: this.labelSize,
[`${this.sizeVariant}`]: this.sizeVariant,
});

return html`<style>
${dynamicStyles.map((style) => style)}
</style>
<label class=${labelClasses} for=${this.forValue || nothing}>
${this.labelText}
${this.label}
<span class=${spanClasses}>${this.labelAppendix}</span>
</label>`;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-library/src/components/number-input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ export class BlrNumberInput extends LitElement {
? html`
<div class="label-wrapper">
${BlrFormLabelRenderFunction({
labelText: this.label,
labelSize: this.size,
label: this.label,
sizeVariant: this.size,
labelAppendix: this.labelAppendix,
forValue: this.numberInputId,
theme: this.theme,
variant: this.hasError ? 'error' : 'label',
hasError: Boolean(this.label),
})}
</div>
`
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-library/src/components/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ export class BlrSelect extends LitElement {
? html`
<div class="label-wrapper">
${BlrFormLabelRenderFunction({
labelText: this.label,
label: this.label,
labelAppendix: this.labelAppendix,
labelSize: this.size,
sizeVariant: this.size,
forValue: this.selectId,
theme: this.theme,
variant: this.hasError ? 'error' : 'label',
hasError: Boolean(this.label),
})}
</div>
`
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-library/src/components/text-input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ export class BlrTextInput extends LitElement {
? html`
<div class="label-wrapper">
${BlrFormLabelRenderFunction({
labelText: this.label,
labelSize: this.size,
label: this.label,
sizeVariant: this.size,
labelAppendix: this.labelAppendix,
forValue: this.textInputId,
theme: this.theme,
variant: this.hasError ? 'error' : 'label',
hasError: Boolean(this.label),
})}
</div>
`
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-library/src/components/textarea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ export class BlrTextarea extends LitElement {
${this.hasLabel
? html`<div class="label-wrapper">
${BlrFormLabelRenderFunction({
labelText: this.label,
labelSize: this.size,
label: this.label,
sizeVariant: this.size,
labelAppendix: this.labelAppendix,
forValue: this.textareaId,
theme: this.theme,
variant: this.hasError ? 'error' : 'label',
hasError: Boolean(this.label),
})}
</div>`
: nothing}
Expand Down

0 comments on commit 5b5ebae

Please sign in to comment.