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

add d2l-navigation-button-icon component #151

Merged
merged 5 commits into from
Jul 8, 2022
Merged

Conversation

dlockhart
Copy link
Contributor

A new component that mirrors the functionality of the recently added <d2l-navigation-link-icon>, except with button semantics. Loosely based on the more generic <d2l-navigation-button> that takes a <slot>. I'm hoping to switch all usages of <d2l-navigation-button> over to this and get rid of it.

When the text is hidden, I have it rendering a tooltip instead of using the title -- this matches what the iterators are doing and will allow me to just switch them over to use this. I've updated link to do this as well, which isn't a breaking change since the only usages of them don't hide the text (FYI @abcotter).

@dlockhart dlockhart requested a review from svanherk July 8, 2022 19:06
@dlockhart dlockhart requested a review from a team as a code owner July 8, 2022 19:06
@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2022

Visual diff tests failed - pull request #152 has been opened with the updated goldens.

@@ -253,11 +268,11 @@ Then run the tests:

```shell
# run visual-diff tests
npx mocha './test/**/*.visual-diff.mjs' -t 10000
npx mocha './test/**/*.visual-diff.js' -t 10000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed this last time around.

button[disabled] {
cursor: default;
opacity: 0.5;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These styles are ported over from the d2l-navigation-shared-styles.js Polymer style mixins, but then heavily modified since there's no <slot>, no IE11/Edge hacks and the "highlight border" styles are already in a shared export.

const text = !this.textHidden ? this.text : nothing;
const tooltip = this.textHidden ? html`<d2l-tooltip for="${this._buttonId}" for-type="label">${this.text}</d2l-tooltip>` : nothing;
return html`
<button id="${ifDefined(id)}" ?disabled="${this.disabled}" aria-label="${ifDefined(ariaLabel)}">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm setting aria-label AND associating the tooltip because of this defect.

import '../d2l-navigation-button-notification-icon.js';
import '../d2l-navigation-link.js';
import '../d2l-navigation-link-back.js';
import '../d2l-navigation-link-image.js';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I split the link tests out into link.test.js to match what the visual-diffs were doing.

<div class="visual-diff">
<d2l-navigation-button-icon id="icon-text-disabled" icon="tier3:classes" text="Classes" disabled></d2l-navigation-button-icon>
</div>
<div class="visual-diff" id="icon-text-hidden-container" style="display: inline-block; padding: 0 30px 60px 30px;">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Padding out the parent so that the tooltip can fit nicely inside the space it creates.

d2l-navigation-button-icon.js Outdated Show resolved Hide resolved
@dlockhart dlockhart merged commit 3f4bf5b into main Jul 8, 2022
@dlockhart dlockhart deleted the dlockhart/button-icon branch July 8, 2022 20:20
@ghost
Copy link

ghost commented Jul 8, 2022

🎉 This PR is included in version 5.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ghost ghost added the released label Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants