diff --git a/packages/devextreme/scss/widgets/base/_icons.scss b/packages/devextreme/scss/widgets/base/_icons.scss index 9d985bd2664b..8bd97392232e 100644 --- a/packages/devextreme/scss/widgets/base/_icons.scss +++ b/packages/devextreme/scss/widgets/base/_icons.scss @@ -170,14 +170,15 @@ } } -@mixin dx-icon-margin($size) { - margin-right: $size; - margin-left: 0; +@mixin dx-icon-margin($size, $position: start) { + @if $position == start { + margin-inline-end: $size; + margin-inline-start: 0; + } - @at-root #{selector-append(".dx-rtl", &)}, - .dx-rtl & { - margin-left: $size; - margin-right: 0; + @if $position == end { + margin-inline-start: $size; + margin-inline-end: 0; } } diff --git a/packages/devextreme/scss/widgets/base/_tabs.scss b/packages/devextreme/scss/widgets/base/_tabs.scss index 991c026282b0..1681ef50eb96 100644 --- a/packages/devextreme/scss/widgets/base/_tabs.scss +++ b/packages/devextreme/scss/widgets/base/_tabs.scss @@ -134,3 +134,15 @@ justify-content: flex-start; } } + +.dx-tabs-icon-position-end .dx-tab-text { + flex-direction: row-reverse; +} + +.dx-tabs-icon-position-top .dx-tab-text { + flex-direction: column; +} + +.dx-tabs-icon-position-bottom .dx-tab-text { + flex-direction: column-reverse; +} diff --git a/packages/devextreme/scss/widgets/generic/tabs/layout/tab/_base.scss b/packages/devextreme/scss/widgets/generic/tabs/layout/tab/_base.scss index 9a5dc0811a5b..3022f9f37124 100644 --- a/packages/devextreme/scss/widgets/generic/tabs/layout/tab/_base.scss +++ b/packages/devextreme/scss/widgets/generic/tabs/layout/tab/_base.scss @@ -109,10 +109,17 @@ color: $tabs-tab-icon-color; @include dx-icon-sizing($generic-base-icon-size); - @include dx-icon-margin($generic-tabs-icon-margin); } } +.dx-tabs-icon-position-start .dx-tab .dx-icon { + @include dx-icon-margin($generic-tabs-icon-margin, start); +} + +.dx-tabs-icon-position-end .dx-tab .dx-icon { + @include dx-icon-margin($generic-tabs-icon-margin, end); +} + .dx-tabs.dx-state-focused { .dx-tab { &.dx-focused-disabled-next-tab { diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/common.ts b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/common.ts index 4e605cac4b90..d84a8d76a652 100644 --- a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/common.ts +++ b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/common.ts @@ -1,6 +1,6 @@ import { createScreenshotsComparer } from 'devextreme-screenshot-comparer'; import { Selector, ClientFunction } from 'testcafe'; -import { testScreenshot } from '../../../helpers/themeUtils'; +import { testScreenshot, isMaterial } from '../../../helpers/themeUtils'; import url from '../../../helpers/getPageUrl'; import createWidget from '../../../helpers/createWidget'; import TabPanel from '../../../model/tabPanel'; @@ -419,3 +419,56 @@ test('TabPanel borders without scrolling', async (t) => { return createWidget('dxTabPanel', tabPanelOptions); }); }); + +[true, false].forEach((rtlEnabled) => { + ['start', 'top', 'end', 'bottom'].forEach((iconPosition) => { + test('TabPanel icon position', async (t) => { + const { takeScreenshot, compareResults } = createScreenshotsComparer(t); + + if (!isMaterial()) { + await testScreenshot(t, takeScreenshot, `TabPanel iconPosition=${iconPosition},rtl=${rtlEnabled}.png`, { element: '#container' }); + } + + await t + .expect(compareResults.isValid()) + .ok(compareResults.errorMessages()); + }).before(async () => { + const dataSource = [ + { + title: 'John Heart', + text: 'John Heart', + icon: 'plus', + }, { + title: 'Olivia Peyton', + text: 'Olivia Peyton', + disabled: true, + icon: 'plus', + }, { + title: 'Robert Reagan', + text: 'Robert Reagan', + icon: 'plus', + }, { + title: 'Greta Sims', + text: 'Greta Sims', + icon: 'plus', + }, { + title: 'Olivia Peyton', + text: 'Olivia Peyton', + icon: 'plus', + }, + ] as Item[]; + + const tabPanelOptions = { + dataSource, + height: 250, + width: 450, + iconPosition, + rtlEnabled, + // prevent firing dxinactive event for to avoid failing test + itemHoldTimeout: 5000, + }; + + return createWidget('dxTabPanel', tabPanelOptions); + }); + }); +}); diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=bottom,rtl=false (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=bottom,rtl=false (generic-light).png new file mode 100644 index 000000000000..118e7e57bad9 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=bottom,rtl=false (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=bottom,rtl=true (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=bottom,rtl=true (generic-light).png new file mode 100644 index 000000000000..ad30c0cef54f Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=bottom,rtl=true (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=end,rtl=false (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=end,rtl=false (generic-light).png new file mode 100644 index 000000000000..d87061ccb590 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=end,rtl=false (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=end,rtl=true (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=end,rtl=true (generic-light).png new file mode 100644 index 000000000000..0ec0adf730cb Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=end,rtl=true (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=start,rtl=false (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=start,rtl=false (generic-light).png new file mode 100644 index 000000000000..cc8e1369c0df Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=start,rtl=false (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=start,rtl=true (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=start,rtl=true (generic-light).png new file mode 100644 index 000000000000..fc8452cf91c3 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=start,rtl=true (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=top,rtl=false (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=top,rtl=false (generic-light).png new file mode 100644 index 000000000000..e44327f04c70 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=top,rtl=false (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=top,rtl=true (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=top,rtl=true (generic-light).png new file mode 100644 index 000000000000..1fb47218a9f3 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabPanel/etalons/TabPanel iconPosition=top,rtl=true (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/common.ts b/packages/devextreme/testing/testcafe/tests/navigation/tabs/common.ts index 0075fdfcbeca..ce79d2f65f6e 100644 --- a/packages/devextreme/testing/testcafe/tests/navigation/tabs/common.ts +++ b/packages/devextreme/testing/testcafe/tests/navigation/tabs/common.ts @@ -11,26 +11,32 @@ const TAB_CLASS = 'dx-tab'; fixture.disablePageReloads`Tabs_common` .page(url(__dirname, '../../container.html')); -test('Tabs icon alignment', async (t) => { - const { takeScreenshot, compareResults } = createScreenshotsComparer(t); - - await testScreenshot(t, takeScreenshot, 'Tabs items alignment.png', { element: '#tabs', shouldTestInCompact: true }); - - await t - .expect(compareResults.isValid()) - .ok(compareResults.errorMessages()); -}).before(async () => { - await appendElementTo('#container', 'div', 'tabs'); - await setAttribute('#container', 'style', 'width: 800px; height: 600px;'); - - const dataSource = [ - { text: 'user' }, - { text: 'comment', icon: 'comment' }, - { icon: 'user' }, - { icon: 'money' }, - ] as Item[]; - - return createWidget('dxTabs', { dataSource }, '#tabs'); +[true, false].forEach((rtlEnabled) => { + ['start', 'top', 'end', 'bottom'].forEach((iconPosition) => { + test('Tabs icon position', async (t) => { + const { takeScreenshot, compareResults } = createScreenshotsComparer(t); + + if (!isMaterial()) { + await testScreenshot(t, takeScreenshot, `Tabs iconPosition=${iconPosition},rtl=${rtlEnabled}.png`, { element: '#tabs', shouldTestInCompact: true }); + } + + await t + .expect(compareResults.isValid()) + .ok(compareResults.errorMessages()); + }).before(async () => { + await appendElementTo('#container', 'div', 'tabs'); + await setAttribute('#container', 'style', 'width: 800px; height: 600px;'); + + const dataSource = [ + { text: 'user' }, + { text: 'comment', icon: 'comment' }, + { icon: 'user' }, + { icon: 'money' }, + ] as Item[]; + + return createWidget('dxTabs', { dataSource, iconPosition, rtlEnabled }, '#tabs'); + }); + }); }); test('Tabs in contrast theme', async (t) => { diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=false (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=false (generic-light).png new file mode 100644 index 000000000000..8d1a3653d94c Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=false (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=false (generic-light-compact).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=false (generic-light-compact).png new file mode 100644 index 000000000000..66c2c6b53f65 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=false (generic-light-compact).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=true (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=true (generic-light).png new file mode 100644 index 000000000000..66480097c457 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=true (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=true (generic-light-compact).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=true (generic-light-compact).png new file mode 100644 index 000000000000..7ac7693e3b2f Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=bottom,rtl=true (generic-light-compact).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=false (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=false (generic-light).png new file mode 100644 index 000000000000..b0a12d6a36d6 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=false (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=false (generic-light-compact).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=false (generic-light-compact).png new file mode 100644 index 000000000000..8453420bea6c Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=false (generic-light-compact).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=true (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=true (generic-light).png new file mode 100644 index 000000000000..3d704041bf2b Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=true (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=true (generic-light-compact).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=true (generic-light-compact).png new file mode 100644 index 000000000000..5d3de12da256 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=end,rtl=true (generic-light-compact).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=false (generic-light).png similarity index 100% rename from packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (generic-light).png rename to packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=false (generic-light).png diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (generic-light-compact).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=false (generic-light-compact).png similarity index 100% rename from packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (generic-light-compact).png rename to packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=false (generic-light-compact).png diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=true (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=true (generic-light).png new file mode 100644 index 000000000000..27c9562dda21 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=true (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=true (generic-light-compact).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=true (generic-light-compact).png new file mode 100644 index 000000000000..896c18927ac7 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=start,rtl=true (generic-light-compact).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=false (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=false (generic-light).png new file mode 100644 index 000000000000..8c53a0cbdca2 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=false (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=false (generic-light-compact).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=false (generic-light-compact).png new file mode 100644 index 000000000000..a5973ab07ca0 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=false (generic-light-compact).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=true (generic-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=true (generic-light).png new file mode 100644 index 000000000000..9b44e20bfb86 Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=true (generic-light).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=true (generic-light-compact).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=true (generic-light-compact).png new file mode 100644 index 000000000000..5a5176ebe91d Binary files /dev/null and b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs iconPosition=top,rtl=true (generic-light-compact).png differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (material-blue-light).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (material-blue-light).png deleted file mode 100644 index 0966c042eb7c..000000000000 Binary files a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (material-blue-light).png and /dev/null differ diff --git a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (material-blue-light-compact).png b/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (material-blue-light-compact).png deleted file mode 100644 index 0972bdd48658..000000000000 Binary files a/packages/devextreme/testing/testcafe/tests/navigation/tabs/etalons/Tabs items alignment (material-blue-light-compact).png and /dev/null differ