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

feat: add ability to hide the highlight border #186

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Add the `d2l-navigation-main-footer` component, and provide elements for the `ma
| `disabled` | Boolean | Disables the button |
| `text` | String, required | Text for the button |
| `icon` | String | Preset icon key (e.g. `tier1:gear`) |
| `no-highlight-border` | Boolean | Visually hides the highlight border when hovered/focused |
| `text-hidden` | Boolean | Visually hides the text |

---
Expand Down
8 changes: 7 additions & 1 deletion d2l-navigation-button-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class NavigationButtonIcon extends FocusMixin(LitElement) {
* @type {'start'|'end'}
*/
iconPosition: { attribute: 'icon-position', type: String },
/**
* Visually hides the highlight border when hovered/focused
* @type {boolean}
*/
noHighlightBorder: { attribute: 'no-highlight-border', type: Boolean },
/**
* REQUIRED: Text for the button
* @type {string}
Expand Down Expand Up @@ -58,6 +63,7 @@ class NavigationButtonIcon extends FocusMixin(LitElement) {
super();
this.disabled = false;
this.iconPosition = 'start';
this.noHighlightBorder = false;
this.textHidden = false;
this._buttonId = getUniqueId();
}
Expand All @@ -68,7 +74,7 @@ class NavigationButtonIcon extends FocusMixin(LitElement) {

render() {
const { ariaLabel, id, text, tooltip } = this._getRenderSettings();
const highlightBorder = !this.disabled ? html`<span class="d2l-navigation-highlight-border"></span>` : nothing;
const highlightBorder = (!this.disabled && !this.noHighlightBorder) ? html`<span class="d2l-navigation-highlight-border"></span>` : nothing;
const icon = html`<d2l-icon icon="${this.icon}"></d2l-icon>`;
return html`
<button id="${ifDefined(id)}" ?disabled="${this.disabled}" aria-label="${ifDefined(ariaLabel)}" type="button">
Expand Down
3 changes: 3 additions & 0 deletions test/button.visual-diff.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<div class="visual-diff">
<d2l-navigation-button-icon id="icon-text-flip" icon="tier3:classes" icon-position="end" text="Classes"></d2l-navigation-button-icon>
</div>
<div class="visual-diff">
<d2l-navigation-button-icon id="icon-text-no-highlight-border" icon="tier3:classes" text="Classes" no-highlight-border></d2l-navigation-button-icon>
</div>
<div class="visual-diff" id="icon-text-hidden-container" style="display: inline-block; padding: 0 30px 60px 30px;">
<d2l-navigation-button-icon id="icon-text-hidden" icon="tier3:classes" text="Classes" text-hidden></d2l-navigation-button-icon>
</div>
Expand Down
1 change: 1 addition & 0 deletions test/button.visual-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('d2l-navigation-button', () => {
{ category: 'disabled', tests: ['normal', 'hover', 'focus'] },
{ category: 'icon-text', tests: ['normal', 'hover', 'focus'] },
{ category: 'icon-text-disabled', tests: ['normal', 'hover', 'focus'] },
{ category: 'icon-text-no-highlight-border', tests: ['normal', 'hover', 'focus'] },
{ category: 'icon-text-flip', tests: ['normal', 'hover', 'focus'] },
{ category: 'icon-text-hidden', tooltip: true, rectSelector: 'icon-text-hidden-container', tests: ['normal', 'hover', 'focus'] },
{ category: 'icon-text-hidden-disabled', tests: ['normal', 'hover', 'focus'] },
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.