Skip to content

Commit

Permalink
fix(ui-library): remove margin in error state (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
angsherpa456 committed Mar 20, 2024
1 parent daebf49 commit 7791519
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ const sampleParams: BlrInputFieldNumberType = {
inputFieldNumberId: 'egal',
label: 'Hello',
hasHint: false,
hintMessage: 'This is a sample hint',
hintIcon: 'blr360',
errorIcon: 'blrInfo',
errorMessage: "OMG it's an error",
value: 4,
unit: 'gr',
decimals: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class BlrInputFieldNumber extends LitElement {
[this.stepperVariant || 'split']: this.stepperVariant || 'split',
});

const captionContent = html`
const getCaptionContent = () => html`
${this.hasHint && (this.hintMessage || this.hintIcon)
? html`
<div class="hint-wrapper">
Expand Down Expand Up @@ -341,8 +341,8 @@ export class BlrInputFieldNumber extends LitElement {
</div>
</div>
${this.hasHint || this.hasError
? BlrFormCaptionGroupRenderFunction({ sizeVariant: this.sizeVariant }, captionContent)
${(this.hasHint && this.hintMessage) || (this.hasError && this.errorMessage)
? BlrFormCaptionGroupRenderFunction({ sizeVariant: this.sizeVariant }, getCaptionContent())
: nothing}
`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ const defaultParams: BlrInputFieldTextType = {
readonly: false,
hasError: false,
errorMessage: '',
errorIcon: 'blrInfo',

errorIcon: undefined,
type: 'text',
inputIcon: 'blr360',
showInputIcon: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const sampleParams: BlrInputFieldTextType = {
readonly: false,
required: false,
hasError: false,
errorMessage: '',
errorMessage: "OMG it's an error",
errorIcon: 'blrInfo',
arialabel: 'InputFieldText',
inputFieldTextId: 'Input Id',
Expand Down
25 changes: 23 additions & 2 deletions packages/ui-library/src/components/input-field-text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,27 @@ export class BlrInputFieldText extends LitElement {
this.size,
]).toLowerCase() as SizesType;

const getCaptionContent = () => html`
${this.hasHint && (this.hintMessage || this.hintIcon)
? BlrFormCaptionRenderFunction({
variant: 'hint',
theme: this.theme,
sizeVariant: this.size,
message: this.hintMessage,
icon: this.hintIcon,
})
: nothing}
${this.hasError && (this.errorMessage || this.errorIcon)
? BlrFormCaptionRenderFunction({
variant: 'error',
theme: this.theme,
sizeVariant: this.size,
message: this.errorMessage,
icon: this.errorIcon,
})
: nothing}
`;

const captionContent = html`

Check failure on line 163 in packages/ui-library/src/components/input-field-text/index.ts

View workflow job for this annotation

GitHub Actions / eslint

'captionContent' is assigned a value but never used
${this.hasHint && (this.hintMessage || this.hintIcon)
? BlrFormCaptionRenderFunction({
Expand Down Expand Up @@ -237,8 +258,8 @@ export class BlrInputFieldText extends LitElement {
)}`
: nothing}
</div>
${this.hasHint || this.hasError
? BlrFormCaptionGroupRenderFunction({ sizeVariant: this.size }, captionContent)
${(this.hasHint && this.hintMessage) || (this.hasError && this.errorMessage)
? BlrFormCaptionGroupRenderFunction({ sizeVariant: this.size }, getCaptionContent())
: nothing}
</div>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const defaultParams: BlrTextareaType = {
required: false,
hasError: false,
errorMessage: '',
errorMessageIcon: 'blr360',
errorMessageIcon: undefined,
arialabel: 'Text Area',
textAreaId: '#textAreaId',
name: 'Text Area',
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 @@ -172,7 +172,7 @@ export class BlrTextarea extends LitElement {

const counterVariant = this.determinateCounterVariant();

const captionContent = html`
const getCaptionContent = () => html`
${this.hasHint && (this.hintMessage || this.hintMessageIcon)
? BlrFormCaptionRenderFunction({
variant: 'hint',
Expand Down Expand Up @@ -231,8 +231,8 @@ export class BlrTextarea extends LitElement {
@keyup=${this.updateCounter}
></textarea>
<div class="${textareaInfoContainer}">
${this.hasHint || this.hasError
? BlrFormCaptionGroupRenderFunction({ sizeVariant: this.sizeVariant }, captionContent)
${(this.hasHint && this.hintMessage) || (this.hasError && this.errorMessage)
? BlrFormCaptionGroupRenderFunction({ sizeVariant: this.sizeVariant }, getCaptionContent())
: nothing}
${this.hasCounter
? BlrCounterRenderFunction({
Expand Down

0 comments on commit 7791519

Please sign in to comment.