Skip to content

Commit

Permalink
ci: reduce motion on e2e by default
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Nov 30, 2023
1 parent 1dcbee6 commit 710fe20
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 47 deletions.
1 change: 1 addition & 0 deletions projects/addon-doc/tokens/scroll-behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {TUI_REDUCED_MOTION} from '@taiga-ui/core';

/**
* Defines the transition animation for scroll
* @deprecated will be remove in v4.0
*/
export const TUI_DOC_SCROLL_BEHAVIOR = tuiCreateTokenFromFactory<ScrollBehavior>(() =>
inject(TUI_REDUCED_MOTION) ? `auto` : `smooth`,
Expand Down
8 changes: 7 additions & 1 deletion projects/core/components/root/root.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import {
TUI_VERSION,
} from '@taiga-ui/cdk';
import {TuiBreakpointService} from '@taiga-ui/core/services';
import {TUI_ANIMATIONS_DURATION, TUI_THEME} from '@taiga-ui/core/tokens';
import {
TUI_ANIMATIONS_DURATION,
TUI_REDUCED_MOTION,
TUI_THEME,
} from '@taiga-ui/core/tokens';
import {combineLatest, Observable, of} from 'rxjs';
import {debounceTime, map} from 'rxjs/operators';

Expand All @@ -30,6 +34,7 @@ import {debounceTime, map} from 'rxjs/operators';
'[style.--tui-duration.ms]': 'duration',
'[class._ios]': 'isIOS',
'[class._android]': 'isAndroid',
'[class._reduced-motion]': 'reducedMotion',
'[$.class._mobile]': 'isMobileRes$',
'($.class._mobile)': 'isMobileRes$',
},
Expand All @@ -48,6 +53,7 @@ export class TuiRootComponent {
: of(!this.isMobile);

constructor(
@Inject(TUI_REDUCED_MOTION) readonly reducedMotion: boolean,
@Inject(TUI_ANIMATIONS_DURATION) readonly duration: number,
@Inject(TUI_DIALOGS)
readonly dialogs: ReadonlyArray<Observable<readonly unknown[]>>,
Expand Down
6 changes: 1 addition & 5 deletions projects/core/styles/mixins/mixins.less
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,10 @@
padding: 0;
}

/**
* @description:
* disable smooth scrolling when users have prefers-reduced-motion enabled
*/
.scroll-behavior(@mode: smooth) {
scroll-behavior: @mode;

@media screen and (prefers-reduced-motion: reduce) {
:host-context(tui-root._reduced-motion) & {
scroll-behavior: auto;
}
}
1 change: 1 addition & 0 deletions projects/demo-cypress/cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default async (
`--window-size=${TUI_CYPRESS_DESKTOP_VIEWPORT_WIDTH},${TUI_CYPRESS_DESKTOP_VIEWPORT_HEIGHT}`,
`--force-device-scale-factor=2`,
`--high-dpi-support=1`,
`--force-prefers-reduced-motion`,
`--force-color-profile=srgb`,
`--disable-dev-shm-usage`,
`--disable-gpu`,
Expand Down
11 changes: 0 additions & 11 deletions projects/demo-cypress/cypress/support/helpers/visit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ interface TuiVisitOptions {
rootSelector?: string;
skipDecodingUrl?: boolean;
skipExpectUrl?: boolean;
stopAnimation?: boolean;
waitAllIcons?: boolean;
waitRenderedFont?: RegExp;
}
Expand All @@ -57,9 +56,7 @@ export function tuiVisit(path: string, options: TuiVisitOptions = {}): void {
enableNightMode = false,
hideCursor = true,
hideScrollbar = true,
noSmoothScroll = true,
hideHeader = true,
stopAnimation = true,
skipExpectUrl = false,
skipDecodingUrl = false,
hideNavigation = true,
Expand Down Expand Up @@ -150,10 +147,6 @@ export function tuiVisit(path: string, options: TuiVisitOptions = {}): void {

cy.get(`${rootSelector}._is-cypress-mode`).as(`app`);

if (stopAnimation) {
cy.get(`@app`).invoke(`addClass`, `_stop-animation`);
}

if (hideCursor) {
cy.get(`@app`).invoke(`addClass`, `_hide-cursor`);
}
Expand All @@ -162,10 +155,6 @@ export function tuiVisit(path: string, options: TuiVisitOptions = {}): void {
cy.get(`@app`).invoke(`addClass`, `_hide-scrollbar`);
}

if (noSmoothScroll) {
cy.get(`@app`).invoke(`addClass`, `_no-smooth-scroll`);
}

cy.get(rootSelector).should(`have.class`, `_loaded`);

if (hideHeader) {
Expand Down
3 changes: 3 additions & 0 deletions projects/demo-playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default defineConfig({
baseURL: `http://localhost:${process.env.NG_SERVER_PORT || 3333}`,
trace: `on-first-retry`,
viewport: DEFAULT_VIEWPORT,
contextOptions: {
reducedMotion: `reduce`,
},
},
projects: [
{
Expand Down
20 changes: 0 additions & 20 deletions projects/demo/src/modules/app/app.providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from '@angular/common';
import {inject, PLATFORM_ID, Provider} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
import {UrlTree} from '@angular/router';
import {SESSION_STORAGE} from '@ng-web-apis/common';
import {
Expand All @@ -16,7 +15,6 @@ import {
TUI_DOC_EXAMPLE_CONTENT_PROCESSOR,
TUI_DOC_LOGO,
TUI_DOC_PAGES,
TUI_DOC_SCROLL_BEHAVIOR,
TUI_DOC_SEE_ALSO,
TUI_DOC_SOURCE_CODE,
TUI_DOC_TITLE,
Expand All @@ -35,12 +33,10 @@ import {
tuiAssert,
} from '@taiga-ui/cdk';
import {
TUI_ANIMATIONS_DURATION,
TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS,
TUI_DROPDOWN_HOVER_OPTIONS,
TUI_HINT_DEFAULT_OPTIONS,
TUI_HINT_OPTIONS,
TUI_REDUCED_MOTION,
TUI_SANITIZER,
} from '@taiga-ui/core';
import {TuiLanguageName, tuiLanguageSwitcher} from '@taiga-ui/i18n';
Expand Down Expand Up @@ -151,17 +147,6 @@ export const APP_PROVIDERS: Provider[] = [
provide: TUI_SWIPE_OPTIONS,
useValue: {timeout: 300, threshold: 60},
},
{
provide: ANIMATION_MODULE_TYPE,
useFactory: () =>
inject(TUI_IS_E2E) || inject(TUI_REDUCED_MOTION)
? `NoopAnimations`
: `BrowserAnimations`,
},
{
provide: TUI_ANIMATIONS_DURATION,
useFactory: () => (inject(TUI_IS_E2E) || inject(TUI_REDUCED_MOTION) ? 0 : 300),
},
{
provide: TUI_HINT_OPTIONS,
useFactory: () =>
Expand All @@ -176,11 +161,6 @@ export const APP_PROVIDERS: Provider[] = [
? {...TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS, showDelay: 0, hideDelay: 0}
: TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS,
},
{
provide: TUI_DOC_SCROLL_BEHAVIOR,
useFactory: () =>
inject(TUI_IS_E2E) || inject(TUI_REDUCED_MOTION) ? `auto` : `smooth`, // https://github.com/cypress-io/cypress/issues/4640
},
{
provide: TUI_TAKE_ONLY_TRUSTED_EVENTS,
useFactory: () => !inject(TUI_IS_E2E),
Expand Down
8 changes: 0 additions & 8 deletions projects/demo/src/modules/app/cypress.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,4 @@
&._hide-cursor * {
caret-color: transparent !important;
}

&._no-smooth-scroll * {
scroll-behavior: auto !important;
}

&._stop-animation * {
animation-iteration-count: 0 !important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

.vertical,
.horizontal {
.scroll-behavior();
.transition(~'box-shadow, background');
position: relative;
background: var(--tui-base-01);
color: var(--tui-text-01);
box-shadow: 0 0.125rem 0.1875rem rgba(0, 0, 0, 0.1);
border: 1px solid var(--tui-base-03);
scroll-behavior: smooth;
}

.title {
Expand Down
2 changes: 1 addition & 1 deletion projects/kit/components/input-tag/input-tag.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
}

.t-scrollbar {
.scroll-behavior();
margin-inline-start: -0.25rem;
min-width: 100%;
scroll-behavior: smooth;

:host:not(._label-outside) &,
:host._label-outside._icon-left & {
Expand Down

0 comments on commit 710fe20

Please sign in to comment.