Skip to content

Commit

Permalink
perf(button): use new auro-button flat variant for clear and show pas…
Browse files Browse the repository at this point in the history
…sword
  • Loading branch information
jason-capsule42 committed Jul 3, 2024
1 parent 4032727 commit 2a671d2
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 30 deletions.
59 changes: 57 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"node": "^18 || ^20"
},
"dependencies": {
"@aurodesignsystem/auro-button": "^7.3.0-beta.2",
"@aurodesignsystem/auro-formvalidation": "^1.0.3",
"@aurodesignsystem/auro-icon": "^5.0.0-beta.1",
"@aurodesignsystem/auro-library": "^2.6.0",
Expand Down
1 change: 1 addition & 0 deletions scripts/version.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import versionWriter from '@aurodesignsystem/auro-library/scripts/build/versionWriter.js';

versionWriter.writeDepVersionFile('@aurodesignsystem/auro-icon');
versionWriter.writeDepVersionFile('@aurodesignsystem/auro-button');
55 changes: 30 additions & 25 deletions src/auro-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import BaseInput from './base-input.js';
import { AuroDependencyVersioning } from '@aurodesignsystem/auro-library/scripts/runtime/dependencyTagVersioning.mjs';
import { AuroIcon } from '@aurodesignsystem/auro-icon/src/auro-icon.js';
import iconVersion from './iconVersion';
import { AuroButton } from '@aurodesignsystem/auro-button/src/auro-button.js';
import buttonVersion from './buttonVersion';

// build the component class
export class AuroInput extends BaseInput {
Expand All @@ -26,6 +28,7 @@ export class AuroInput extends BaseInput {
*/
const versioning = new AuroDependencyVersioning();
this.iconTag = versioning.generateTag('auro-icon', iconVersion, AuroIcon);
this.buttonTag = versioning.generateTag('auro-button', buttonVersion, AuroButton);
}

/**
Expand Down Expand Up @@ -137,42 +140,44 @@ export class AuroInput extends BaseInput {
${this.hasValue ? html`
${this.type === 'password' ? html`
<div class="notification">
<button
<${this.buttonTag}
variant="flat"
aria-hidden="true"
tabindex="-1"
@click="${this.handleClickShowPassword}"
class="notificationBtn passwordBtn">
${this.showPassword ? html`
<${this.iconTag}
category="interface"
name="hide-password-stroke"
customSize>
</${this.iconTag}>
` : html`
<${this.iconTag}
category="interface"
name="view-password-stroke"
customSize>
</${this.iconTag}>
`}
</button>
<${this.iconTag}
?hidden=${!this.showPassword}
customColor
category="interface"
name="hide-password-stroke"
customSize>
</${this.iconTag}>
<${this.iconTag}
?hidden=${this.showPassword}
customColor
category="interface"
name="view-password-stroke"
customSize>
</${this.iconTag}>
</${this.buttonTag}>
</div>
` : undefined}
${!this.disabled ? html`
${!this.disabled && !this.readonly ? html`
<div class="notification">
<button
<${this.buttonTag}
variant="flat"
class="notificationBtn clearBtn"
aria-hidden="true"
tabindex="-1"
@click="${this.handleClickClear}">
${this.readonly ? undefined : html`
<${this.iconTag}
category="interface"
name="x-lg"
customSize>
</${this.iconTag}>
`}
</button>
<${this.iconTag}
customColor
category="interface"
name="x-lg"
customSize>
</${this.iconTag}>
</${this.buttonTag}>
</div>
` : undefined}
` : undefined}
Expand Down
1 change: 1 addition & 0 deletions src/buttonVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default '7.3.0-beta.1'
17 changes: 15 additions & 2 deletions src/styles/notificationIcons.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import './../../node_modules/@aurodesignsystem/design-tokens/dist/tokens/SCSSVariables.scss';

/* stylelint-disable max-nesting-depth, selector-max-class, selector-max-combinators, selector-max-compound-selectors */
/* stylelint-disable selector-max-attribute, max-nesting-depth, selector-max-class, selector-max-combinators, selector-max-compound-selectors */

.typeIcon {
display: flex;
Expand Down Expand Up @@ -32,7 +32,7 @@

.notification {
&:not(:first-of-type) {
margin-left: var(--ds-size-150, $ds-size-150);
margin-left: var(--ds-size-100, $ds-size-100);
}
}

Expand All @@ -52,10 +52,23 @@
}

.notificationBtn {
display: block;
padding: 0;
border: 0;
background: unset;
cursor: pointer;
height: var(--ds-size-200, $ds-size-200);
width: var(--ds-size-200, $ds-size-200);

[auro-icon] {
display: block;
height: var(--ds-size-200, $ds-size-200);
width: var(--ds-size-200, $ds-size-200);

&[hidden] {
display: none;
}
}
}

:host(:not([bordered])) {
Expand Down
2 changes: 1 addition & 1 deletion test/auro-input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('auro-input', () => {
<auro-input value="other value" label="First name"></auro-input>
`);

const clearButton = el.shadowRoot.querySelector('button');
const clearButton = el.shadowRoot.querySelector('.clearBtn');
clearButton.click();
expect(el.value).to.equal('');
});
Expand Down

0 comments on commit 2a671d2

Please sign in to comment.