Skip to content

Commit

Permalink
fix(ui-library): props alignment form label (#949)
Browse files Browse the repository at this point in the history
  • Loading branch information
RubirajAccenture authored and ChristianHoffmannS2 committed Mar 26, 2024
1 parent 0ecf0d8 commit 877556c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
16 changes: 6 additions & 10 deletions packages/ui-library/src/components/form-label/index.stories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import { Themes } from '../../foundation/_tokens-generated/index.themes';
import { FormSizes, LabelVariants } from '../../globals/constants';
import { FormSizes } from '../../globals/constants';
import { BlrFormLabelType } from './index';
import { BlrFormLabelRenderFunction } from './renderFunction';
import { html } from 'lit-html';
Expand Down Expand Up @@ -54,11 +54,9 @@ export default {
category: 'Content / Settings',
},
},

hasError: {
description: 'Choose if component has an error.',
options: LabelVariants,
control: { type: 'select' },
defaultValue: false,
table: {
category: 'Validation',
},
Expand Down Expand Up @@ -86,10 +84,8 @@ export default {
- [**Appearance**](#appearance)
- [**Size Variant**](#size-variant)
- [**Content / Settings**](#content--settings)
- [**Label Appendix**](#label-appendix)
- [**Validation**](#validation)
- [**Has Error**](#has-error)
Expand Down Expand Up @@ -139,7 +135,7 @@ BlrFormLabel.args = defaultParams;

/**
* ## Appearance
* ### Size Variant
* ### Size Variant
* The Form Label component comes in 3 sizes: SM, MD and LG.
*/
export const SizeVariant = () => {
Expand Down Expand Up @@ -180,19 +176,19 @@ export const LabelAppendix = () => {
return html`
${WrappedBlrFormLabelRenderFunction({
...defaultParams,
sizeVariant: 'lg',
sizeVariant: 'md',
label: 'Form label',
labelAppendix: '(required)',
})}
${WrappedBlrFormLabelRenderFunction({
...defaultParams,
sizeVariant: 'lg',
sizeVariant: 'md',
label: 'Form label',
labelAppendix: '(optional)',
})}
${WrappedBlrFormLabelRenderFunction({
...defaultParams,
sizeVariant: 'lg',
sizeVariant: 'md',
label: 'Form label',
labelAppendix: ' ',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('blr-form-label', () => {
);
const blrLabel = querySelectorDeep('label.blr-form-label', element.getRootNode() as HTMLElement);
const errorLabel = blrLabel?.getAttribute('class');
expect(errorLabel).to.contain('true');
expect(errorLabel).to.contain('error');
});

it('has a size md by default', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-library/src/components/form-label/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class BlrFormLabel extends LitElement {
const labelClasses = classMap({
'blr-form-label': true,
[`${this.sizeVariant}`]: this.sizeVariant,
[`${this.hasError}`]: this.hasError,
'error': this.hasError,
});

const spanClasses = classMap({
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-library/src/components/number-input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class BlrNumberInput extends LitElement {
labelAppendix: this.labelAppendix,
forValue: this.numberInputId,
theme: this.theme,
hasError: Boolean(this.label),
hasError: Boolean(this.hasError),
})}
</div>
`
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-library/src/components/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class BlrSelect extends LitElement {
sizeVariant: this.size,
forValue: this.selectId,
theme: this.theme,
hasError: Boolean(this.label),
hasError: Boolean(this.hasError),
})}
</div>
`
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-library/src/components/text-input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class BlrTextInput extends LitElement {
labelAppendix: this.labelAppendix,
forValue: this.textInputId,
theme: this.theme,
hasError: Boolean(this.label),
hasError: Boolean(this.hasError),
})}
</div>
`
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-library/src/components/textarea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class BlrTextarea extends LitElement {
labelAppendix: this.labelAppendix,
forValue: this.textareaId,
theme: this.theme,
hasError: Boolean(this.label),
hasError: Boolean(this.hasError),
})}
</div>`
: nothing}
Expand Down

0 comments on commit 877556c

Please sign in to comment.