From 969eda02a66050cf4518ddfa657e86d1d6d8b6c3 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Tue, 10 Aug 2021 19:04:54 +0200 Subject: feat: follow OS reduced motion setting (#1757) - add missing meta charset to index.html - dont restrict scaling for user in index.html - load animations.css conditionally based on motion preference - load transitions conditionally in js and css based on motion preference Co-authored-by: Vijay Raghavan Aravamudhan --- src/components/auth/SetupAssistant.js | 110 ++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 50 deletions(-) (limited to 'src/components/auth') diff --git a/src/components/auth/SetupAssistant.js b/src/components/auth/SetupAssistant.js index bd9069eb7..06ab09892 100644 --- a/src/components/auth/SetupAssistant.js +++ b/src/components/auth/SetupAssistant.js @@ -18,15 +18,16 @@ const SLACK_ID = 'slack'; const messages = defineMessages({ headline: { id: 'setupAssistant.headline', - defaultMessage: '!!!Let\'s get started', + defaultMessage: "!!!Let's get started", }, subHeadline: { id: 'setupAssistant.subheadline', - defaultMessage: '!!!Choose from our most used services and get back on top of your messaging now.', + defaultMessage: + '!!!Choose from our most used services and get back on top of your messaging now.', }, submitButtonLabel: { id: 'setupAssistant.submit.label', - defaultMessage: '!!!Let\'s go', + defaultMessage: "!!!Let's go", }, inviteSuccessInfo: { id: 'invite.successInfo', @@ -34,14 +35,19 @@ const messages = defineMessages({ }, }); -const styles = (theme) => ({ +let transition = 'none'; + +if (window.matchMedia('(prefers-reduced-motion: no-preference)')) { + transition = 'all 0.25s'; +} + +const styles = theme => ({ root: { width: '500px !important', textAlign: 'center', padding: 20, - '& h1': { - }, + '& h1': {}, }, servicesGrid: { display: 'flex', @@ -60,7 +66,7 @@ const styles = (theme) => ({ borderRadius: theme.borderRadius, marginBottom: 10, opacity: 0.5, - transition: 'all 0.25s', + transition, border: [3, 'solid', 'transparent'], '& h2': { @@ -70,10 +76,8 @@ const styles = (theme) => ({ '&:hover': { border: [3, 'solid', theme.brandPrimary], - '& $serviceIcon': { - }, + '& $serviceIcon': {}, }, - }, selected: { border: [3, 'solid', theme.brandPrimary], @@ -82,7 +86,7 @@ const styles = (theme) => ({ }, serviceIcon: { width: 50, - transition: 'all 0.25s', + transition, }, slackModalContent: { @@ -125,7 +129,8 @@ const styles = (theme) => ({ }, }); -@injectSheet(styles) @observer +@injectSheet(styles) +@observer class SetupAssistant extends Component { static propTypes = { classes: PropTypes.object.isRequired, @@ -144,13 +149,17 @@ class SetupAssistant extends Component { }; state = { - services: [{ - id: 'whatsapp', - }, { - id: 'messenger', - }, { - id: 'gmail', - }], + services: [ + { + id: 'whatsapp', + }, + { + id: 'messenger', + }, + { + id: 'gmail', + }, + ], isSlackModalOpen: false, slackWorkspace: '', }; @@ -158,10 +167,12 @@ class SetupAssistant extends Component { slackWorkspaceHandler() { const { slackWorkspace = '', services } = this.state; - const sanitizedWorkspace = slackWorkspace.trim().replace(/^https?:\/\//, ''); + const sanitizedWorkspace = slackWorkspace + .trim() + .replace(/^https?:\/\//, ''); if (sanitizedWorkspace) { - const index = services.findIndex((s) => s.id === SLACK_ID); + const index = services.findIndex(s => s.id === SLACK_ID); if (index === -1) { const newServices = services; @@ -179,9 +190,17 @@ class SetupAssistant extends Component { render() { const { intl } = this.context; const { - classes, isInviteSuccessful, onSubmit, services, isSettingUpServices, + classes, + isInviteSuccessful, + onSubmit, + services, + isSettingUpServices, } = this.props; - const { isSlackModalOpen, slackWorkspace, services: addedServices } = this.state; + const { + isSlackModalOpen, + slackWorkspace, + services: addedServices, + } = this.state; return (
@@ -197,29 +216,22 @@ class SetupAssistant extends Component { )} - -

- {intl.formatMessage(messages.headline)} -

-

- {intl.formatMessage(messages.subHeadline)} -

+ +

{intl.formatMessage(messages.headline)}

+

{intl.formatMessage(messages.subHeadline)}

- {Object.keys(services).map((id) => { + {Object.keys(services).map(id => { const service = services[id]; return (