Skip to content

Commit edb9178

Browse files
fix(ui-library): added icon keys, type and visibility test (#280)
1 parent 76db039 commit edb9178

File tree

5 files changed

+178
-7
lines changed

5 files changed

+178
-7
lines changed

packages/icons/icons-optimized/icons.ts

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8211,6 +8211,121 @@ const blrWiFiXxs = (className: string) =>
82118211
/>
82128212
</svg>`;
82138213

8214+
const PureIconKeys = [
8215+
'blr360',
8216+
'blrArrowDown',
8217+
'blrArrowLeft',
8218+
'blrArrowRight',
8219+
'blrArrowUp',
8220+
'blrBag',
8221+
'blrBook',
8222+
'blrBookmark',
8223+
'blrBriefcase',
8224+
'blrCalendar',
8225+
'blrCalendarToday',
8226+
'blrCamera',
8227+
'blrCart',
8228+
'blrChat',
8229+
'blrCheckmark',
8230+
'blrChevronDown',
8231+
'blrChevronLeft',
8232+
'blrChevronRight',
8233+
'blrChevronUp',
8234+
'blrClock0000',
8235+
'blrClock0030',
8236+
'blrClock0100',
8237+
'blrClock0130',
8238+
'blrClock0300',
8239+
'blrClock0330',
8240+
'blrClock0430',
8241+
'blrClock0500',
8242+
'blrClock0700',
8243+
'blrClock0730',
8244+
'blrClock0900',
8245+
'blrClock0930',
8246+
'blrClock1100',
8247+
'blrClock1130',
8248+
'blrClose',
8249+
'blrCloud',
8250+
'blrCloudUpload',
8251+
'blrCompass',
8252+
'blrCopy',
8253+
'blrCrop',
8254+
'blrDislike',
8255+
'blrDocumentNew',
8256+
'blrDocumentTwo',
8257+
'blrDownload',
8258+
'blrDrag',
8259+
'blrEnvelopeClosed',
8260+
'blrEnvelopeOpen',
8261+
'blrEqual',
8262+
'blrErrorFilled',
8263+
'blrError',
8264+
'blrEye',
8265+
'blrEyeOff',
8266+
'blrEyeOn',
8267+
'blrFlag',
8268+
'blrFolder',
8269+
'blrFolderOpen',
8270+
'blrFolderOpenSide',
8271+
'blrForward',
8272+
'blrGlobe',
8273+
'blrHeart',
8274+
'blrHome',
8275+
'blrImage',
8276+
'blrInboxMessageMail',
8277+
'blrInfo',
8278+
'blrLike',
8279+
'blrLinkBroken',
8280+
'blrLink',
8281+
'blrLockClosed',
8282+
'blrLockOpen',
8283+
'blrMenu',
8284+
'blrMicrophone',
8285+
'blrMinus',
8286+
'blrMoreHorizontal',
8287+
'blrMore',
8288+
'blrMoreVertical',
8289+
'blrMusic',
8290+
'blrNotificationBellOff',
8291+
'blrNotificationBellOn',
8292+
'blrPause',
8293+
'blrPen',
8294+
'blrPhoneIncomingCall',
8295+
'blrPhone',
8296+
'blrPhoneOutgoingCall',
8297+
'blrPin',
8298+
'blrPlane',
8299+
'blrPlay',
8300+
'blrPlus',
8301+
'blrPrinter',
8302+
'blrProfile',
8303+
'blrRefresh2',
8304+
'blrRefresh',
8305+
'blrResizeIn',
8306+
'blrResizeOut',
8307+
'blrScissors',
8308+
'blrSearch',
8309+
'blrSelectionBoxOff',
8310+
'blrSelectionBoxOn',
8311+
'blrSelectionOff',
8312+
'blrSelectionOn',
8313+
'blrSend',
8314+
'blrSettingsCog',
8315+
'blrShare',
8316+
'blrShoppingBasket',
8317+
'blroothie',
8318+
'blrSoundMax',
8319+
'blrSoundMin',
8320+
'blrStar',
8321+
'blrTag',
8322+
'blrTrash',
8323+
'blrUpload',
8324+
'blrVideoCamera',
8325+
'blrVideo',
8326+
'blrWiFi',
8327+
];
8328+
82148329
export const IconMapping = {
82158330
blr360Lg,
82168331
blr360Md,
@@ -8877,5 +8992,9 @@ export const IconMapping = {
88778992
blrWiFiXs,
88788993
blrWiFiXxs,
88798994
};
8995+
88808996
export type IconType = keyof typeof IconMapping;
88818997
export const IconKeys = Object.keys(IconMapping);
8998+
8999+
export type SizelessIconType = (typeof PureIconKeys)[number];
9000+
export const SizelessIconKeys = PureIconKeys;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ import { customElement, property } from 'lit/decorators.js';
33
import { classMap } from 'lit/directives/class-map.js';
44
import { FormSizesType, HintVariantType } from '../../../globals/types';
55
import { BlrIconRenderFunction } from '../icon';
6-
import { IconType } from '@boiler/icons';
6+
import { SizelessIconType } from '@boiler/icons';
77
import { form } from '../../../foundation/semantic-tokens/form.css';
88
import { calculateIconName } from '../../../utils/calculate-icon-name';
9+
import { counter } from '../../../foundation/component-tokens/feedback.css';
910

1011
@customElement('blr-form-hint')
1112
export class BlrFormHint extends LitElement {
12-
static styles = [form];
13+
static styles = [counter, form];
1314

1415
@property() message?: string;
15-
@property() icon?: IconType;
16+
@property() icon?: SizelessIconType;
1617
@property() variant: HintVariantType = 'hint';
1718
@property() size: FormSizesType = 'md';
1819
@property() childElement?: TemplateResult<1>;

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,31 @@ describe('blr-textarea', () => {
7575
// in html disabled will become null when its false
7676
expect(disabled).to.be.equal(null);
7777
});
78+
79+
it('is having a a visible hint icon', async () => {
80+
const element = await fixture(
81+
BlrTextareaRenderFunction({
82+
...sampleParams,
83+
showHint: true,
84+
hintIcon: 'blrInfo',
85+
})
86+
);
87+
88+
const textarea = querySelectorDeep('textarea', element.getRootNode() as HTMLElement);
89+
const formHint = querySelectorDeep('blr-form-hint', textarea?.getRootNode() as HTMLElement);
90+
const hintIcon = querySelectorDeep('blr-icon', formHint?.getRootNode() as HTMLElement);
91+
const svg = querySelectorDeep('svg', hintIcon?.getRootNode() as HTMLElement);
92+
93+
const rect = svg?.getBoundingClientRect();
94+
95+
expect(rect).have.property('width');
96+
expect(rect).have.property('height');
97+
// expect(rect).have.property('x');
98+
// expect(rect).have.property('y');
99+
100+
expect(rect?.width).to.be.greaterThan(0);
101+
expect(rect?.height).to.be.greaterThan(0);
102+
// expect((rect?.x || 0) + (rect?.width || 0)).not.to.be.lessThan(0);
103+
// expect((rect?.y || 0) + (rect?.height || 0)).not.to.be.lessThan(0);
104+
});
78105
});

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { counter } from '../../foundation/component-tokens/feedback.css';
88
import { FormSizesType } from '../../globals/types';
99
import { BlrFormLabelRenderFunction } from '../internal-components/form-label';
1010
import { BlrFormHintRenderFunction } from '../internal-components/form-hint';
11-
import { IconType } from '@boiler/icons';
11+
import { SizelessIconType } from '@boiler/icons';
1212
import { iconButton } from '../../foundation/component-tokens/action.css';
1313

1414
@customElement('blr-textarea')
@@ -33,7 +33,7 @@ export class BlrTextarea extends LitElement {
3333
@property() errorMessage?: string;
3434
@property() showHint = true;
3535
@property() hintText?: string;
36-
@property() hintIcon: IconType = 'blrInfoSm';
36+
@property() hintIcon: SizelessIconType = 'blrInfo';
3737
@property() isResizeable?: boolean;
3838
@property() rows?: number;
3939
@property() cols?: number;
@@ -117,10 +117,9 @@ export class BlrTextarea extends LitElement {
117117
})}
118118
`
119119
: html`<div class="blr-form-hint">
120-
<div class="brl-counter ${counterClasses}">${this.count}/${this.maxLength}</div>
120+
<div class="blr-counter ${counterClasses}">${this.count}/${this.maxLength}</div>
121121
</div>`
122122
}
123-
124123
</div>
125124
</div>
126125
`;

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,31 @@ export const form = css`
178178
padding-bottom: ${Forms.LG.LabelSlot.Padding};
179179
}
180180
}
181+
.blr-counter {
182+
&.sm {
183+
font-family: ${Forms.SM.Caption.fontFamily}, sans-serif;
184+
font-weight: ${Forms.SM.Caption.fontWeight};
185+
font-size: ${Forms.SM.Caption.fontSize};
186+
font-family: ${Forms.SM.Caption.fontFamily}, sans-serif;
187+
line-height: ${Forms.SM.Caption.lineHeight};
188+
}
189+
190+
&.md {
191+
font-family: ${Forms.MD.Caption.fontFamily}, sans-serif;
192+
font-weight: ${Forms.MD.Caption.fontWeight};
193+
font-size: ${Forms.MD.Caption.fontSize};
194+
font-family: ${Forms.MD.Caption.fontFamily}, sans-serif;
195+
line-height: ${Forms.MD.Caption.lineHeight};
196+
}
197+
198+
&.md {
199+
font-family: ${Forms.LG.Caption.fontFamily}, sans-serif;
200+
font-weight: ${Forms.LG.Caption.fontWeight};
201+
font-size: ${Forms.LG.Caption.fontSize};
202+
font-family: ${Forms.LG.Caption.fontFamily}, sans-serif;
203+
line-height: ${Forms.LG.Caption.lineHeight};
204+
}
205+
}
181206
.blr-form-hint, .blr-counter {
182207
display: flex;
183208
align-items: flex-start;

0 commit comments

Comments
 (0)