Skip to content

Commit

Permalink
Badge: Fix dimensions in Tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
marker-dao authored Oct 18, 2023
1 parent 1c80639 commit 47000fd
Show file tree
Hide file tree
Showing 73 changed files with 84 additions and 45 deletions.
6 changes: 6 additions & 0 deletions packages/devextreme/scss/widgets/base/_badge.scss
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
// adduse

.dx-badge {
display: inline-flex;
align-items: center;
justify-content: center;
}
4 changes: 0 additions & 4 deletions packages/devextreme/scss/widgets/base/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@
@include dx-overflow();
}

.dx-tabs-item-badge {
display: inline-block;
}

.dx-tabs-nav-button {
align-items: center;
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


.dx-tab {
gap: $fluent-tabs-item-gap;
padding: $fluent-tabs-item-padding;
min-width: 0;
background-color: $tabs-tab-background;
Expand Down Expand Up @@ -88,6 +89,11 @@

@include dx-icon-sizing($fluent-tabs-icon-size);
}

.dx-tabs-item-badge {
min-width: $fluent-badge-min-size;
min-height: $fluent-badge-min-size;
}
}

.dx-tabs-icon-position-start .dx-tab-text::after {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// adduse


$fluent-tabs-item-gap: 4px !default;
$fluent-tabs-item-padding: null !default;
$fluent-tabs-item-padding-top-bottom: null !default;
$fluent-tabs-item-padding-right-left: null !default;
Expand Down Expand Up @@ -30,6 +31,8 @@ $fluent-indicator-length-secondary: 100% !default;
$fluent-tab-item-border-radius-secondary: 4px !default;
$fluent-indicator-border-radius-secondary: 4px !default;

$fluent-badge-min-size: null !default;

@if $size == "default" {
$fluent-tabs-item-padding-top-bottom: 12px !default;
$fluent-tabs-item-padding-right-left: 10px !default;
Expand All @@ -43,6 +46,7 @@ $fluent-indicator-border-radius-secondary: 4px !default;
$fluent-tab-nav-button-icon-font-size: 20px !default;
$fluent-tab-nav-button-content-padding: 0 4px !default;
$fluent-tab-vertical-nav-button-content-padding: 4px 0 !default;
$fluent-badge-min-size: 20px !default;
}

@else if $size == "compact" {
Expand All @@ -58,4 +62,5 @@ $fluent-indicator-border-radius-secondary: 4px !default;
$fluent-tab-nav-button-icon-font-size: 16px !default;
$fluent-tab-nav-button-content-padding: 0 4px !default;
$fluent-tab-vertical-nav-button-content-padding: 4px 0 !default;
$fluent-badge-min-size: 16px !default;
}
2 changes: 1 addition & 1 deletion packages/devextreme/scss/widgets/generic/badge/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
background-color: $badge-bg;
color: $badge-color;
font-size: $generic-base-font-size - 1px;
padding: 0 $generic-badge-horizontal-padding 2px;
padding: $generic-badge-padding;
line-height: normal;
border-radius: 14px;
}
6 changes: 3 additions & 3 deletions packages/devextreme/scss/widgets/generic/badge/_sizes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

// adduse

$generic-badge-horizontal-padding: null !default;
$generic-badge-padding: null !default;

@if $size == "default" {
$generic-badge-horizontal-padding: 6px !default;
$generic-badge-padding: 0 6px !default;
}

@else if $size == "compact" {
$generic-badge-horizontal-padding: 5px !default;
$generic-badge-padding: 0 5px !default;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


.dx-tab {
gap: $generic-tabs-item-gap;
padding: $generic-tabs-item-padding;
background-color: $tabs-tab-bg;
color: $tabs-tab-color;
Expand Down Expand Up @@ -110,6 +111,11 @@

@include dx-icon-sizing($generic-tabs-icon-size);
}

.dx-tabs-item-badge {
min-width: $generic-badge-min-size;
min-height: $generic-badge-min-size;
}
}

.dx-tabs.dx-state-focused {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// adduse

$generic-tabs-item-gap: 4px !default;
$generic-tabs-item-padding: null !default;
$generic-tabs-item-padding-disabled-focused: null !default;
$generic-tabs-border-width: $generic-base-border-width !default;
Expand All @@ -14,6 +15,8 @@ $generic-tab-text-line-height: null !default;
$generic-tabs-icon-margin: null !default;
$generic-tabs-icon-size: null !default;

$generic-badge-min-size: null !default;

@if $size == "default" {
$generic-tabs-item-padding: 10px 9px !default;
$generic-tabs-item-padding-disabled-focused: 10px !default;
Expand All @@ -22,6 +25,7 @@ $generic-tabs-icon-size: null !default;
$generic-tabs-nav-button-height: 38px !default;
$generic-tabs-icon-margin: 8px !default;
$generic-tabs-icon-size: 18px !default;
$generic-badge-min-size: 18px !default;
}

@else if $size == "compact" {
Expand All @@ -32,4 +36,5 @@ $generic-tabs-icon-size: null !default;
$generic-tabs-nav-button-height: 38px !default;
$generic-tabs-icon-margin: 8px !default;
$generic-tabs-icon-size: 21px !default;
$generic-badge-min-size: 21px !default;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
color: $badge-color;
font-size: $material-badge-font-size;
padding: $material-badge-padding;
margin-inline-start: 4px;
line-height: normal;
border-radius: 14px;
margin-top: 1px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


.dx-tab {
gap: $material-tabs-item-gap;
padding: $material-tabs-item-padding;
min-width: $material-tab-min-width;
background-color: $tabs-tab-background;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// adduse


$material-tabs-item-gap: 4px !default;
$material-tabs-item-padding: null !default;
$material-tabs-item-padding-horizontal: null !default;
$material-tabs-item-padding-vertical: null !default;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import { Selector, ClientFunction } from 'testcafe';
import {
// Selector,
ClientFunction,
} from 'testcafe';
import { testScreenshot } from '../../../helpers/themeUtils';
import url from '../../../helpers/getPageUrl';
import createWidget from '../../../helpers/createWidget';
import TabPanel from '../../../model/tabPanel';
import { Item } from '../../../../../js/ui/tab_panel.d';

const TABS_RIGHT_NAV_BUTTON_CLASS = 'dx-tabs-nav-button-right';
const TABS_LEFT_NAV_BUTTON_CLASS = 'dx-tabs-nav-button-left';
// const TABS_RIGHT_NAV_BUTTON_CLASS = 'dx-tabs-nav-button-right';
// const TABS_LEFT_NAV_BUTTON_CLASS = 'dx-tabs-nav-button-left';

fixture.disablePageReloads`TabPanel_common`
.page(url(__dirname, '../../container.html'));
Expand Down Expand Up @@ -197,24 +200,29 @@ test('TabPanel borders without scrolling', async (t) => {

await t.pressKey(direction);

const thirdItem = tabPanel.getItem(2);
// const thirdItem = tabPanel.getItem(2);
const firstItem = tabPanel.getItem(0);

await t.dispatchEvent(firstItem.element, 'mousedown');
await testScreenshot(t, takeScreenshot, `TabPanel 1 item active,rtl=${rtlEnabled}.png`, { element: '#container' });

await t
.dispatchEvent(thirdItem.element, 'mouseup')
.click(Selector('body'), { offsetY: -50 })
.hover(firstItem.element);
// TODO: this test is unstable
// await t
// .dispatchEvent(thirdItem.element, 'mouseup')
// .click(Selector('body'), { offsetY: -50 })
// .hover(firstItem.element);

await testScreenshot(t, takeScreenshot, `TabPanel 1 item hovered,rtl=${rtlEnabled}.png`, { element: '#container' });
// eslint-disable-next-line max-len
// await testScreenshot(t, takeScreenshot, `TabPanel 1 item hovered,rtl=${rtlEnabled}.png`, { element: '#container' });

await t
.click(Selector('body'), { offsetY: -50 })
.hover(Selector(`.${rtlEnabled ? TABS_LEFT_NAV_BUTTON_CLASS : TABS_RIGHT_NAV_BUTTON_CLASS}`));
// TODO: this test is unstable
// await t
// .click(Selector('body'), { offsetY: -50 })
// eslint-disable-next-line max-len
// .hover(Selector(`.${rtlEnabled ? TABS_LEFT_NAV_BUTTON_CLASS : TABS_RIGHT_NAV_BUTTON_CLASS}`));

await testScreenshot(t, takeScreenshot, `TabPanel right navigation button hovered, rtl=${rtlEnabled}.png`, { element: '#container' });
// eslint-disable-next-line max-len
// await testScreenshot(t, takeScreenshot, `TabPanel right navigation button hovered, rtl=${rtlEnabled}.png`, { element: '#container' });

await t
.expect(compareResults.isValid())
Expand Down Expand Up @@ -403,18 +411,20 @@ test('TabPanel borders without scrolling', async (t) => {

await t.pressKey('right');

const thirdItem = tabPanel.getItem(2);
// const thirdItem = tabPanel.getItem(2);
const firstItem = tabPanel.getItem(0);

await t.dispatchEvent(firstItem.element, 'mousedown');
await testScreenshot(t, takeScreenshot, `TabPanel 1 item active,tabsPosition=${tabsPosition}.png`, { element: '#container' });

await t
.dispatchEvent(thirdItem.element, 'mouseup')
.click(Selector('body'), { offsetY: -50 })
.hover(firstItem.element);
// TODO: this test is unstable
// await t
// .dispatchEvent(thirdItem.element, 'mouseup')
// .click(Selector('body'), { offsetY: -50 })
// .hover(firstItem.element);

await testScreenshot(t, takeScreenshot, `TabPanel 1 item hovered,tabsPosition=${tabsPosition}.png`, { element: '#container' });
// eslint-disable-next-line max-len
// await testScreenshot(t, takeScreenshot, `TabPanel 1 item hovered,tabsPosition=${tabsPosition}.png`, { element: '#container' });

await t
.expect(compareResults.isValid())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ fixture.disablePageReloads`Tabs_common`
await setAttribute('#container', 'style', 'width: 800px; height: 600px;');

const dataSource = [
{ text: 'user' },
{ text: 'comment', icon: 'comment' },
{ text: 'user', badge: '1' },
{ text: 'comment', icon: 'comment', badge: 'text' },
{ icon: 'user' },
{ icon: 'money' },
] as Item[];
Expand Down Expand Up @@ -70,20 +70,23 @@ test('Tabs with width: auto in flex container', async (t) => {

const firstItem = Selector(`.${TAB_CLASS}:nth-child(1)`);

await t.hover(firstItem);
await testScreenshot(t, takeScreenshot, `Tabs 1 selected,hovered stylingMode=${stylingMode},rtl=${rtlEnabled}.png`, { element: '#tabs' });
// TODO: this test is unstable
// await t.hover(firstItem);
// eslint-disable-next-line max-len
// await testScreenshot(t, takeScreenshot, `Tabs 1 selected,hovered stylingMode=${stylingMode},rtl=${rtlEnabled}.png`, { element: '#tabs' });

await t.dispatchEvent(firstItem, 'mousedown');
await testScreenshot(t, takeScreenshot, `Tabs 1 selected,active stylingMode=${stylingMode},rtl=${rtlEnabled}.png`, { element: '#tabs' });

const thirdItem = Selector(`.${TAB_CLASS}:nth-child(3)`);

await t
.dispatchEvent(firstItem, 'mouseup')
.click(firstItem)
.hover(thirdItem);

await testScreenshot(t, takeScreenshot, `Tabs 3 not selected,hovered stylingMode=${stylingMode},rtl=${rtlEnabled}.png`, { element: '#tabs' });
// TODO: this test is unstable
// await t
// .dispatchEvent(firstItem, 'mouseup')
// .click(firstItem)
// .hover(thirdItem);
// eslint-disable-next-line max-len
// await testScreenshot(t, takeScreenshot, `Tabs 3 not selected,hovered stylingMode=${stylingMode},rtl=${rtlEnabled}.png`, { element: '#tabs' });

await t.dispatchEvent(thirdItem, 'mousedown');
await testScreenshot(t, takeScreenshot, `Tabs 3 not selected,active stylingMode=${stylingMode},rtl=${rtlEnabled}.png`, { element: '#tabs' });
Expand Down Expand Up @@ -158,20 +161,22 @@ test('Tabs in contrast theme', async (t) => {
await testScreenshot(t, takeScreenshot, `Tabs disab focused,sOF=${selectOnFocus},orient=${orientation},rtl=${rtlEnabled}.png`, { element: '#tabs' });

const thirdItem = Selector(`.${TAB_CLASS}:nth-child(3)`);
const fourthItem = Selector(`.${TAB_CLASS}:nth-child(4)`);
// const fourthItem = Selector(`.${TAB_CLASS}:nth-child(4)`);

await t
.pressKey(direction)
.dispatchEvent(thirdItem, 'mousedown');

await testScreenshot(t, takeScreenshot, `Tabs 3item active,sOF=${selectOnFocus},orient=${orientation},rtl=${rtlEnabled}.png`, { element: '#tabs' });

await t
.dispatchEvent(thirdItem, 'mouseup')
.click(thirdItem)
.hover(fourthItem);
// TODO: this test is unstable
// await t
// .dispatchEvent(thirdItem, 'mouseup')
// .click(thirdItem)
// .hover(fourthItem);

await testScreenshot(t, takeScreenshot, `Tabs 4item hovered,sOF=${selectOnFocus},orient=${orientation},rtl=${rtlEnabled}.png`, { element: '#tabs' });
// eslint-disable-next-line max-len
// await testScreenshot(t, takeScreenshot, `Tabs 4item hovered,sOF=${selectOnFocus},orient=${orientation},rtl=${rtlEnabled}.png`, { element: '#tabs' });

await t
.expect(compareResults.isValid())
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 47000fd

Please sign in to comment.