Skip to content

Commit 60f5cbd

Browse files
committed
feat(ui-library): removing calculate icon name from hint component and aligning icon top left
1 parent 40d6fce commit 60f5cbd

File tree

7 files changed

+57
-42
lines changed

7 files changed

+57
-42
lines changed

packages/ui-library/src/components/checkbox/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { styleCustom } from './index.css';
99
import { form } from '../../foundation/semantic-tokens/form.css';
1010
import { checkbox } from '../../foundation/component-tokens/checkbox.css';
1111
import { BlrFormHintRenderFunction } from '../internal-components/form-hint';
12-
import { calculateIconName } from '../../utils/calculate-icon-name';
1312
import { IconType } from '@boiler/icons';
1413

1514
@customElement('blr-checkbox')
@@ -87,7 +86,7 @@ export class BlrCheckbox extends LitElement {
8786
message: this.hintMessage,
8887
variant: 'hint',
8988
size: this.size,
90-
icon: this.hintIcon ? calculateIconName(this.hintIcon, this.size) : undefined,
89+
icon: this.hintIcon ? this.hintIcon : undefined,
9190
})}
9291
</div>
9392
`
@@ -99,7 +98,7 @@ export class BlrCheckbox extends LitElement {
9998
message: this.errorMessage,
10099
variant: 'error',
101100
size: this.size,
102-
icon: this.errorIcon ? calculateIconName(this.errorIcon, this.size) : undefined,
101+
icon: this.errorIcon ? this.errorIcon : undefined,
103102
})}
104103
</div>
105104
`

packages/ui-library/src/components/internal-components/form-hint/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,23 @@ export class BlrFormHint extends LitElement {
2424
[`${this.size}`]: this.size,
2525
});
2626

27+
const iconClasses = classMap({
28+
'blr-icon': true,
29+
[`${this.size}`]: this.size || 'md',
30+
});
31+
2732
return html`<div class=${classes}>
2833
<div class="icon-wrapper">
29-
${BlrIconRenderFunction({ icon: calculateIconName(this.icon, 'sm'), size: 'sm', hideAria: true })}
34+
${BlrIconRenderFunction({
35+
icon: calculateIconName(this.icon, 'sm'),
36+
size: 'sm',
37+
classMap: iconClasses,
38+
hideAria: true,
39+
})}
40+
</div>
41+
<div class="label-wrapper">
42+
<span class="blr-caption-text">${this.message}</span>
3043
</div>
31-
<span class="blr-caption-text">${this.message}</span>
3244
${this.childElement}
3345
</div>`;
3446
}

packages/ui-library/src/components/internal-components/icon/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const BlrIconRenderFunction = ({
4444
disablePointerEvents,
4545
}: BlrIconType) => {
4646
return html`<blr-icon
47-
class="blr-icon ${classMap}"
47+
class="${classMap}"
4848
.icon=${icon || nothing}
4949
.size=${size}
5050
.name=${name || nothing}

packages/ui-library/src/components/select/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class BlrSelect extends LitElement {
119119
message: (this.hasError ? this.errorMessage : this.hint) || 'This is dummy message',
120120
variant: this.hasError ? 'error' : 'hint',
121121
size: 'sm',
122-
icon: calculateIconName(this.hintIcon, this.size),
122+
icon: this.hintIcon,
123123
})}
124124
</div>
125125
`;

packages/ui-library/src/components/text-input/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class BlrTextInput extends LitElement {
130130
${BlrFormHintRenderFunction({
131131
message: this.hasError ? this.errorMessage : this.hintText,
132132
variant: this.hasError ? 'error' : 'hint',
133-
icon: calculateIconName(this.hintIcon, this.size),
133+
icon: this.hintIcon,
134134
size: 'sm',
135135
})}
136136
`

packages/ui-library/src/components/textarea/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { BlrFormLabelRenderFunction } from '../internal-components/form-label';
1010
import { BlrFormHintRenderFunction } from '../internal-components/form-hint';
1111
import { IconType } from '@boiler/icons';
1212
import { iconButton } from '../../foundation/component-tokens/action.css';
13-
import { calculateIconName } from '../../utils/calculate-icon-name';
1413

1514
@customElement('blr-textarea')
1615
export class BlrTextarea extends LitElement {
@@ -110,7 +109,7 @@ export class BlrTextarea extends LitElement {
110109
${BlrFormHintRenderFunction({
111110
message: this.hasError ? this.errorMessage : this.hintText,
112111
variant: this.hasError ? 'error' : 'hint',
113-
icon: calculateIconName(this.hintIcon, this.size),
112+
icon: this.hintIcon,
114113
size: this.size,
115114
childElement: html`<div class="blr-counter ${counterClasses}">
116115
${this.count}/${this.maxLength}

packages/ui-library/src/foundation/semantic-tokens/form.css.js

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,6 @@ export const form = css`
160160
.blr-input-icon {
161161
position: absolute;
162162
color: ${Forms.Placeholder.Default.Rest};
163-
&.sm {
164-
165-
}
166-
&.md {
167-
168-
}
169-
&.lg {
170-
171-
}
172163
}
173164
174165
.blr-input-icon.error {
@@ -191,19 +182,36 @@ export const form = css`
191182
display: flex;
192183
align-items: flex-start;
193184
word-break: break-all;
185+
.label-wrapper {
186+
padding: 0rem 0px;
187+
display: flex;
188+
.blr-caption-text {
189+
color: ${Forms.Caption.Hint};
190+
}
191+
}
192+
&.error {
193+
color: ${Forms.Caption.Error};
194+
.label-wrapper {
195+
.blr-caption-text {
196+
color: ${Forms.Caption.Error};
197+
}
198+
}
199+
}
194200
&.sm {
195201
padding: ${Forms.SM.CaptionComponent.Padding};
196202
gap: ${Forms.SM.CaptionComponent.ItemSpacing};
197203
.icon-wrapper {
198204
padding: ${Forms.SM.CaptionComponent.IconWrapper.Padding}
199205
}
200-
.blr-caption-text {
201-
font-family: ${Forms.SM.Caption.fontFamily}, sans-serif;
202-
font-weight: ${Forms.SM.Caption.fontWeight};
203-
font-size: ${Forms.SM.Caption.fontSize};
204-
font-family: ${Forms.SM.Caption.fontFamily}, sans-serif;
205-
line-height: ${Forms.SM.Caption.lineHeight};
206+
.label-wrapper {
206207
padding: ${Forms.SM.CaptionComponent.CaptionLabelWrapper.Padding};
208+
.blr-caption-text {
209+
font-family: ${Forms.SM.Caption.fontFamily}, sans-serif;
210+
font-weight: ${Forms.SM.Caption.fontWeight};
211+
font-size: ${Forms.SM.Caption.fontSize};
212+
font-family: ${Forms.SM.Caption.fontFamily}, sans-serif;
213+
line-height: ${Forms.SM.Caption.lineHeight};
214+
}
207215
}
208216
}
209217
&.md {
@@ -212,12 +220,14 @@ export const form = css`
212220
.icon-wrapper {
213221
padding: ${Forms.MD.CaptionComponent.IconWrapper.Padding}
214222
}
215-
.blr-caption-text {
216-
font-family: ${Forms.MD.Caption.fontFamily}, sans-serif;
217-
font-weight: ${Forms.MD.Caption.fontWeight};
218-
font-size: ${Forms.MD.Caption.fontSize};
219-
line-height: ${Forms.MD.Caption.lineHeight};
223+
.label-wrapper {
220224
padding: ${Forms.MD.CaptionComponent.CaptionLabelWrapper.Padding};
225+
.blr-caption-text {
226+
font-family: ${Forms.MD.Caption.fontFamily}, sans-serif;
227+
font-weight: ${Forms.MD.Caption.fontWeight};
228+
font-size: ${Forms.MD.Caption.fontSize};
229+
line-height: ${Forms.MD.Caption.lineHeight};
230+
}
221231
}
222232
}
223233
&.lg {
@@ -226,21 +236,16 @@ export const form = css`
226236
.icon-wrapper {
227237
padding: ${Forms.LG.CaptionComponent.IconWrapper.Padding}
228238
}
229-
.blr-caption-text {
230-
font-weight: ${Forms.LG.Caption.fontWeight};
231-
font-size: ${Forms.LG.Caption.fontSize};
232-
font-family: ${Forms.LG.Caption.fontFamily}, sans-serif;
233-
line-height: ${Forms.LG.Caption.lineHeight};
239+
.label-wrapper {
234240
padding: ${Forms.LG.CaptionComponent.CaptionLabelWrapper.Padding};
241+
.blr-caption-text {
242+
font-weight: ${Forms.LG.Caption.fontWeight};
243+
font-size: ${Forms.LG.Caption.fontSize};
244+
font-family: ${Forms.LG.Caption.fontFamily}, sans-serif;
245+
line-height: ${Forms.LG.Caption.lineHeight};
246+
}
235247
}
236248
}
237-
.blr-caption-text {
238-
padding-left: ${Forms.MD.LabelSlot.ItemSpacing};
239-
color: ${Forms.Caption.Hint};
240-
}
241-
&.error {
242-
color: ${Forms.Caption.Error};
243-
}
244249
}
245250
.blr-form-label {
246251
display: inline-block;

0 commit comments

Comments
 (0)