Skip to content

Commit

Permalink
fix(882): textarea label space alignment and counter alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
RubirajAccenture committed Feb 13, 2024
1 parent 993a94c commit 054ce18
Show file tree
Hide file tree
Showing 6 changed files with 552 additions and 514 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ const defaultParams: BlrTextInputType = {
readonly: false,
hasError: false,
errorMessage: '',
errorIcon: 'blrInfo',
type: 'text',
inputIcon: 'blr360',
showInputIcon: true,
Expand Down Expand Up @@ -387,7 +386,6 @@ const generateDisabledArgTypes = (argTypes: string[]) => {
const disabledArgTypes = {};
argTypes.forEach((argType: string) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
disabledArgTypes[argType] = {
table: {
disable: true,
Expand Down
29 changes: 7 additions & 22 deletions packages/ui-library/src/components/forms/textarea/index.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export const styleCustom = typeSafeNestedCss`
.blr-textarea-info-container {
display: flex;
justify-content: space-between;
justify-content: right;
&.hint, &.error{
justify-content: space-between;
}
&.sm {
> blr-counter {
Expand All @@ -63,16 +67,16 @@ export const styleCustom = typeSafeNestedCss`
`;

export const { tokenizedLight: textAreaLight, tokenizedDark: textAreaDark } = renderThemedCssStrings((componentTokens, semanticTokens) => {
const { SM, MD, LG } = semanticTokens.Forms;
const { TextArea } = componentTokens.Forms;

const { SurfaceFill } = semanticTokens.Forms;
return typeSafeNestedCss`
.textarea-input-control {
resize: none;
display: block;
max-width: 100%;
word-break: break-all;
width: 100%;
background-color: ${SurfaceFill.Default.Rest};
&.both {
resize: both;
Expand Down Expand Up @@ -101,25 +105,6 @@ export const { tokenizedLight: textAreaLight, tokenizedDark: textAreaDark } = re
&.lg {
min-height: ${TextArea.InputField.MinHeight.LG};
}
.flex-container {
display: flex;
align-items: flex-start;
justify-content: space-between;
flex-wrap: wrap;
&.sm {
margin: ${SM.CaptionSlot.Margin};
}
&.md {
margin: ${MD.CaptionSlot.Margin};
}
&.lg {
margin: ${LG.CaptionSlot.Margin};
}
}
}
`;
});
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ const argTypesToDisable = [
const generateDisabledArgTypes = (argTypes: string[]) => {
const disabledArgTypes = {};
argTypes.forEach((argType: string) => {
// @ts-expect-error todo
disabledArgTypes[argType] = {
table: {
disable: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '@boiler/ui-library/dist/';

import { BlrTextareaRenderFunction } from './renderFunction';
import type { BlrTextareaType } from '@boiler/ui-library/dist/';
import { BlrTextareaType } from './index';

import { fixture, expect } from '@open-wc/testing';
import { querySelectorAllDeep, querySelectorDeep } from 'query-selector-shadow-dom';
Expand Down
67 changes: 31 additions & 36 deletions packages/ui-library/src/components/forms/textarea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class BlrTextarea extends LitElement {
@property() pattern?: string;
@property() hasError?: boolean;
@property() errorMessage?: string;
@property() errorIcon?: SizelessIconType;
@property() errorIcon?: SizelessIconType = undefined;
@property() hint?: string;
@property() hasHint = true;
@property() hintMessage?: string;
Expand Down Expand Up @@ -148,8 +148,9 @@ export class BlrTextarea extends LitElement {
const dynamicStyles = this.theme === 'Light' ? [formLight, textAreaLight] : [formDark, textAreaDark];

const classes = classMap({
'blr-textarea': true,
'error': this.hasError || false,
[`${this.size}`]: this.size,
error: this.hasError || false,
});

const textareaClasses = classMap({
Expand All @@ -161,6 +162,8 @@ export class BlrTextarea extends LitElement {

const textareaInfoContainer = classMap({
'blr-textarea-info-container': true,
'hint': this.hasHint || false,
'error': this.hasError || false,
[`${this.size}`]: this.size,
});

Expand Down Expand Up @@ -191,24 +194,20 @@ export class BlrTextarea extends LitElement {
<style>
${dynamicStyles}
</style>
<div class="${classes} blr-textarea">
${
this.hasLabel
? html`
<div class="label-wrapper">
${BlrFormLabelRenderFunction({
labelText: this.label,
labelSize: this.size,
labelAppendix: this.labelAppendix,
forValue: this.textareaId,
theme: this.theme,
variant: this.hasError ? 'error' : 'label',
})}
</div>
`
: nothing
}
</div>
<div class="${classes}">
${this.hasLabel
? html`<div class="label-wrapper">
${BlrFormLabelRenderFunction({
labelText: this.label,
labelSize: this.size,
labelAppendix: this.labelAppendix,
forValue: this.textareaId,
theme: this.theme,
variant: this.hasError ? 'error' : 'label',
})}
</div>`
: nothing}
<textarea
class="blr-form-element textarea-input-control ${textareaClasses}"
id="${this.textareaId || nothing}"
Expand All @@ -232,22 +231,18 @@ ${this.value}
</textarea
>
<div class="${textareaInfoContainer}">
${
this.hasHint || this.hasError
? BlrFormCaptionGroupRenderFunction({ size: this.size }, captionContent)
: nothing
}
${
this.showCounter
? BlrCounterRenderFunction({
variant: counterVariant,
current: this.count,
max: this.maxLength || 0,
size: this.size,
theme: this.theme,
})
: nothing
}
${this.hasHint || this.hasError
? BlrFormCaptionGroupRenderFunction({ size: this.size }, captionContent)
: nothing}
${this.showCounter
? BlrCounterRenderFunction({
variant: counterVariant,
current: this.count,
max: this.maxLength || 0,
size: this.size,
theme: this.theme,
})
: nothing}
</div>
</div>
`;
Expand Down
Loading

0 comments on commit 054ce18

Please sign in to comment.