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/867 ensure property naming text button #935

Merged
merged 6 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions packages/js-example-app/src/prod-assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ <h2>Vanilla JS Example Application</h2>
<blr-text-button
theme="Light"
variant="cta"
size="md"
sizeVariant="md"
label="Button"
hasIcon="true"
iconPosition="leading"
icon="blr360"
buttonId="button-id"
textButtonId="button-id"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to make this same change in src/assets/index.html. I'm not too sure why we have two directories: one for development and one for production. Other than that it looks good 👍🏻

></blr-text-button>
<button id="toggleLoadingState">Toggle Loading State</button>
<button id="toggleDisabledState">Toggle Disabled State</button>
Expand Down
22 changes: 9 additions & 13 deletions packages/ui-library/src/components/text-button/index.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const sharedStyles = html`
const defaultParams: BlrTextButtonType = {
theme: 'Light',
variant: 'primary',
size: 'md',
sizeVariant: 'md',
label: 'Label-text',
hasIcon: true,
icon: 'blr360',
Expand All @@ -51,8 +51,7 @@ export default {
category: 'Appearance',
},
},
size: {
name: 'sizeVariant',
sizeVariant: {
description: 'Select size of the component.',
options: ActionSizes,
control: { type: 'select' },
Expand Down Expand Up @@ -217,25 +216,22 @@ const argTypesToDisable = [
'theme',
'arialabel',
'variant',
'size',
'sizeVariant',
'label',
'hasIcon',
'iconPosition',
'icon',
'loading',
'disabled',
'buttonId',
'textButtonId',
'buttonDisplay',
'onClick',
'onBlur',
'onFocus',
];
const generateDisabledArgTypes = (argTypes: string[]) => {
const disabledArgTypes = {};
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
argTypes.forEach((argType: string) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
disabledArgTypes[argType] = {
table: {
disable: true,
Expand Down Expand Up @@ -313,31 +309,31 @@ export const SizeVariant = () => {
<div class="stories-textbutton">
${BlrTextButtonRenderFunction({
...defaultParams,
size: 'xs',
sizeVariant: 'xs',
label: 'Button XS',
hasIcon: false,
})}
${BlrTextButtonRenderFunction({
...defaultParams,
size: 'sm',
sizeVariant: 'sm',
label: 'Button SM',
hasIcon: false,
})}
${BlrTextButtonRenderFunction({
...defaultParams,
size: 'md',
sizeVariant: 'md',
label: 'Button MD',
hasIcon: false,
})}
${BlrTextButtonRenderFunction({
...defaultParams,
size: 'lg',
sizeVariant: 'lg',
label: 'Button LG',
hasIcon: false,
})}
${BlrTextButtonRenderFunction({
...defaultParams,
size: 'xl',
sizeVariant: 'xl',
label: 'Button XL',
hasIcon: false,
})}
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-library/src/components/text-button/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const sampleParams: BlrTextButtonType = {
iconPosition: 'leading',
loading: false,
disabled: false,
buttonId: 'button-id',
textButtonId: 'button-id',
variant: 'cta',
theme: 'Light',
buttonDisplay: 'inline-block',
Expand All @@ -39,7 +39,7 @@ describe('blr-text-button', () => {
});

it('has a size sm when "size" is set to "sm" ', async () => {
const element = await fixture(BlrTextButtonRenderFunction({ ...sampleParams, size: 'sm' }));
const element = await fixture(BlrTextButtonRenderFunction({ ...sampleParams, sizeVariant: 'sm' }));

const textButton = querySelectorDeep('.blr-text-button', element.getRootNode() as HTMLElement);
const className = textButton?.className;
Expand Down
16 changes: 8 additions & 8 deletions packages/ui-library/src/components/text-button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export class BlrTextButton extends LitElement {
@property() iconPosition?: IconPositionVariant = 'leading';
@property({ type: Boolean }) loading!: boolean;
@property({ type: Boolean }) disabled!: boolean;
@property() buttonId?: string;
@property() textButtonId?: string;
@property() variant: ActionVariantType = 'primary';
@property() size?: ActionSizesType = 'md';
@property() sizeVariant?: ActionSizesType = 'md';
@property() buttonDisplay?: ButtonDisplayType = 'inline-block';

@property() theme: ThemeType = 'Light';
Expand Down Expand Up @@ -78,14 +78,14 @@ export class BlrTextButton extends LitElement {
};

protected render() {
if (this.size && this.buttonDisplay) {
if (this.sizeVariant && this.buttonDisplay) {
const dynamicStyles = this.theme === 'Light' ? [actionLight] : [actionDark];

const classes = classMap({
'blr-semantic-action': true,
'blr-text-button': true,
[this.variant]: this.variant,
[`${this.size}`]: this.size,
[`${this.sizeVariant}`]: this.sizeVariant,
'disabled': this.disabled,
'loading': this.loading,
[this.buttonDisplay]: this.buttonDisplay,
Expand All @@ -99,23 +99,23 @@ export class BlrTextButton extends LitElement {

const flexContainerClasses = classMap({
'flex-container': true,
[`${this.size}`]: this.size,
[`${this.sizeVariant}`]: this.sizeVariant,
});

const loaderVariant = determineLoaderVariant(this.variant);

const loaderSizeVariant = getComponentConfigToken([
'SizeVariant',
'Actions',
this.size.toUpperCase(),
this.sizeVariant.toUpperCase(),
'Loader',
]).toLowerCase() as FormSizesType;

const iconSizeVariant = getComponentConfigToken([
'SizeVariant',
'Actions',
'TextButton',
this.size.toUpperCase(),
this.sizeVariant.toUpperCase(),
'Icon',
]).toLowerCase() as SizesType;

Expand Down Expand Up @@ -163,7 +163,7 @@ export class BlrTextButton extends LitElement {
this.handleClick(event);
}
}}
id=${this.buttonId || nothing}
id=${this.textButtonId || nothing}
>
${this.focused && !this.loading ? html`<span class="focus-layer"></span>` : nothing}
${this.loading
Expand Down
Loading