Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui-library): props alignment form label #949

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading