Просмотр исходного кода

ref(settings-dialog) Refactor styles (#13017)

Remove unused styles
Move some styles to their tab
Convert CalendarTab to TS
Fix mobile styles
factor2
Robert Pintilii 2 лет назад
Родитель
Сommit
a94ba85a98
Аккаунт пользователя с таким Email не найден

react/features/settings/components/web/CalendarTab.js → react/features/settings/components/web/CalendarTab.tsx Просмотреть файл

1
-// @flow
2
-
3
 import Spinner from '@atlaskit/spinner';
1
 import Spinner from '@atlaskit/spinner';
2
+import { Theme } from '@mui/material';
3
+import { withStyles } from '@mui/styles';
4
 import React, { Component } from 'react';
4
 import React, { Component } from 'react';
5
+import { WithTranslation } from 'react-i18next';
6
+import { connect } from 'react-redux';
5
 
7
 
6
-import { translate } from '../../../base/i18n';
7
-import { connect } from '../../../base/redux';
8
+import { IReduxState } from '../../../app/types';
9
+import { translate } from '../../../base/i18n/functions';
10
+import { withPixelLineHeight } from '../../../base/styles/functions.web';
8
 import Button from '../../../base/ui/components/web/Button';
11
 import Button from '../../../base/ui/components/web/Button';
9
 import {
12
 import {
10
     CALENDAR_TYPE,
13
     CALENDAR_TYPE,
13
     clearCalendarIntegration,
16
     clearCalendarIntegration,
14
     isCalendarEnabled,
17
     isCalendarEnabled,
15
     signIn
18
     signIn
19
+
20
+    // @ts-ignore
16
 } from '../../../calendar-sync';
21
 } from '../../../calendar-sync';
22
+// eslint-disable-next-line lines-around-comment
23
+// @ts-ignore
17
 import { GoogleSignInButton } from '../../../google-api';
24
 import { GoogleSignInButton } from '../../../google-api';
18
 import logger from '../../logger';
25
 import logger from '../../logger';
19
 
26
 
20
-declare var interfaceConfig: Object;
21
-
22
 /**
27
 /**
23
  * The type of the React {@code Component} props of {@link CalendarTab}.
28
  * The type of the React {@code Component} props of {@link CalendarTab}.
24
  */
29
  */
25
-type Props = {
30
+interface IProps extends WithTranslation {
26
 
31
 
27
     /**
32
     /**
28
      * The name given to this Jitsi Application.
33
      * The name given to this Jitsi Application.
29
      */
34
      */
30
-    _appName: string,
35
+    _appName: string;
31
 
36
 
32
     /**
37
     /**
33
      * Whether or not to display a button to sign in to Google.
38
      * Whether or not to display a button to sign in to Google.
34
      */
39
      */
35
-    _enableGoogleIntegration: boolean,
40
+    _enableGoogleIntegration: boolean;
36
 
41
 
37
     /**
42
     /**
38
      * Whether or not to display a button to sign in to Microsoft.
43
      * Whether or not to display a button to sign in to Microsoft.
39
      */
44
      */
40
-    _enableMicrosoftIntegration: boolean,
45
+    _enableMicrosoftIntegration: boolean;
41
 
46
 
42
     /**
47
     /**
43
      * The current calendar integration in use, if any.
48
      * The current calendar integration in use, if any.
44
      */
49
      */
45
-    _isConnectedToCalendar: boolean,
50
+    _isConnectedToCalendar: boolean;
46
 
51
 
47
     /**
52
     /**
48
      * The email address associated with the calendar integration in use.
53
      * The email address associated with the calendar integration in use.
49
      */
54
      */
50
-    _profileEmail: string,
55
+    _profileEmail?: string;
51
 
56
 
52
     /**
57
     /**
53
-     * Invoked to change the configured calendar integration.
58
+     * CSS classes object.
54
      */
59
      */
55
-    dispatch: Function,
60
+    classes: any;
56
 
61
 
57
     /**
62
     /**
58
-     * Invoked to obtain translated strings.
63
+     * Invoked to change the configured calendar integration.
59
      */
64
      */
60
-    t: Function
61
-};
65
+    dispatch: Function;
66
+}
62
 
67
 
63
 /**
68
 /**
64
  * The type of the React {@code Component} state of {@link CalendarTab}.
69
  * The type of the React {@code Component} state of {@link CalendarTab}.
65
  */
70
  */
66
-type State = {
71
+interface IState {
67
 
72
 
68
     /**
73
     /**
69
      * Whether or not any third party APIs are being loaded.
74
      * Whether or not any third party APIs are being loaded.
70
      */
75
      */
71
-    loading: boolean
76
+    loading: boolean;
77
+}
78
+
79
+const styles = (theme: Theme) => {
80
+    return {
81
+        container: {
82
+            width: '100%',
83
+            display: 'flex',
84
+            flexDirection: 'column' as const,
85
+            alignItems: 'center',
86
+            justifyContent: 'center',
87
+            textAlign: 'center',
88
+            minHeight: '100px',
89
+            color: theme.palette.text01,
90
+            ...withPixelLineHeight(theme.typography.bodyShortRegular)
91
+        },
92
+
93
+        button: {
94
+            marginTop: theme.spacing(4)
95
+        }
96
+    };
72
 };
97
 };
73
 
98
 
74
 /**
99
 /**
76
  *
101
  *
77
  * @augments Component
102
  * @augments Component
78
  */
103
  */
79
-class CalendarTab extends Component<Props, State> {
104
+class CalendarTab extends Component<IProps, IState> {
80
     /**
105
     /**
81
      * Initializes a new {@code CalendarTab} instance.
106
      * Initializes a new {@code CalendarTab} instance.
82
      *
107
      *
83
      * @inheritdoc
108
      * @inheritdoc
84
      */
109
      */
85
-    constructor(props: Props) {
110
+    constructor(props: IProps) {
86
         super(props);
111
         super(props);
87
 
112
 
88
         this.state = {
113
         this.state = {
103
      */
128
      */
104
     componentDidMount() {
129
     componentDidMount() {
105
         this.props.dispatch(bootstrapCalendarIntegration())
130
         this.props.dispatch(bootstrapCalendarIntegration())
106
-            .catch(err => logger.error('CalendarTab bootstrap failed', err))
131
+            .catch((err: any) => logger.error('CalendarTab bootstrap failed', err))
107
             .then(() => this.setState({ loading: false }));
132
             .then(() => this.setState({ loading: false }));
108
     }
133
     }
109
 
134
 
114
      * @returns {ReactElement}
139
      * @returns {ReactElement}
115
      */
140
      */
116
     render() {
141
     render() {
142
+        const { classes } = this.props;
117
         let view;
143
         let view;
118
 
144
 
119
         if (this.state.loading) {
145
         if (this.state.loading) {
125
         }
151
         }
126
 
152
 
127
         return (
153
         return (
128
-            <div className = 'calendar-tab'>
154
+            <div className = { classes.container }>
129
                 { view }
155
                 { view }
130
             </div>
156
             </div>
131
         );
157
         );
139
      * @private
165
      * @private
140
      * @returns {void}
166
      * @returns {void}
141
      */
167
      */
142
-    _attemptSignIn(type) {
168
+    _attemptSignIn(type: string) {
143
         this.props.dispatch(signIn(type));
169
         this.props.dispatch(signIn(type));
144
     }
170
     }
145
 
171
 
146
-    _onClickDisconnect: (Object) => void;
147
-
148
     /**
172
     /**
149
      * Dispatches an action to sign out of the currently connected third party
173
      * Dispatches an action to sign out of the currently connected third party
150
      * used for calendar integration.
174
      * used for calendar integration.
161
         this.props.dispatch(clearCalendarIntegration());
185
         this.props.dispatch(clearCalendarIntegration());
162
     }
186
     }
163
 
187
 
164
-    _onClickGoogle: () => void;
165
-
166
     /**
188
     /**
167
      * Starts the sign in flow for Google calendar integration.
189
      * Starts the sign in flow for Google calendar integration.
168
      *
190
      *
173
         this._attemptSignIn(CALENDAR_TYPE.GOOGLE);
195
         this._attemptSignIn(CALENDAR_TYPE.GOOGLE);
174
     }
196
     }
175
 
197
 
176
-    _onClickMicrosoft: () => void;
177
-
178
     /**
198
     /**
179
      * Starts the sign in flow for Microsoft calendar integration.
199
      * Starts the sign in flow for Microsoft calendar integration.
180
      *
200
      *
194
     _renderLoadingState() {
214
     _renderLoadingState() {
195
         return (
215
         return (
196
             <Spinner
216
             <Spinner
217
+
218
+                // @ts-ignore
197
                 isCompleting = { false }
219
                 isCompleting = { false }
198
                 size = 'medium' />
220
                 size = 'medium' />
199
         );
221
         );
211
             _appName,
233
             _appName,
212
             _enableGoogleIntegration,
234
             _enableGoogleIntegration,
213
             _enableMicrosoftIntegration,
235
             _enableMicrosoftIntegration,
236
+            classes,
214
             t
237
             t
215
         } = this.props;
238
         } = this.props;
216
 
239
 
217
         return (
240
         return (
218
-            <div>
241
+            <>
219
                 <p>
242
                 <p>
220
                     { t('settings.calendar.about',
243
                     { t('settings.calendar.about',
221
                         { appName: _appName || '' }) }
244
                         { appName: _appName || '' }) }
222
                 </p>
245
                 </p>
223
                 { _enableGoogleIntegration
246
                 { _enableGoogleIntegration
224
-                    && <div className = 'calendar-tab-sign-in'>
247
+                    && <div className = { classes.button }>
225
                         <GoogleSignInButton
248
                         <GoogleSignInButton
226
                             onClick = { this._onClickGoogle }
249
                             onClick = { this._onClickGoogle }
227
                             text = { t('liveStreaming.signIn') } />
250
                             text = { t('liveStreaming.signIn') } />
228
                     </div> }
251
                     </div> }
229
                 { _enableMicrosoftIntegration
252
                 { _enableMicrosoftIntegration
230
-                    && <div className = 'calendar-tab-sign-in'>
253
+                    && <div className = { classes.button }>
231
                         <MicrosoftSignInButton
254
                         <MicrosoftSignInButton
232
                             onClick = { this._onClickMicrosoft }
255
                             onClick = { this._onClickMicrosoft }
233
                             text = { t('settings.calendar.microsoftSignIn') } />
256
                             text = { t('settings.calendar.microsoftSignIn') } />
234
                     </div> }
257
                     </div> }
235
-            </div>
258
+            </>
236
         );
259
         );
237
     }
260
     }
238
 
261
 
244
      * @returns {ReactElement}
267
      * @returns {ReactElement}
245
      */
268
      */
246
     _renderSignOutState() {
269
     _renderSignOutState() {
247
-        const { _profileEmail, t } = this.props;
270
+        const { _profileEmail, classes, t } = this.props;
248
 
271
 
249
         return (
272
         return (
250
-            <div>
251
-                <div className = 'sign-out-cta'>
252
-                    { t('settings.calendar.signedIn',
273
+            <>
274
+                { t('settings.calendar.signedIn',
253
                         { email: _profileEmail }) }
275
                         { email: _profileEmail }) }
254
-                </div>
255
-                <div className = 'sign-out-cta-button'>
256
-                    <Button
257
-                        id = 'calendar_logout'
258
-                        label = { t('settings.calendar.disconnect') }
259
-                        onClick = { this._onClickDisconnect } />
260
-                </div>
261
-            </div>
276
+                <Button
277
+                    className = { classes.button }
278
+                    id = 'calendar_logout'
279
+                    label = { t('settings.calendar.disconnect') }
280
+                    onClick = { this._onClickDisconnect } />
281
+            </>
262
         );
282
         );
263
     }
283
     }
264
 }
284
 }
277
  *     _profileEmail: string
297
  *     _profileEmail: string
278
  * }}
298
  * }}
279
  */
299
  */
280
-function _mapStateToProps(state) {
300
+function _mapStateToProps(state: IReduxState) {
281
     const calendarState = state['features/calendar-sync'] || {};
301
     const calendarState = state['features/calendar-sync'] || {};
282
     const {
302
     const {
283
         googleApiApplicationClientID,
303
         googleApiApplicationClientID,
296
     };
316
     };
297
 }
317
 }
298
 
318
 
299
-export default translate(connect(_mapStateToProps)(CalendarTab));
319
+export default withStyles(styles)(translate(connect(_mapStateToProps)(CalendarTab)));

+ 13
- 2
react/features/settings/components/web/NotificationsTab.tsx Просмотреть файл

84
     return {
84
     return {
85
         container: {
85
         container: {
86
             display: 'flex',
86
             display: 'flex',
87
-            width: '100%'
87
+            width: '100%',
88
+
89
+            '@media (max-width: 607px)': {
90
+                flexDirection: 'column' as const
91
+            }
88
         },
92
         },
89
 
93
 
90
         column: {
94
         column: {
95
+            display: 'flex',
96
+            flexDirection: 'column' as const,
91
             flex: 1,
97
             flex: 1,
92
 
98
 
93
             '&:first-child:not(:last-child)': {
99
             '&:first-child:not(:last-child)': {
94
-                marginRight: theme.spacing(3)
100
+                marginRight: theme.spacing(3),
101
+
102
+                '@media (max-width: 607px)': {
103
+                    marginRight: 0,
104
+                    marginBottom: theme.spacing(3)
105
+                }
95
             }
106
             }
96
         },
107
         },
97
 
108
 

+ 14
- 2
react/features/settings/components/web/ProfileTab.tsx Просмотреть файл

13
 import AbstractDialogTab, {
13
 import AbstractDialogTab, {
14
     IProps as AbstractDialogTabProps } from '../../../base/dialog/components/web/AbstractDialogTab';
14
     IProps as AbstractDialogTabProps } from '../../../base/dialog/components/web/AbstractDialogTab';
15
 import { translate } from '../../../base/i18n/functions';
15
 import { translate } from '../../../base/i18n/functions';
16
+import { withPixelLineHeight } from '../../../base/styles/functions.web';
16
 import Button from '../../../base/ui/components/web/Button';
17
 import Button from '../../../base/ui/components/web/Button';
17
 import Checkbox from '../../../base/ui/components/web/Checkbox';
18
 import Checkbox from '../../../base/ui/components/web/Checkbox';
18
 import Input from '../../../base/ui/components/web/Input';
19
 import Input from '../../../base/ui/components/web/Input';
109
 
110
 
110
         bottomMargin: {
111
         bottomMargin: {
111
             marginBottom: theme.spacing(4)
112
             marginBottom: theme.spacing(4)
113
+        },
114
+
115
+        label: {
116
+            color: `${theme.palette.text01} !important`,
117
+            ...withPixelLineHeight(theme.typography.bodyShortRegular),
118
+            marginBottom: theme.spacing(2)
119
+        },
120
+
121
+        name: {
122
+            marginBottom: theme.spacing(1)
112
         }
123
         }
113
     };
124
     };
114
 };
125
 };
312
     _renderAuth() {
323
     _renderAuth() {
313
         const {
324
         const {
314
             authLogin,
325
             authLogin,
326
+            classes,
315
             t
327
             t
316
         } = this.props;
328
         } = this.props;
317
 
329
 
318
         return (
330
         return (
319
             <div>
331
             <div>
320
-                <h2 className = 'mock-atlaskit-label'>
332
+                <h2 className = { classes.label }>
321
                     { t('toolbar.authenticate') }
333
                     { t('toolbar.authenticate') }
322
                 </h2>
334
                 </h2>
323
                 { authLogin
335
                 { authLogin
324
-                    && <div className = 'auth-name'>
336
+                    && <div className = { classes.name }>
325
                         { t('settings.loggedIn', { name: authLogin }) }
337
                         { t('settings.loggedIn', { name: authLogin }) }
326
                     </div> }
338
                     </div> }
327
                 <Button
339
                 <Button

+ 8
- 102
react/features/settings/components/web/SettingsDialog.tsx Просмотреть файл

1
-import { Theme } from '@mui/material';
2
 import { withStyles } from '@mui/styles';
1
 import { withStyles } from '@mui/styles';
3
 import React, { Component } from 'react';
2
 import React, { Component } from 'react';
4
 
3
 
15
     IconVolumeUp
14
     IconVolumeUp
16
 } from '../../../base/icons/svg';
15
 } from '../../../base/icons/svg';
17
 import { connect } from '../../../base/redux/functions';
16
 import { connect } from '../../../base/redux/functions';
18
-import { withPixelLineHeight } from '../../../base/styles/functions.web';
19
 import DialogWithTabs, { IDialogTab } from '../../../base/ui/components/web/DialogWithTabs';
17
 import DialogWithTabs, { IDialogTab } from '../../../base/ui/components/web/DialogWithTabs';
20
 import { isCalendarEnabled } from '../../../calendar-sync/functions.web';
18
 import { isCalendarEnabled } from '../../../calendar-sync/functions.web';
21
 import { submitAudioDeviceSelectionTab, submitVideoDeviceSelectionTab } from '../../../device-selection/actions.web';
19
 import { submitAudioDeviceSelectionTab, submitVideoDeviceSelectionTab } from '../../../device-selection/actions.web';
45
     getVirtualBackgroundTabProps
43
     getVirtualBackgroundTabProps
46
 } from '../../functions';
44
 } from '../../functions';
47
 
45
 
48
-// @ts-ignore
49
 import CalendarTab from './CalendarTab';
46
 import CalendarTab from './CalendarTab';
50
 import ModeratorTab from './ModeratorTab';
47
 import ModeratorTab from './ModeratorTab';
51
 import MoreTab from './MoreTab';
48
 import MoreTab from './MoreTab';
95
  *
92
  *
96
  * @returns {Object}
93
  * @returns {Object}
97
  */
94
  */
98
-const styles = (theme: Theme) => {
95
+const styles = () => {
99
     return {
96
     return {
100
         settingsDialog: {
97
         settingsDialog: {
101
             display: 'flex',
98
             display: 'flex',
102
-            width: '100%',
103
-
104
-            '& .auth-name': {
105
-                marginBottom: theme.spacing(1)
106
-            },
107
-
108
-            '& .mock-atlaskit-label': {
109
-                color: '#b8c7e0',
110
-                fontSize: '12px',
111
-                fontWeight: 600,
112
-                lineHeight: 1.33,
113
-                padding: `20px 0px ${theme.spacing(1)} 0px`
114
-            },
115
-
116
-            '& .checkbox-label': {
117
-                color: theme.palette.text01,
118
-                ...withPixelLineHeight(theme.typography.bodyShortRegular),
119
-                marginBottom: theme.spacing(2),
120
-                display: 'block',
121
-                marginTop: '20px'
122
-            },
123
-
124
-            '& input[type="checkbox"]:checked + svg': {
125
-                '--checkbox-background-color': '#6492e7',
126
-                '--checkbox-border-color': '#6492e7'
127
-            },
128
-
129
-            '& input[type="checkbox"] + svg + span': {
130
-                color: '#9FB0CC'
131
-            },
132
-
133
-            // @ts-ignore
134
-            [[ '& .calendar-tab',
135
-                '& .more-tab',
136
-                '& .box' ]]: {
137
-                display: 'flex',
138
-                justifyContent: 'space-between',
139
-                width: '100%'
140
-            },
141
-
142
-            '& .settings-sub-pane': {
143
-                flex: 1
144
-            },
145
-
146
-            '& .settings-sub-pane .right': {
147
-                flex: 1
148
-            },
149
-            '& .settings-sub-pane .left': {
150
-                flex: 1
151
-            },
152
-
153
-            '& .settings-sub-pane-element': {
154
-                textAlign: 'left',
155
-                flex: 1
156
-            },
157
-
158
-            '& .dropdown-menu': {
159
-                marginTop: '20px'
160
-            },
161
-
162
-            '& .settings-checkbox': {
163
-                display: 'flex',
164
-                marginBottom: theme.spacing(3)
165
-            },
166
-
167
-            '& .calendar-tab': {
168
-                alignItems: 'center',
169
-                flexDirection: 'column',
170
-                fontSize: '14px',
171
-                minHeight: '100px',
172
-                textAlign: 'center',
173
-                marginTop: '20px'
174
-            },
175
-
176
-            '& .calendar-tab-sign-in': {
177
-                marginTop: '20px'
178
-            },
179
-
180
-            '& .sign-out-cta': {
181
-                marginBottom: '20px'
182
-            },
183
-
184
-            '& .sign-out-cta-button': {
185
-                display: 'flex',
186
-                justifyContent: 'center'
187
-            },
188
-
189
-            '@media only screen and (max-width: 700px)': {
190
-                '& .more-tab': {
191
-                    flexDirection: 'column'
192
-                }
193
-            }
99
+            width: '100%'
194
         }
100
         }
195
     };
101
     };
196
 };
102
 };
282
                     selectedAudioOutputId: tabState.selectedAudioOutputId
188
                     selectedAudioOutputId: tabState.selectedAudioOutputId
283
                 };
189
                 };
284
             },
190
             },
285
-            className: `settings-pane ${classes.settingsDialog} devices-pane`,
191
+            className: `settings-pane ${classes.settingsDialog}`,
286
             submit: (newState: any) => submitAudioDeviceSelectionTab(newState, isDisplayedOnWelcomePage),
192
             submit: (newState: any) => submitAudioDeviceSelectionTab(newState, isDisplayedOnWelcomePage),
287
             icon: IconVolumeUp
193
             icon: IconVolumeUp
288
         });
194
         });
305
                     selectedVideoInputId: tabState.selectedVideoInputId
211
                     selectedVideoInputId: tabState.selectedVideoInputId
306
                 };
212
                 };
307
             },
213
             },
308
-            className: `settings-pane ${classes.settingsDialog} devices-pane`,
214
+            className: `settings-pane ${classes.settingsDialog}`,
309
             submit: (newState: any) => submitVideoDeviceSelectionTab(newState, isDisplayedOnWelcomePage),
215
             submit: (newState: any) => submitVideoDeviceSelectionTab(newState, isDisplayedOnWelcomePage),
310
             icon: IconVideo
216
             icon: IconVideo
311
         });
217
         });
371
                     startReactionsMuted: tabState?.startReactionsMuted
277
                     startReactionsMuted: tabState?.startReactionsMuted
372
                 };
278
                 };
373
             },
279
             },
374
-            className: `settings-pane ${classes.settingsDialog} moderator-pane`,
280
+            className: `settings-pane ${classes.settingsDialog}`,
375
             submit: submitModeratorTab,
281
             submit: submitModeratorTab,
376
             icon: IconModerator
282
             icon: IconModerator
377
         });
283
         });
383
             component: ProfileTab,
289
             component: ProfileTab,
384
             labelKey: 'profile.title',
290
             labelKey: 'profile.title',
385
             props: getProfileTabProps(state),
291
             props: getProfileTabProps(state),
386
-            className: `settings-pane ${classes.settingsDialog} profile-pane`,
292
+            className: `settings-pane ${classes.settingsDialog}`,
387
             submit: submitProfileTab,
293
             submit: submitProfileTab,
388
             icon: IconUser
294
             icon: IconUser
389
         });
295
         });
394
             name: SETTINGS_TABS.CALENDAR,
300
             name: SETTINGS_TABS.CALENDAR,
395
             component: CalendarTab,
301
             component: CalendarTab,
396
             labelKey: 'settings.calendar.title',
302
             labelKey: 'settings.calendar.title',
397
-            className: `settings-pane ${classes.settingsDialog} calendar-pane`,
303
+            className: `settings-pane ${classes.settingsDialog}`,
398
             icon: IconCalendar
304
             icon: IconCalendar
399
         });
305
         });
400
     }
306
     }
434
                     maxStageParticipants: tabState?.maxStageParticipants
340
                     maxStageParticipants: tabState?.maxStageParticipants
435
                 };
341
                 };
436
             },
342
             },
437
-            className: `settings-pane ${classes.settingsDialog} more-pane`,
343
+            className: `settings-pane ${classes.settingsDialog}`,
438
             submit: submitMoreTab,
344
             submit: submitMoreTab,
439
             icon: IconGear
345
             icon: IconGear
440
         });
346
         });

Загрузка…
Отмена
Сохранить