소스 검색

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 년 전
부모
커밋
a94ba85a98
No account linked to committer's email address

react/features/settings/components/web/CalendarTab.js → react/features/settings/components/web/CalendarTab.tsx 파일 보기

@@ -1,10 +1,13 @@
1
-// @flow
2
-
3 1
 import Spinner from '@atlaskit/spinner';
2
+import { Theme } from '@mui/material';
3
+import { withStyles } from '@mui/styles';
4 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 11
 import Button from '../../../base/ui/components/web/Button';
9 12
 import {
10 13
     CALENDAR_TYPE,
@@ -13,62 +16,84 @@ import {
13 16
     clearCalendarIntegration,
14 17
     isCalendarEnabled,
15 18
     signIn
19
+
20
+    // @ts-ignore
16 21
 } from '../../../calendar-sync';
22
+// eslint-disable-next-line lines-around-comment
23
+// @ts-ignore
17 24
 import { GoogleSignInButton } from '../../../google-api';
18 25
 import logger from '../../logger';
19 26
 
20
-declare var interfaceConfig: Object;
21
-
22 27
 /**
23 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 33
      * The name given to this Jitsi Application.
29 34
      */
30
-    _appName: string,
35
+    _appName: string;
31 36
 
32 37
     /**
33 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 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 48
      * The current calendar integration in use, if any.
44 49
      */
45
-    _isConnectedToCalendar: boolean,
50
+    _isConnectedToCalendar: boolean;
46 51
 
47 52
     /**
48 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 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 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,13 +101,13 @@ type State = {
76 101
  *
77 102
  * @augments Component
78 103
  */
79
-class CalendarTab extends Component<Props, State> {
104
+class CalendarTab extends Component<IProps, IState> {
80 105
     /**
81 106
      * Initializes a new {@code CalendarTab} instance.
82 107
      *
83 108
      * @inheritdoc
84 109
      */
85
-    constructor(props: Props) {
110
+    constructor(props: IProps) {
86 111
         super(props);
87 112
 
88 113
         this.state = {
@@ -103,7 +128,7 @@ class CalendarTab extends Component<Props, State> {
103 128
      */
104 129
     componentDidMount() {
105 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 132
             .then(() => this.setState({ loading: false }));
108 133
     }
109 134
 
@@ -114,6 +139,7 @@ class CalendarTab extends Component<Props, State> {
114 139
      * @returns {ReactElement}
115 140
      */
116 141
     render() {
142
+        const { classes } = this.props;
117 143
         let view;
118 144
 
119 145
         if (this.state.loading) {
@@ -125,7 +151,7 @@ class CalendarTab extends Component<Props, State> {
125 151
         }
126 152
 
127 153
         return (
128
-            <div className = 'calendar-tab'>
154
+            <div className = { classes.container }>
129 155
                 { view }
130 156
             </div>
131 157
         );
@@ -139,12 +165,10 @@ class CalendarTab extends Component<Props, State> {
139 165
      * @private
140 166
      * @returns {void}
141 167
      */
142
-    _attemptSignIn(type) {
168
+    _attemptSignIn(type: string) {
143 169
         this.props.dispatch(signIn(type));
144 170
     }
145 171
 
146
-    _onClickDisconnect: (Object) => void;
147
-
148 172
     /**
149 173
      * Dispatches an action to sign out of the currently connected third party
150 174
      * used for calendar integration.
@@ -161,8 +185,6 @@ class CalendarTab extends Component<Props, State> {
161 185
         this.props.dispatch(clearCalendarIntegration());
162 186
     }
163 187
 
164
-    _onClickGoogle: () => void;
165
-
166 188
     /**
167 189
      * Starts the sign in flow for Google calendar integration.
168 190
      *
@@ -173,8 +195,6 @@ class CalendarTab extends Component<Props, State> {
173 195
         this._attemptSignIn(CALENDAR_TYPE.GOOGLE);
174 196
     }
175 197
 
176
-    _onClickMicrosoft: () => void;
177
-
178 198
     /**
179 199
      * Starts the sign in flow for Microsoft calendar integration.
180 200
      *
@@ -194,6 +214,8 @@ class CalendarTab extends Component<Props, State> {
194 214
     _renderLoadingState() {
195 215
         return (
196 216
             <Spinner
217
+
218
+                // @ts-ignore
197 219
                 isCompleting = { false }
198 220
                 size = 'medium' />
199 221
         );
@@ -211,28 +233,29 @@ class CalendarTab extends Component<Props, State> {
211 233
             _appName,
212 234
             _enableGoogleIntegration,
213 235
             _enableMicrosoftIntegration,
236
+            classes,
214 237
             t
215 238
         } = this.props;
216 239
 
217 240
         return (
218
-            <div>
241
+            <>
219 242
                 <p>
220 243
                     { t('settings.calendar.about',
221 244
                         { appName: _appName || '' }) }
222 245
                 </p>
223 246
                 { _enableGoogleIntegration
224
-                    && <div className = 'calendar-tab-sign-in'>
247
+                    && <div className = { classes.button }>
225 248
                         <GoogleSignInButton
226 249
                             onClick = { this._onClickGoogle }
227 250
                             text = { t('liveStreaming.signIn') } />
228 251
                     </div> }
229 252
                 { _enableMicrosoftIntegration
230
-                    && <div className = 'calendar-tab-sign-in'>
253
+                    && <div className = { classes.button }>
231 254
                         <MicrosoftSignInButton
232 255
                             onClick = { this._onClickMicrosoft }
233 256
                             text = { t('settings.calendar.microsoftSignIn') } />
234 257
                     </div> }
235
-            </div>
258
+            </>
236 259
         );
237 260
     }
238 261
 
@@ -244,21 +267,18 @@ class CalendarTab extends Component<Props, State> {
244 267
      * @returns {ReactElement}
245 268
      */
246 269
     _renderSignOutState() {
247
-        const { _profileEmail, t } = this.props;
270
+        const { _profileEmail, classes, t } = this.props;
248 271
 
249 272
         return (
250
-            <div>
251
-                <div className = 'sign-out-cta'>
252
-                    { t('settings.calendar.signedIn',
273
+            <>
274
+                { t('settings.calendar.signedIn',
253 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,7 +297,7 @@ class CalendarTab extends Component<Props, State> {
277 297
  *     _profileEmail: string
278 298
  * }}
279 299
  */
280
-function _mapStateToProps(state) {
300
+function _mapStateToProps(state: IReduxState) {
281 301
     const calendarState = state['features/calendar-sync'] || {};
282 302
     const {
283 303
         googleApiApplicationClientID,
@@ -296,4 +316,4 @@ function _mapStateToProps(state) {
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,14 +84,25 @@ const styles = (theme: Theme) => {
84 84
     return {
85 85
         container: {
86 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 94
         column: {
95
+            display: 'flex',
96
+            flexDirection: 'column' as const,
91 97
             flex: 1,
92 98
 
93 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,6 +13,7 @@ import Avatar from '../../../base/avatar/components/Avatar';
13 13
 import AbstractDialogTab, {
14 14
     IProps as AbstractDialogTabProps } from '../../../base/dialog/components/web/AbstractDialogTab';
15 15
 import { translate } from '../../../base/i18n/functions';
16
+import { withPixelLineHeight } from '../../../base/styles/functions.web';
16 17
 import Button from '../../../base/ui/components/web/Button';
17 18
 import Checkbox from '../../../base/ui/components/web/Checkbox';
18 19
 import Input from '../../../base/ui/components/web/Input';
@@ -109,6 +110,16 @@ const styles = (theme: Theme) => {
109 110
 
110 111
         bottomMargin: {
111 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,16 +323,17 @@ class ProfileTab extends AbstractDialogTab<IProps, any> {
312 323
     _renderAuth() {
313 324
         const {
314 325
             authLogin,
326
+            classes,
315 327
             t
316 328
         } = this.props;
317 329
 
318 330
         return (
319 331
             <div>
320
-                <h2 className = 'mock-atlaskit-label'>
332
+                <h2 className = { classes.label }>
321 333
                     { t('toolbar.authenticate') }
322 334
                 </h2>
323 335
                 { authLogin
324
-                    && <div className = 'auth-name'>
336
+                    && <div className = { classes.name }>
325 337
                         { t('settings.loggedIn', { name: authLogin }) }
326 338
                     </div> }
327 339
                 <Button

+ 8
- 102
react/features/settings/components/web/SettingsDialog.tsx 파일 보기

@@ -1,4 +1,3 @@
1
-import { Theme } from '@mui/material';
2 1
 import { withStyles } from '@mui/styles';
3 2
 import React, { Component } from 'react';
4 3
 
@@ -15,7 +14,6 @@ import {
15 14
     IconVolumeUp
16 15
 } from '../../../base/icons/svg';
17 16
 import { connect } from '../../../base/redux/functions';
18
-import { withPixelLineHeight } from '../../../base/styles/functions.web';
19 17
 import DialogWithTabs, { IDialogTab } from '../../../base/ui/components/web/DialogWithTabs';
20 18
 import { isCalendarEnabled } from '../../../calendar-sync/functions.web';
21 19
 import { submitAudioDeviceSelectionTab, submitVideoDeviceSelectionTab } from '../../../device-selection/actions.web';
@@ -45,7 +43,6 @@ import {
45 43
     getVirtualBackgroundTabProps
46 44
 } from '../../functions';
47 45
 
48
-// @ts-ignore
49 46
 import CalendarTab from './CalendarTab';
50 47
 import ModeratorTab from './ModeratorTab';
51 48
 import MoreTab from './MoreTab';
@@ -95,102 +92,11 @@ interface IProps {
95 92
  *
96 93
  * @returns {Object}
97 94
  */
98
-const styles = (theme: Theme) => {
95
+const styles = () => {
99 96
     return {
100 97
         settingsDialog: {
101 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,7 +188,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
282 188
                     selectedAudioOutputId: tabState.selectedAudioOutputId
283 189
                 };
284 190
             },
285
-            className: `settings-pane ${classes.settingsDialog} devices-pane`,
191
+            className: `settings-pane ${classes.settingsDialog}`,
286 192
             submit: (newState: any) => submitAudioDeviceSelectionTab(newState, isDisplayedOnWelcomePage),
287 193
             icon: IconVolumeUp
288 194
         });
@@ -305,7 +211,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
305 211
                     selectedVideoInputId: tabState.selectedVideoInputId
306 212
                 };
307 213
             },
308
-            className: `settings-pane ${classes.settingsDialog} devices-pane`,
214
+            className: `settings-pane ${classes.settingsDialog}`,
309 215
             submit: (newState: any) => submitVideoDeviceSelectionTab(newState, isDisplayedOnWelcomePage),
310 216
             icon: IconVideo
311 217
         });
@@ -371,7 +277,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
371 277
                     startReactionsMuted: tabState?.startReactionsMuted
372 278
                 };
373 279
             },
374
-            className: `settings-pane ${classes.settingsDialog} moderator-pane`,
280
+            className: `settings-pane ${classes.settingsDialog}`,
375 281
             submit: submitModeratorTab,
376 282
             icon: IconModerator
377 283
         });
@@ -383,7 +289,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
383 289
             component: ProfileTab,
384 290
             labelKey: 'profile.title',
385 291
             props: getProfileTabProps(state),
386
-            className: `settings-pane ${classes.settingsDialog} profile-pane`,
292
+            className: `settings-pane ${classes.settingsDialog}`,
387 293
             submit: submitProfileTab,
388 294
             icon: IconUser
389 295
         });
@@ -394,7 +300,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
394 300
             name: SETTINGS_TABS.CALENDAR,
395 301
             component: CalendarTab,
396 302
             labelKey: 'settings.calendar.title',
397
-            className: `settings-pane ${classes.settingsDialog} calendar-pane`,
303
+            className: `settings-pane ${classes.settingsDialog}`,
398 304
             icon: IconCalendar
399 305
         });
400 306
     }
@@ -434,7 +340,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
434 340
                     maxStageParticipants: tabState?.maxStageParticipants
435 341
                 };
436 342
             },
437
-            className: `settings-pane ${classes.settingsDialog} more-pane`,
343
+            className: `settings-pane ${classes.settingsDialog}`,
438 344
             submit: submitMoreTab,
439 345
             icon: IconGear
440 346
         });

Loading…
취소
저장