Sfoglia il codice sorgente

feat(ui-components) Add button component (#11868)

factor2
Robert Pintilii 2 anni fa
parent
commit
b08ed3ade4
Nessun account collegato all'indirizzo email del committer

+ 4
- 0
custom.d.ts Vedi File

@@ -0,0 +1,4 @@
1
+declare module '*.svg' {
2
+    const content: any;
3
+    export default content;
4
+}

+ 3
- 1
react/.eslintrc.js Vedi File

@@ -17,7 +17,9 @@ module.exports = {
17 17
                 '@typescript-eslint/no-empty-function': 'off',
18 18
                 '@typescript-eslint/ban-types': 'off',
19 19
                 '@typescript-eslint/no-explicit-any': 'off',
20
-                'no-prototype-builtins': 'off'
20
+                'no-prototype-builtins': 'off',
21
+                'no-shadow': 'off',
22
+                '@typescript-eslint/no-shadow': [ 'error' ]
21 23
             },
22 24
             'plugins': [ '@typescript-eslint' ],
23 25
             'extends': [

+ 195
- 0
react/features/base/components/common/Button.tsx Vedi File

@@ -0,0 +1,195 @@
1
+import { makeStyles } from '@material-ui/core';
2
+import clsx from 'clsx';
3
+import React from 'react';
4
+
5
+import Icon from '../../icons/components/Icon';
6
+import { BUTTON_TYPES } from '../../react/constants';
7
+import { withPixelLineHeight } from '../../styles/functions.web';
8
+
9
+import { ButtonProps } from './types';
10
+
11
+interface IButtonProps extends ButtonProps {
12
+
13
+    /**
14
+     * Whether or not the button should be full width.
15
+     */
16
+    fullWidth?: boolean,
17
+
18
+    /**
19
+     * The id of the button.
20
+     */
21
+    id?: string;
22
+
23
+    /**
24
+     * Click callback.
25
+     */
26
+    onClick: () => void;
27
+
28
+    /**
29
+     * Which size the button should be.
30
+     */
31
+    size?: 'small' | 'medium' | 'large';
32
+}
33
+
34
+const useStyles = makeStyles((theme: any) => {
35
+    return {
36
+        button: {
37
+            backgroundColor: theme.palette.action01,
38
+            color: theme.palette.text01,
39
+            borderRadius: theme.shape.borderRadius,
40
+            padding: '10px 16px',
41
+            display: 'flex',
42
+            alignItems: 'center',
43
+            justifyContent: 'center',
44
+            border: 0,
45
+            ...withPixelLineHeight(theme.typography.bodyShortBold),
46
+            transition: 'background .2s',
47
+            cursor: 'pointer',
48
+
49
+            '&:hover': {
50
+                backgroundColor: theme.palette.action01Hover
51
+            },
52
+
53
+            '&:active': {
54
+                backgroundColor: theme.palette.action01Active
55
+            },
56
+
57
+            '&:focus': {
58
+                outline: 0,
59
+                boxShadow: `0px 0px 0px 2px ${theme.palette.focus01}`
60
+            },
61
+
62
+            '& svg': {
63
+                fill: theme.palette.icon01
64
+            }
65
+        },
66
+
67
+        primary: {},
68
+
69
+        secondary: {
70
+            backgroundColor: theme.palette.action02,
71
+            color: theme.palette.text04,
72
+
73
+            '&:hover': {
74
+                backgroundColor: theme.palette.action02Hover
75
+            },
76
+
77
+            '&:active': {
78
+                backgroundColor: theme.palette.action02Active
79
+            },
80
+
81
+            '& svg': {
82
+                fill: theme.palette.icon04
83
+            }
84
+        },
85
+
86
+        tertiary: {
87
+            backgroundColor: theme.palette.action03,
88
+
89
+            '&:hover': {
90
+                backgroundColor: theme.palette.action03Hover
91
+            },
92
+
93
+            '&:active': {
94
+                backgroundColor: theme.palette.action03Active
95
+            }
96
+        },
97
+
98
+        destructive: {
99
+            backgroundColor: theme.palette.actionDanger,
100
+
101
+            '&:hover': {
102
+                backgroundColor: theme.palette.actionDangerHover
103
+            },
104
+
105
+            '&:active': {
106
+                backgroundColor: theme.palette.actionDangerActive
107
+            }
108
+        },
109
+
110
+        disabled: {
111
+            backgroundColor: theme.palette.disabled01,
112
+            color: theme.palette.text03,
113
+
114
+            '&:hover': {
115
+                backgroundColor: theme.palette.disabled01,
116
+                color: theme.palette.text03
117
+            },
118
+
119
+            '&:active': {
120
+                backgroundColor: theme.palette.disabled01,
121
+                color: theme.palette.text03
122
+            },
123
+
124
+            '& svg': {
125
+                fill: theme.palette.icon03
126
+            }
127
+        },
128
+
129
+        iconButton: {
130
+            padding: '10px'
131
+        },
132
+
133
+        textWithIcon: {
134
+            marginLeft: `${theme.spacing(2)}px`
135
+        },
136
+
137
+        small: {
138
+            padding: '8px 16px',
139
+            ...withPixelLineHeight(theme.typography.labelBold),
140
+
141
+            '&.iconButton': {
142
+                padding: '6px'
143
+            }
144
+        },
145
+
146
+        medium: {},
147
+
148
+        large: {
149
+            padding: '13px 16px',
150
+            ...withPixelLineHeight(theme.typography.bodyShortBoldLarge),
151
+
152
+            '&.iconButton': {
153
+                padding: '14px'
154
+            }
155
+        },
156
+
157
+        fullWidth: {
158
+            width: '100%'
159
+        }
160
+    };
161
+});
162
+
163
+const Button = ({
164
+    accessibilityLabel,
165
+    disabled,
166
+    fullWidth,
167
+    icon,
168
+    id,
169
+    label,
170
+    onClick,
171
+    size = 'medium',
172
+    type = BUTTON_TYPES.PRIMARY
173
+}: IButtonProps) => {
174
+    const styles = useStyles();
175
+
176
+    return (
177
+        <button
178
+            aria-label = { accessibilityLabel }
179
+            className = { clsx(styles.button, styles[type],
180
+                disabled && styles.disabled,
181
+                icon && !label && `${styles.iconButton} iconButton`,
182
+                styles[size], fullWidth && styles.fullWidth) }
183
+            disabled = { disabled }
184
+            { ...(id ? { id } : {}) }
185
+            onClick = { onClick }
186
+            type = 'button'>
187
+            {icon && <Icon
188
+                size = { 20 }
189
+                src = { icon } />}
190
+            {label && <span className = { icon ? styles.textWithIcon : '' }>{label}</span>}
191
+        </button>
192
+    );
193
+};
194
+
195
+export default Button;

+ 29
- 0
react/features/base/components/common/types.ts Vedi File

@@ -0,0 +1,29 @@
1
+import { BUTTON_TYPES } from '../../react/constants';
2
+
3
+export interface ButtonProps {
4
+
5
+    /**
6
+     * Label used for accessibility.
7
+     */
8
+    accessibilityLabel: string;
9
+
10
+    /**
11
+     * Whether or not the button is disabled.
12
+     */
13
+    disabled?: boolean;
14
+
15
+    /**
16
+     * The icon to be displayed on the button.
17
+     */
18
+    icon?: Function;
19
+
20
+    /**
21
+     * The text to be displayed on the button.
22
+     */
23
+    label?: string;
24
+
25
+    /**
26
+     * The type of button to be displayed.
27
+     */
28
+    type?: BUTTON_TYPES;
29
+}

react/features/base/icons/components/Icon.js → react/features/base/icons/components/Icon.tsx Vedi File

@@ -1,8 +1,10 @@
1
-// @flow
2
-
1
+/* eslint-disable import/order */
3 2
 import React, { useCallback } from 'react';
4 3
 
4
+// @ts-ignore
5 5
 import { Container } from '../../react/base';
6
+
7
+// @ts-ignore
6 8
 import { styleTypeToObject } from '../../styles';
7 9
 
8 10
 type Props = {
@@ -15,7 +17,7 @@ type Props = {
15 17
     /**
16 18
      * Color of the icon (if not provided by the style object).
17 19
      */
18
-    color?: ?string,
20
+    color?: string,
19 21
 
20 22
     /**
21 23
      * Id prop (mainly for autotests).
@@ -35,7 +37,7 @@ type Props = {
35 37
     /**
36 38
      * The size of the icon (if not provided by the style object).
37 39
      */
38
-    size?: ?number | string,
40
+    size?: number | string,
39 41
 
40 42
     /**
41 43
      * The preloaded icon component to render.
@@ -82,12 +84,12 @@ type Props = {
82 84
      */
83 85
     ariaControls?: string,
84 86
 
85
-      /**
87
+    /**
86 88
      * TabIndex  for the Icon.
87 89
      */
88 90
     tabIndex?: number,
89 91
 
90
-     /**
92
+    /**
91 93
      * Role for the Icon.
92 94
      */
93 95
     role?: string,
@@ -110,7 +112,7 @@ export const DEFAULT_SIZE = navigator.product === 'ReactNative' ? 36 : 22;
110 112
  * Implements an Icon component that takes a loaded SVG file as prop and renders it as an icon.
111 113
  *
112 114
  * @param {Props} props - The props of the component.
113
- * @returns {Reactelement}
115
+ * @returns {ReactElement}
114 116
  */
115 117
 export default function Icon(props: Props) {
116 118
     const {

react/features/base/icons/svg/index.js → react/features/base/icons/svg/index.ts Vedi File

@@ -1,5 +1,3 @@
1
-// @flow
2
-
3 1
 export { default as IconAdd } from './add.svg';
4 2
 export { default as IconAddPeople } from './link.svg';
5 3
 export { default as IconArrowBack } from './arrow_back.svg';

+ 3
- 3
react/features/base/react/components/native/Button.tsx Vedi File

@@ -11,13 +11,13 @@ import {
11 11
 import BaseTheme from '../../../ui/components/BaseTheme.native';
12 12
 // @ts-ignore
13 13
 import { BUTTON_MODES, BUTTON_TYPES } from '../../constants';
14
-import { ButtonProps } from '../../types';
14
+import { IButtonProps } from '../../types';
15 15
 
16 16
 // @ts-ignore
17 17
 import styles from './styles';
18 18
 
19 19
 
20
-const Button: React.FC<ButtonProps> = ({
20
+const Button: React.FC<IButtonProps> = ({
21 21
     accessibilityLabel,
22 22
     color: buttonColor,
23 23
     disabled,
@@ -27,7 +27,7 @@ const Button: React.FC<ButtonProps> = ({
27 27
     onPress,
28 28
     style,
29 29
     type
30
-}: ButtonProps) => {
30
+}: IButtonProps) => {
31 31
     const { t } = useTranslation();
32 32
     const { CONTAINED } = BUTTON_MODES;
33 33
     const { DESTRUCTIVE, PRIMARY, SECONDARY, TERTIARY } = BUTTON_TYPES;

react/features/base/react/constants.js → react/features/base/react/constants.ts Vedi File

@@ -1,5 +1,3 @@
1
-// @flow
2
-
3 1
 /**
4 2
  * Z-index for components that are to be rendered like an overlay, to be over
5 3
  * everything, such as modal-type of components, or dialogs.
@@ -9,12 +7,12 @@ export const OVERLAY_Z_INDEX = 1000;
9 7
 /**
10 8
  * The types of the buttons.
11 9
  */
12
-export const BUTTON_TYPES = {
13
-    PRIMARY: 'primary',
14
-    SECONDARY: 'secondary',
15
-    TERTIARY: 'tertiary',
16
-    DESTRUCTIVE: 'destructive'
17
-};
10
+export enum BUTTON_TYPES {
11
+    PRIMARY = 'primary',
12
+    SECONDARY = 'secondary',
13
+    TERTIARY = 'tertiary',
14
+    DESTRUCTIVE = 'destructive'
15
+}
18 16
 
19 17
 /**
20 18
  * The modes of the buttons.

+ 3
- 6
react/features/base/react/types.ts Vedi File

@@ -1,13 +1,10 @@
1
-export interface ButtonProps {
2
-    accessibilityLabel?: string;
1
+import { ButtonProps } from '../components/common/types';
2
+
3
+export interface IButtonProps extends ButtonProps {
3 4
     color?: string;
4
-    disabled?: boolean;
5
-    icon?: JSX.Element;
6
-    label?: string;
7 5
     labelStyle?: Object|undefined;
8 6
     onPress?: Function;
9 7
     style?: Object|undefined;
10
-    type?: string;
11 8
 }
12 9
 
13 10
 export interface IconButtonProps {

react/features/base/styles/functions.web.js → react/features/base/styles/functions.web.ts Vedi File

@@ -1,7 +1,7 @@
1
-// @flow
2
-
3
-import { type StyleType } from './functions.any';
1
+// @ts-ignore
2
+import { StyleType } from './functions.any';
4 3
 
4
+// @ts-ignore
5 5
 export * from './functions.any';
6 6
 
7 7
 /**
@@ -32,7 +32,7 @@ export function getFixedPlatformStyle(style: StyleType): StyleType {
32 32
  * @param {Object} base - The base object containing the `lineHeight` property.
33 33
  * @returns {Object}
34 34
  */
35
-export function withPixelLineHeight(base: Object): Object {
35
+export function withPixelLineHeight(base: any): Object {
36 36
     return {
37 37
         ...base,
38 38
         lineHeight: `${base.lineHeight}px`

react/features/participants-pane/components/breakout-rooms/components/web/AddBreakoutRoomButton.js → react/features/participants-pane/components/breakout-rooms/components/web/AddBreakoutRoomButton.tsx Vedi File

@@ -1,36 +1,27 @@
1
-// @flow
2
-
3
-import { makeStyles } from '@material-ui/core/styles';
1
+/* eslint-disable lines-around-comment */
4 2
 import React, { useCallback } from 'react';
5 3
 import { useTranslation } from 'react-i18next';
6 4
 import { useDispatch } from 'react-redux';
7 5
 
6
+import Button from '../../../../../base/components/common/Button';
7
+import { BUTTON_TYPES } from '../../../../../base/react/constants';
8
+// @ts-ignore
8 9
 import { createBreakoutRoom } from '../../../../../breakout-rooms/actions';
9
-import ParticipantPaneBaseButton from '../../../web/ParticipantPaneBaseButton';
10
-
11
-const useStyles = makeStyles(() => {
12
-    return {
13
-        button: {
14
-            width: '100%'
15
-        }
16
-    };
17
-});
18 10
 
19 11
 export const AddBreakoutRoomButton = () => {
20 12
     const { t } = useTranslation();
21 13
     const dispatch = useDispatch();
22
-    const styles = useStyles();
23 14
 
24 15
     const onAdd = useCallback(() =>
25 16
         dispatch(createBreakoutRoom())
26 17
     , [ dispatch ]);
27 18
 
28 19
     return (
29
-        <ParticipantPaneBaseButton
20
+        <Button
30 21
             accessibilityLabel = { t('breakoutRooms.actions.add') }
31
-            className = { styles.button }
32
-            onClick = { onAdd }>
33
-            {t('breakoutRooms.actions.add')}
34
-        </ParticipantPaneBaseButton>
22
+            fullWidth = { true }
23
+            label = { t('breakoutRooms.actions.add') }
24
+            onClick = { onAdd }
25
+            type = { BUTTON_TYPES.SECONDARY } />
35 26
     );
36 27
 };

+ 0
- 42
react/features/participants-pane/components/breakout-rooms/components/web/AutoAssignButton.js Vedi File

@@ -1,42 +0,0 @@
1
-// @flow
2
-
3
-import { makeStyles } from '@material-ui/styles';
4
-import React, { useCallback } from 'react';
5
-import { useTranslation } from 'react-i18next';
6
-import { useDispatch } from 'react-redux';
7
-
8
-import { autoAssignToBreakoutRooms } from '../../../../../breakout-rooms/actions';
9
-import ParticipantPaneBaseButton from '../../../web/ParticipantPaneBaseButton';
10
-
11
-const useStyles = makeStyles(theme => {
12
-    return {
13
-        button: {
14
-            color: theme.palette.link01,
15
-            width: '100%',
16
-            backgroundColor: 'transparent',
17
-
18
-            '&:hover': {
19
-                backgroundColor: 'transparent'
20
-            }
21
-        }
22
-    };
23
-});
24
-
25
-export const AutoAssignButton = () => {
26
-    const { t } = useTranslation();
27
-    const dispatch = useDispatch();
28
-    const styles = useStyles();
29
-
30
-    const onAutoAssign = useCallback(() => {
31
-        dispatch(autoAssignToBreakoutRooms());
32
-    }, [ dispatch ]);
33
-
34
-    return (
35
-        <ParticipantPaneBaseButton
36
-            accessibilityLabel = { t('breakoutRooms.actions.autoAssign') }
37
-            className = { styles.button }
38
-            onClick = { onAutoAssign }>
39
-            {t('breakoutRooms.actions.autoAssign')}
40
-        </ParticipantPaneBaseButton>
41
-    );
42
-};

+ 27
- 0
react/features/participants-pane/components/breakout-rooms/components/web/AutoAssignButton.tsx Vedi File

@@ -0,0 +1,27 @@
1
+/* eslint-disable lines-around-comment */
2
+import React, { useCallback } from 'react';
3
+import { useTranslation } from 'react-i18next';
4
+import { useDispatch } from 'react-redux';
5
+
6
+import Button from '../../../../../base/components/common/Button';
7
+import { BUTTON_TYPES } from '../../../../../base/react/constants';
8
+// @ts-ignore
9
+import { autoAssignToBreakoutRooms } from '../../../../../breakout-rooms/actions';
10
+
11
+export const AutoAssignButton = () => {
12
+    const { t } = useTranslation();
13
+    const dispatch = useDispatch();
14
+
15
+    const onAutoAssign = useCallback(() => {
16
+        dispatch(autoAssignToBreakoutRooms());
17
+    }, [ dispatch ]);
18
+
19
+    return (
20
+        <Button
21
+            accessibilityLabel = { t('breakoutRooms.actions.autoAssign') }
22
+            fullWidth = { true }
23
+            label = { t('breakoutRooms.actions.autoAssign') }
24
+            onClick = { onAutoAssign }
25
+            type = { BUTTON_TYPES.TERTIARY } />
26
+    );
27
+};

+ 0
- 44
react/features/participants-pane/components/breakout-rooms/components/web/LeaveButton.js Vedi File

@@ -1,44 +0,0 @@
1
-// @flow
2
-
3
-import { makeStyles } from '@material-ui/styles';
4
-import React, { useCallback } from 'react';
5
-import { useTranslation } from 'react-i18next';
6
-import { useDispatch } from 'react-redux';
7
-
8
-import { createBreakoutRoomsEvent, sendAnalytics } from '../../../../../analytics';
9
-import { moveToRoom } from '../../../../../breakout-rooms/actions';
10
-import ParticipantPaneBaseButton from '../../../web/ParticipantPaneBaseButton';
11
-
12
-const useStyles = makeStyles(theme => {
13
-    return {
14
-        button: {
15
-            color: theme.palette.textError,
16
-            backgroundColor: 'transparent',
17
-            width: '100%',
18
-
19
-            '&:hover': {
20
-                backgroundColor: 'transparent'
21
-            }
22
-        }
23
-    };
24
-});
25
-
26
-export const LeaveButton = () => {
27
-    const { t } = useTranslation();
28
-    const dispatch = useDispatch();
29
-    const styles = useStyles();
30
-
31
-    const onLeave = useCallback(() => {
32
-        sendAnalytics(createBreakoutRoomsEvent('leave'));
33
-        dispatch(moveToRoom());
34
-    }, [ dispatch ]);
35
-
36
-    return (
37
-        <ParticipantPaneBaseButton
38
-            accessibilityLabel = { t('breakoutRooms.actions.leaveBreakoutRoom') }
39
-            className = { styles.button }
40
-            onClick = { onLeave }>
41
-            {t('breakoutRooms.actions.leaveBreakoutRoom')}
42
-        </ParticipantPaneBaseButton>
43
-    );
44
-};

+ 30
- 0
react/features/participants-pane/components/breakout-rooms/components/web/LeaveButton.tsx Vedi File

@@ -0,0 +1,30 @@
1
+/* eslint-disable lines-around-comment */
2
+import React, { useCallback } from 'react';
3
+import { useTranslation } from 'react-i18next';
4
+import { useDispatch } from 'react-redux';
5
+
6
+// @ts-ignore
7
+import { createBreakoutRoomsEvent, sendAnalytics } from '../../../../../analytics';
8
+import Button from '../../../../../base/components/common/Button';
9
+import { BUTTON_TYPES } from '../../../../../base/react/constants';
10
+// @ts-ignore
11
+import { moveToRoom } from '../../../../../breakout-rooms/actions';
12
+
13
+export const LeaveButton = () => {
14
+    const { t } = useTranslation();
15
+    const dispatch = useDispatch();
16
+
17
+    const onLeave = useCallback(() => {
18
+        sendAnalytics(createBreakoutRoomsEvent('leave'));
19
+        dispatch(moveToRoom());
20
+    }, [ dispatch ]);
21
+
22
+    return (
23
+        <Button
24
+            accessibilityLabel = { t('breakoutRooms.actions.leaveBreakoutRoom') }
25
+            fullWidth = { true }
26
+            label = { t('breakoutRooms.actions.leaveBreakoutRoom') }
27
+            onClick = { onLeave }
28
+            type = { BUTTON_TYPES.DESTRUCTIVE } />
29
+    );
30
+};

+ 0
- 57
react/features/participants-pane/components/web/FooterButton.js Vedi File

@@ -1,57 +0,0 @@
1
-// @flow
2
-
3
-import { makeStyles } from '@material-ui/styles';
4
-import React from 'react';
5
-
6
-import ParticipantPaneBaseButton from './ParticipantPaneBaseButton';
7
-
8
-type Props = {
9
-
10
-    /**
11
-     * Label used for accessibility.
12
-     */
13
-    accessibilityLabel: String,
14
-
15
-    /**
16
-     * Children of the component.
17
-     */
18
-    children: string | React$Node,
19
-
20
-    /**
21
-     * Button id.
22
-     */
23
-    id?: string,
24
-
25
-    /**
26
-     * Whether or not the button is icon button (no text).
27
-     */
28
-    isIconButton?: boolean,
29
-
30
-    /**
31
-     * Click handler.
32
-     */
33
-    onClick: Function
34
-}
35
-
36
-const useStyles = makeStyles(theme => {
37
-    return {
38
-        button: {
39
-            padding: `${theme.spacing(2)}px`
40
-        }
41
-    };
42
-});
43
-
44
-const FooterButton = ({ accessibilityLabel, children, id, isIconButton = false, onClick }: Props) => {
45
-    const styles = useStyles();
46
-
47
-    return (<ParticipantPaneBaseButton
48
-        accessibilityLabel = { accessibilityLabel }
49
-        className = { isIconButton ? styles.button : '' }
50
-        id = { id }
51
-        onClick = { onClick }>
52
-        {children}
53
-    </ParticipantPaneBaseButton>
54
-    );
55
-};
56
-
57
-export default FooterButton;

+ 0
- 48
react/features/participants-pane/components/web/InviteButton.js Vedi File

@@ -1,48 +0,0 @@
1
-// @flow
2
-
3
-import { makeStyles } from '@material-ui/styles';
4
-import React, { useCallback } from 'react';
5
-import { useTranslation } from 'react-i18next';
6
-import { useDispatch } from 'react-redux';
7
-
8
-import { createToolbarEvent, sendAnalytics } from '../../../analytics';
9
-import { Icon, IconInviteMore } from '../../../base/icons';
10
-import { beginAddPeople } from '../../../invite';
11
-
12
-import ParticipantPaneBaseButton from './ParticipantPaneBaseButton';
13
-
14
-const useStyles = makeStyles(theme => {
15
-    return {
16
-        button: {
17
-            width: '100%',
18
-
19
-            '& > *:not(:last-child)': {
20
-                marginRight: `${theme.spacing(2)}px`
21
-            }
22
-        }
23
-    };
24
-});
25
-
26
-export const InviteButton = () => {
27
-    const dispatch = useDispatch();
28
-    const { t } = useTranslation();
29
-    const styles = useStyles();
30
-
31
-    const onInvite = useCallback(() => {
32
-        sendAnalytics(createToolbarEvent('invite'));
33
-        dispatch(beginAddPeople());
34
-    }, [ dispatch ]);
35
-
36
-    return (
37
-        <ParticipantPaneBaseButton
38
-            accessibilityLabel = { t('participantsPane.actions.invite') }
39
-            className = { styles.button }
40
-            onClick = { onInvite }
41
-            primary = { true }>
42
-            <Icon
43
-                size = { 20 }
44
-                src = { IconInviteMore } />
45
-            <span>{t('participantsPane.actions.invite')}</span>
46
-        </ParticipantPaneBaseButton>
47
-    );
48
-};

+ 32
- 0
react/features/participants-pane/components/web/InviteButton.tsx Vedi File

@@ -0,0 +1,32 @@
1
+/* eslint-disable lines-around-comment */
2
+import React, { useCallback } from 'react';
3
+import { useTranslation } from 'react-i18next';
4
+import { useDispatch } from 'react-redux';
5
+
6
+// @ts-ignore
7
+import { createToolbarEvent, sendAnalytics } from '../../../analytics';
8
+import Button from '../../../base/components/common/Button';
9
+import { IconInviteMore } from '../../../base/icons/svg/index';
10
+import { BUTTON_TYPES } from '../../../base/react/constants';
11
+// @ts-ignore
12
+import { beginAddPeople } from '../../../invite';
13
+
14
+export const InviteButton = () => {
15
+    const dispatch = useDispatch();
16
+    const { t } = useTranslation();
17
+
18
+    const onInvite = useCallback(() => {
19
+        sendAnalytics(createToolbarEvent('invite'));
20
+        dispatch(beginAddPeople());
21
+    }, [ dispatch ]);
22
+
23
+    return (
24
+        <Button
25
+            accessibilityLabel = { t('participantsPane.actions.invite') }
26
+            fullWidth = { true }
27
+            icon = { IconInviteMore }
28
+            label = { t('participantsPane.actions.invite') }
29
+            onClick = { onInvite }
30
+            type = { BUTTON_TYPES.PRIMARY } />
31
+    );
32
+};

+ 0
- 98
react/features/participants-pane/components/web/ParticipantPaneBaseButton.js Vedi File

@@ -1,98 +0,0 @@
1
-// @flow
2
-
3
-import { makeStyles } from '@material-ui/styles';
4
-import React from 'react';
5
-
6
-import participantsPaneTheme from '../../../base/components/themes/participantsPaneTheme.json';
7
-
8
-type Props = {
9
-
10
-    /**
11
-     * Label used for accessibility.
12
-     */
13
-    accessibilityLabel: String,
14
-
15
-    /**
16
-     * Additional class name for custom styles.
17
-     */
18
-    className?: string,
19
-
20
-    /**
21
-     * Children of the component.
22
-     */
23
-    children: string | React$Node,
24
-
25
-    /**
26
-     * Button id.
27
-     */
28
-    id?: string,
29
-
30
-    /**
31
-     * Click handler.
32
-     */
33
-    onClick: Function,
34
-
35
-    /**
36
-     * Whether or not the button should have primary button style.
37
-     */
38
-    primary?: boolean
39
-}
40
-
41
-const useStyles = makeStyles(theme => {
42
-    return {
43
-        button: {
44
-            alignItems: 'center',
45
-            backgroundColor: theme.palette.ui03,
46
-            border: 0,
47
-            borderRadius: `${theme.shape.borderRadius}px`,
48
-            display: 'flex',
49
-            justifyContent: 'center',
50
-            minHeight: '40px',
51
-            padding: `${theme.spacing(2)}px ${theme.spacing(3)}px`,
52
-            ...theme.typography.labelButton,
53
-            lineHeight: `${theme.typography.labelButton.lineHeight}px`,
54
-
55
-            '&:hover': {
56
-                backgroundColor: theme.palette.ui04
57
-            },
58
-
59
-            [`@media (max-width: ${participantsPaneTheme.MD_BREAKPOINT})`]: {
60
-                ...theme.typography.labelButtonLarge,
61
-                lineHeight: `${theme.typography.labelButtonLarge.lineHeight}px`,
62
-                minWidth: '48px',
63
-                minHeight: '48px'
64
-            }
65
-        },
66
-
67
-        buttonPrimary: {
68
-            backgroundColor: theme.palette.action01,
69
-
70
-            '&:hover': {
71
-                backgroundColor: theme.palette.action01Hover
72
-            }
73
-        }
74
-    };
75
-});
76
-
77
-const ParticipantPaneBaseButton = ({
78
-    accessibilityLabel,
79
-    className,
80
-    children,
81
-    id,
82
-    onClick,
83
-    primary = false
84
-}: Props) => {
85
-    const styles = useStyles();
86
-
87
-    return (
88
-        <button
89
-            aria-label = { accessibilityLabel }
90
-            className = { `${styles.button} ${primary ? styles.buttonPrimary : ''} ${className ?? ''}` }
91
-            id = { id }
92
-            onClick = { onClick }>
93
-            {children}
94
-        </button>
95
-    );
96
-};
97
-
98
-export default ParticipantPaneBaseButton;

+ 10
- 10
react/features/participants-pane/components/web/ParticipantsPane.js Vedi File

@@ -3,11 +3,13 @@
3 3
 import { withStyles } from '@material-ui/core';
4 4
 import React, { Component } from 'react';
5 5
 
6
+import Button from '../../../base/components/common/Button';
6 7
 import participantsPaneTheme from '../../../base/components/themes/participantsPaneTheme.json';
7 8
 import { openDialog } from '../../../base/dialog';
8 9
 import { translate } from '../../../base/i18n';
9 10
 import { Icon, IconClose, IconHorizontalPoints } from '../../../base/icons';
10 11
 import { isLocalParticipantModerator } from '../../../base/participants/functions';
12
+import { BUTTON_TYPES } from '../../../base/react/constants';
11 13
 import { connect } from '../../../base/redux';
12 14
 import { isAddBreakoutRoomButtonVisible } from '../../../breakout-rooms/functions';
13 15
 import { MuteEveryoneDialog } from '../../../video-menu/components/';
@@ -21,7 +23,6 @@ import {
21 23
 import { AddBreakoutRoomButton } from '../breakout-rooms/components/web/AddBreakoutRoomButton';
22 24
 import { RoomList } from '../breakout-rooms/components/web/RoomList';
23 25
 
24
-import FooterButton from './FooterButton';
25 26
 import { FooterContextMenu } from './FooterContextMenu';
26 27
 import LobbyParticipants from './LobbyParticipants';
27 28
 import MeetingParticipants from './MeetingParticipants';
@@ -258,21 +259,20 @@ class ParticipantsPane extends Component<Props, State> {
258 259
                     {_showFooter && (
259 260
                         <div className = { classes.footer }>
260 261
                             {_showMuteAllButton && (
261
-                                <FooterButton
262
+                                <Button
262 263
                                     accessibilityLabel = { t('participantsPane.actions.muteAll') }
263
-                                    onClick = { this._onMuteAll }>
264
-                                    {t('participantsPane.actions.muteAll')}
265
-                                </FooterButton>
264
+                                    label = { t('participantsPane.actions.muteAll') }
265
+                                    onClick = { this._onMuteAll }
266
+                                    type = { BUTTON_TYPES.SECONDARY } />
266 267
                             )}
267 268
                             {_showMoreActionsButton && (
268 269
                                 <div className = { classes.footerMoreContainer }>
269
-                                    <FooterButton
270
+                                    <Button
270 271
                                         accessibilityLabel = { t('participantsPane.actions.moreModerationActions') }
272
+                                        icon = { IconHorizontalPoints }
271 273
                                         id = 'participants-pane-context-menu'
272
-                                        isIconButton = { true }
273
-                                        onClick = { this._onToggleContext }>
274
-                                        <Icon src = { IconHorizontalPoints } />
275
-                                    </FooterButton>
274
+                                        onClick = { this._onToggleContext }
275
+                                        type = { BUTTON_TYPES.SECONDARY } />
276 276
                                     <FooterContextMenu
277 277
                                         isOpen = { contextOpen }
278 278
                                         onDrawerClose = { this._onDrawerClose }

+ 1
- 1
tsconfig.json Vedi File

@@ -1,5 +1,5 @@
1 1
 {
2
-    "include": ["react/features/**/*.ts", "react/features/**/*.tsx"],
2
+    "include": ["react/features/**/*.ts", "react/features/**/*.tsx", "./custom.d.ts"],
3 3
     "compilerOptions": {
4 4
         "allowSyntheticDefaultImports": true,
5 5
         "module": "es6",

Loading…
Annulla
Salva