diff --git a/components/d2l-navigation-iterator/d2l-navigation-iterator-item.js b/components/d2l-navigation-iterator/d2l-navigation-iterator-item.js
deleted file mode 100644
index f513072f..00000000
--- a/components/d2l-navigation-iterator/d2l-navigation-iterator-item.js
+++ /dev/null
@@ -1,117 +0,0 @@
-import { css, html, LitElement } from 'lit';
-import { LocalizeNavigationElement } from '../localize-navigation-element.js';
-import '@brightspace-ui/core/components/colors/colors.js';
-import '@brightspace-ui/core/components/icons/icon.js';
-import '@brightspace-ui/core/components/tooltip/tooltip.js';
-import '../../d2l-navigation-button.js';
-
-class NavigationIteratorItem extends LocalizeNavigationElement(LitElement) {
-
- static get properties() {
- return {
- disabled: {
- type: Boolean,
- reflect: true
- },
- hideText: {
- type: Boolean,
- attribute: 'hide-text',
- reflect: true
- },
- text: {
- type: String
- },
- type: {
- type: String,
- reflect: true
- }
- };
- }
-
- static get styles() {
- return css`
- :host {
- display: flex;
- height: 100%;
- position: relative;
- }
- :host([disabled]) {
- color: var(--d2l-color-ferrite);
- cursor: auto;
- opacity: 0.5;
- text-decoration: none;
- }
- :host([disabled]) d2l-tooltip {
- display: none;
- }
- :host([type="previous"]) d2l-navigation-button {
- padding-left: 1.2rem;
- }
- :host([type="next"]) d2l-navigation-button {
- padding-right: 1.5rem;
- }
- :host([type="previous"]:dir(rtl)) d2l-navigation-button {
- padding-left: 0;
- padding-right: 1.2rem;
- }
- :host([type="next"]:dir(rtl)) d2l-navigation-button {
- padding-left: 1.5rem;
- padding-right: 0;
- }
- .d2l-navigation-iterator-item-items {
- align-items: center;
- display: flex;
- height: 100%;
- }
- :host([type="next"]) .d2l-navigation-iterator-item-items {
- flex-direction: row-reverse;
- }
- :host([type="previous"]) .d2l-navigation-iterator-item-text {
- padding-left: 0.6rem;
- }
- :host([type="next"]) .d2l-navigation-iterator-item-text {
- padding-right: 0.6rem;
- }
- :host([type="previous"]:dir(rtl)) .d2l-navigation-iterator-item-text {
- padding-left: 0;
- padding-right: 0.6rem;
- }
- :host([type="next"]:dir(rtl)) .d2l-navigation-iterator-item-text {
- padding-left: 0.6rem;
- padding-right: 0;
- }
- `;
- }
-
- constructor() {
- super();
- this.disabled = false;
- this.hideText = false;
- this.text = '';
- this.type = 'previous';
- }
-
- render() {
- const icon = (this.type === 'previous') ? 'tier3:chevron-left-circle' : 'tier3:chevron-right-circle';
- const text = this._computeText();
- return html`
-
-
-
- ${text}
-
-
- ${text}
- `;
- }
-
- _computeText() {
- if (this.text.length > 0) {
- return this.text;
- }
- return (this.type === 'previous') ? this.localize('previous') : this.localize('next');
- }
-
-}
-
-customElements.define('d2l-navigation-iterator-item', NavigationIteratorItem);
diff --git a/components/d2l-navigation-iterator/d2l-navigation-iterator.js b/components/d2l-navigation-iterator/d2l-navigation-iterator.js
index 8c7cda4c..43ee8948 100644
--- a/components/d2l-navigation-iterator/d2l-navigation-iterator.js
+++ b/components/d2l-navigation-iterator/d2l-navigation-iterator.js
@@ -1,67 +1,63 @@
-import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
-import '@brightspace-ui/typography/d2l-typography-shared-styles.js';
-import './d2l-navigation-iterator-item.js';
+import { css, html, LitElement } from 'lit';
+import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
+import { LocalizeNavigationElement } from '../localize-navigation-element.js';
+import '../../d2l-navigation-button-icon.js';
-/**
- * @customElement
- * @polymer
- */
-class D2LNavigationIterator extends PolymerElement {
- static get is() { return 'd2l-navigation-iterator'; }
+class NavigationIterator extends LocalizeNavigationElement(LitElement) {
static get properties() {
return {
- previousText: {
- type: String
- },
- nextText: {
- type: String
- },
- hideText: {
- type: Boolean,
- value: false
- },
- previousDisabled: {
- type: Boolean,
- value: false
- },
- nextDisabled: {
- type: Boolean,
- value: false
- }
+ hideText: { attribute: 'hide-text', type: Boolean },
+ previousDisabled: { attribute: 'previous-disabled', type: Boolean },
+ previousText: { attribute: 'previous-text', type: String },
+ nextDisabled: { attribute: 'next-disabled', type: Boolean },
+ nextText: { attribute: 'next-text', type: String },
};
}
- static get template() {
+ static get styles() {
+ return [bodyCompactStyles, css`
+ .wrapper {
+ align-items: center;
+ display: flex;
+ height: 3.3rem;
+ justify-content: space-between;
+ max-width: 20rem;
+ padding: 0 1.2rem;
+ }
+ `];
+ }
+
+ constructor() {
+ super();
+ this.hideText = false;
+ this.nextDisabled = false;
+ this.nextText = '';
+ this.previousDisabled = false;
+ this.previousText = '';
+ }
+
+ render() {
+ const previousText = this.previousText ? this.previousText : this.localize('previous');
+ const nextText = this.nextText ? this.nextText : this.localize('next');
return html`
-
-
-
-
+
+
+
+
+
`;
}
@@ -95,4 +91,4 @@ class D2LNavigationIterator extends PolymerElement {
}
-window.customElements.define('d2l-navigation-iterator', D2LNavigationIterator);
+window.customElements.define('d2l-navigation-iterator', NavigationIterator);
diff --git a/d2l-navigation-button-icon.js b/d2l-navigation-button-icon.js
index d8746fa8..1a5248c0 100644
--- a/d2l-navigation-button-icon.js
+++ b/d2l-navigation-button-icon.js
@@ -24,6 +24,11 @@ class NavigationButtonIcon extends FocusMixin(LitElement) {
* @type {string}
*/
icon: { type: String },
+ /**
+ * Position of the icon.
+ * @type {'start'|'end'}
+ */
+ iconPosition: { attribute: 'icon-position', type: String },
/**
* REQUIRED: Text for the button
* @type {string}
@@ -52,8 +57,10 @@ class NavigationButtonIcon extends FocusMixin(LitElement) {
border: none;
color: var(--d2l-color-ferrite);
cursor: pointer;
+ display: inline-flex;
font-family: inherit;
font-size: inherit;
+ gap: 6px;
height: 100%;
margin: 0;
min-height: 40px;
@@ -61,6 +68,7 @@ class NavigationButtonIcon extends FocusMixin(LitElement) {
overflow: visible;
padding: 0;
position: relative;
+ vertical-align: middle;
white-space: nowrap;
}
/* Firefox includes a hidden border which messes up button dimensions */
@@ -83,6 +91,7 @@ class NavigationButtonIcon extends FocusMixin(LitElement) {
constructor() {
super();
this.disabled = false;
+ this.iconPosition = 'start';
this.textHidden = false;
this._buttonId = getUniqueId();
}
@@ -94,11 +103,13 @@ class NavigationButtonIcon extends FocusMixin(LitElement) {
render() {
const { ariaLabel, id, text, tooltip } = this._getRenderSettings();
const highlightBorder = !this.disabled ? html`` : nothing;
+ const icon = html``;
return html`
${tooltip}
`;
diff --git a/demo/iterator.html b/demo/iterator.html
index d6c73138..4477dbae 100644
--- a/demo/iterator.html
+++ b/demo/iterator.html
@@ -21,14 +21,7 @@ Empty
Count (hide text)
- User 1 of 17
-
-
-
- Separator (hide text)
-
-
-
+ User 1 of 17
@@ -37,14 +30,9 @@ Custom Labels
- Next Disabled
-
-
-
-
- Previous Disabled
+ Disabled
-
+
-
-
-
-
-
-
diff --git a/test/iterator.visual-diff.js b/test/iterator.visual-diff.js
index 54815be7..0fe28d60 100644
--- a/test/iterator.visual-diff.js
+++ b/test/iterator.visual-diff.js
@@ -1,7 +1,5 @@
-/* eslint-disable no-invalid-this */
-/* global forceFocusVisible */
-import { oneEvent, VisualDiff } from '@brightspace-ui/visual-diff';
import puppeteer from 'puppeteer';
+import { VisualDiff } from '@brightspace-ui/visual-diff';
describe('d2l-navigation-iterator', () => {
const visualDiff = new VisualDiff('d2l-navigation-iterator', import.meta.url);
@@ -18,52 +16,8 @@ describe('d2l-navigation-iterator', () => {
await page.bringToFront();
});
- beforeEach(async() => {
- await visualDiff.resetFocus(page);
- });
-
after(async() => await browser.close());
- describe('item', () => {
-
- [
- { category: 'default', tests: ['normal', 'hover', 'focus'] },
- { category: 'previous', tests: ['normal'] },
- { category: 'next', tests: ['normal'] },
- { category: 'hide-text', tests: ['normal', 'hover', 'focus'] },
- { category: 'disabled', tests: ['normal', 'hover', 'focus'] },
- { category: 'custom-text', tests: ['normal'] }
- ].forEach((entry) => {
- describe(entry.category, () => {
- entry.tests.forEach((name) => {
- it(name, async function() {
- const selector = `#item-${entry.category}`;
- const hoverSelector = `#item-${entry.category} > *`;
-
- if (name === 'hover' || name === 'focus') {
- if (entry.category.indexOf('disabled') > -1) {
- if (name === 'hover') await page.hover(hoverSelector);
- else if (name === 'focus') await page.$eval(selector, (elem) => forceFocusVisible(elem));
- } else {
- setTimeout(() => {
- if (name === 'hover') page.hover(hoverSelector);
- else if (name === 'focus') page.$eval(selector, (elem) => forceFocusVisible(elem));
- });
- await oneEvent(page, selector, 'd2l-tooltip-show');
- }
- }
-
- const rect = await visualDiff.getRect(page, selector);
- // without captureBeyondViewport: false, screenshotAndCompare() triggers a resize event
- // which hides the tooltips
- await visualDiff.screenshotAndCompare(page, this.test.fullTitle(), { captureBeyondViewport: false, clip: rect });
- });
- });
- });
- });
-
- });
-
describe('iterator', () => {
[
diff --git a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-focus.png b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-focus.png
index d884493a..ee30460c 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-focus.png and b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-focus.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-hover.png b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-hover.png
index d884493a..ee30460c 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-hover.png and b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-hover.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-normal.png b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-normal.png
index d884493a..ee30460c 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-normal.png and b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-disabled-normal.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-flip-focus.png b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-flip-focus.png
new file mode 100644
index 00000000..328a9716
Binary files /dev/null and b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-flip-focus.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-flip-hover.png b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-flip-hover.png
new file mode 100644
index 00000000..328a9716
Binary files /dev/null and b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-flip-hover.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-flip-normal.png b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-flip-normal.png
new file mode 100644
index 00000000..7eaf3c0c
Binary files /dev/null and b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-flip-normal.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-focus.png b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-focus.png
index 27a4d6ee..338e7422 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-focus.png and b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-focus.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-hover.png b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-hover.png
index 27a4d6ee..338e7422 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-hover.png and b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-hover.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-normal.png b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-normal.png
index 35216633..bef18c7f 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-normal.png and b/test/screenshots/ci/golden/d2l-navigation-button/d2l-navigation-button-icon-text-normal.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-custom-text-normal.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-custom-text-normal.png
deleted file mode 100644
index ccb471ea..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-custom-text-normal.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-default-focus.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-default-focus.png
deleted file mode 100644
index 19d2b399..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-default-focus.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-default-hover.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-default-hover.png
deleted file mode 100644
index 19d2b399..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-default-hover.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-default-normal.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-default-normal.png
deleted file mode 100644
index 55055949..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-default-normal.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-disabled-focus.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-disabled-focus.png
deleted file mode 100644
index 45f98986..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-disabled-focus.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-disabled-hover.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-disabled-hover.png
deleted file mode 100644
index 8fb9da30..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-disabled-hover.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-disabled-normal.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-disabled-normal.png
deleted file mode 100644
index 45f98986..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-disabled-normal.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-hide-text-focus.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-hide-text-focus.png
deleted file mode 100644
index 53381479..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-hide-text-focus.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-hide-text-hover.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-hide-text-hover.png
deleted file mode 100644
index 53381479..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-hide-text-hover.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-hide-text-normal.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-hide-text-normal.png
deleted file mode 100644
index c0927a5e..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-hide-text-normal.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-next-normal.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-next-normal.png
deleted file mode 100644
index cc9cfa10..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-next-normal.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-previous-normal.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-previous-normal.png
deleted file mode 100644
index 55055949..00000000
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-item-previous-normal.png and /dev/null differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-custom-text.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-custom-text.png
index 071f6302..ae2f7334 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-custom-text.png and b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-custom-text.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-default.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-default.png
index 5f3e890b..752b8f17 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-default.png and b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-default.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-disabled.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-disabled.png
index 8563b18a..bac65d51 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-disabled.png and b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-disabled.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-hide-text.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-hide-text.png
index 336afb06..58838ee1 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-hide-text.png and b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-hide-text.png differ
diff --git a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-slot.png b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-slot.png
index 8dd56213..59f48342 100644
Binary files a/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-slot.png and b/test/screenshots/ci/golden/d2l-navigation-iterator/d2l-navigation-iterator-iterator-slot.png differ