import { Subscription } from 'rxjs' ; import { IUiSettingsClient } from '../../ui_settings' ; import { CoreService } from '../../../types' ; import disableAnimationsCss from '!!raw-loader!./disable_animations.css' ; interface StartDeps { uiSettings : IUiSettingsClient ; } internal export class StylesService implements CoreService { private uiSettingsSubscription ? : Subscription ; public async setup ( ) { } public async start ( { uiSettings } ) { const disableAnimationsStyleTag = document . createElement ( 'style' ) ; disableAnimationsStyleTag . setAttribute ( 'id' , 'disableAnimationsCss' ) ; document . head . appendChild ( disableAnimationsStyleTag ) ; const setDisableAnimations = ( disableAnimations ) => { disableAnimationsStyleTag . textContent = disableAnimations ? disableAnimationsCss : '' ; } ; this . uiSettingsSubscription = uiSettings . get$ ( 'accessibility:disableAnimations' ) . subscribe ( setDisableAnimations ) ; } public async stop ( ) { if ( this . uiSettingsSubscription ) { this . uiSettingsSubscription . unsubscribe ( ) ; this . uiSettingsSubscription = undefined ; } } }