Skip to content

Commit 89e1639

Browse files
committed
Improve ui components migration
1 parent 5417b69 commit 89e1639

File tree

12 files changed

+27
-38
lines changed

12 files changed

+27
-38
lines changed

src/components/sdk/LocalVideo/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import styled from 'styled-components';
77
import { useApplyVideoObjectFit } from '../../../hooks/useApplyVideoObjectFit';
88
import { useAudioVideo } from '../../../providers/AudioVideoProvider';
99
import { useLocalVideo } from '../../../providers/LocalVideoProvider';
10-
import { defaultStyledConfig } from '../../../utils/style';
1110
import VideoTile from '../../ui/VideoTile';
1211
import { BaseSdkProps } from '../Base';
1312

@@ -16,7 +15,7 @@ interface Props extends BaseSdkProps {
1615
nameplate?: string;
1716
}
1817

19-
const StyledLocalVideo = styled<any>(VideoTile).withConfig(defaultStyledConfig)`
18+
const StyledLocalVideo = styled<any>(VideoTile)`
2019
${(props) => (!props.active ? 'display: none' : '')};
2120
`;
2221

src/components/sdk/PreviewVideo/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import { useVideoInputs } from '../../../providers/DevicesProvider';
99
import { useLocalVideo } from '../../../providers/LocalVideoProvider';
1010
import { useLogger } from '../../../providers/LoggerProvider';
1111
import { useMeetingManager } from '../../../providers/MeetingProvider';
12-
import { defaultStyledConfig } from '../../../utils/style';
1312
import VideoTile from '../../ui/VideoTile';
1413
import { BaseSdkProps } from '../Base';
1514

16-
const StyledPreview = styled(VideoTile).withConfig(defaultStyledConfig)`
15+
const StyledPreview = styled(VideoTile)`
1716
height: auto;
1817
background: unset;
1918

src/components/ui/Chat/ChatBubble/EditableChatBubble.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const _EditableChatBubble = (args) => {
4242
senderName={args.senderName}
4343
content="This messsage has typos that ned to be fixxed."
4444
showTail={args.showTail}
45-
showName={args.boolean}
45+
showName={args.showName}
4646
saveLabel={args.saveLabel}
4747
cancelLabel={args.cancelLabel}
4848
css={bubbleStyles}

src/components/ui/ContentTile/index.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33

44
import styled from 'styled-components';
55

6-
import { createStyledConfig } from '../../../utils/style';
76
import { VideoTile } from '../../ui/VideoTile';
87

9-
export const ContentTile = styled(VideoTile).withConfig(
10-
createStyledConfig(['nameplate'])
11-
)`
8+
export const ContentTile = styled(VideoTile)`
129
background-color: ${({ theme }) => theme.colors.greys.grey80};
1310
`;
1411

src/components/ui/Flex/docs/common.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import styled from 'styled-components';
66
import { defaultStyledConfig } from '../../../../utils/style';
77
import Flex from '..';
88

9-
export const Child = styled(Flex).withConfig(defaultStyledConfig)`
9+
export const Child = styled(Flex)`
1010
background-color: ${(props) => props.theme.colors.primary.lightest};
1111
color: ${(props) => props.theme.colors.primary.darkest};
1212
margin: 1vh;
@@ -15,14 +15,14 @@ export const Child = styled(Flex).withConfig(defaultStyledConfig)`
1515
width: 20vw;
1616
`;
1717

18-
export const Block = styled(Flex).withConfig(defaultStyledConfig)`
18+
export const Block = styled(Flex)`
1919
background-color: ${(props) => props.theme.colors.primary.lightest};
2020
height: 5vh;
2121
margin: 1rem;
2222
border-radius: 4px;
2323
`;
2424

25-
export const Stack = styled(Flex).withConfig(defaultStyledConfig)`
25+
export const Stack = styled(Flex)`
2626
padding: 1rem 20vw;
2727
`;
2828

src/components/ui/Navbar/Styled.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ export const StyledNavbarItem = styled.div.withConfig(defaultStyledConfig)<
5252
}
5353
`;
5454

55-
export const StyledNavbar = styled(Flex).withConfig(
56-
defaultStyledConfig
57-
)<NavbarProps>`
55+
export const StyledNavbar = styled(Flex)<NavbarProps>`
5856
display: flex;
5957
flex-direction: column;
6058
height: 100%;

src/components/ui/Notification/Styled.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ interface StyledNotificationProps extends NotificationProps {
1414
severity: Severity;
1515
}
1616

17-
export const StyledCloseIconButton = styled(IconButton).withConfig(
18-
defaultStyledConfig
19-
)``;
20-
export const StyledNotificationButton = styled(SecondaryButton).withConfig(
21-
defaultStyledConfig
22-
)``;
17+
export const StyledCloseIconButton = styled(IconButton)``;
18+
export const StyledNotificationButton = styled(SecondaryButton)``;
2319

2420
export const StyledNotification = styled.div.withConfig(
2521
defaultStyledConfig

src/components/ui/NotificationGroup/NotificationGroup.stories.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const AddNotificationButtonGroup = () => {
5454
message:
5555
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.',
5656
autoClose: true,
57+
autoCloseDelay: 2000,
5758
};
5859
return (
5960
<StyledWrapper>

src/components/ui/PopOver/Styled.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ export const StyledPopOverItem = styled.li.withConfig(defaultStyledConfig)`
8787
}
8888
`;
8989

90-
export const StyledSubMenu = styled(StyledPopOverItem).withConfig(
91-
defaultStyledConfig
92-
)`
90+
export const StyledSubMenu = styled(StyledPopOverItem)`
9391
> span {
9492
width: 100%;
9593
height: 100%;

src/components/ui/Radio/Styled.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ export const StyledRadio = styled.div.withConfig(defaultStyledConfig)<any>`
4343
}
4444
`;
4545

46-
export const StyledRadioLabel = styled(StyledRadio).withConfig(
47-
defaultStyledConfig
48-
)<any>`
46+
export const StyledRadioLabel = styled(StyledRadio)<any>`
4947
display: inline-block;
5048
height: 1rem;
5149
position: relative;
@@ -66,9 +64,7 @@ export const StyledRadioLabel = styled(StyledRadio).withConfig(
6664
}
6765
`;
6866

69-
export const StyledRadioIcon = styled(StyledRadio).withConfig(
70-
defaultStyledConfig
71-
)<any>`
67+
export const StyledRadioIcon = styled(StyledRadio)<any>`
7268
display: flex;
7369
align-items: center;
7470
justify-content: center;

src/components/ui/icons/Microphone/Microphone.stories.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ _Microphone.argTypes = {
1515
width: { control: 'text' },
1616
poorConnection: { control: 'boolean' },
1717
muted: { control: 'boolean' },
18+
mutedTitle: { control: 'text' },
19+
unmutedTitle: { control: 'text' },
1820
};
1921

2022
_Microphone.args = {
2123
width: '2rem',
2224
poorConnection: false,
2325
muted: false,
26+
mutedTitle: 'Muted microphone',
27+
unmutedTitle: 'Microphone',
2428
};
2529

2630
_Microphone.story = {

src/utils/style.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ export const absoluteCenter = css`
2626
transform: translate(-50%, -50%);
2727
`;
2828

29-
export const isValidCSSHex = (hex: string) => {
29+
export const isValidCSSHex = (hex: string): boolean => {
3030
// matches 6 digit characters prefixed with a '#'.
3131
return /^#[0-9A-F]{6}$/i.test(hex);
3232
};
3333

34-
export const hexTorgba = (hex: string, alpha: number = 1) => {
34+
export const hexTorgba = (hex: string, alpha: number = 1): string => {
3535
if (!isValidCSSHex(hex)) {
3636
return '';
3737
}
@@ -52,12 +52,13 @@ export const hexTorgba = (hex: string, alpha: number = 1) => {
5252
*/
5353
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
5454
export const createStyledConfig = (additionalProps: string[] = []) => ({
55-
shouldForwardProp: (prop: string) =>
56-
// Native HTML props is forwarded
57-
isPropValid(prop) ||
58-
// Allow additional non-HTML/custom props to be forwarded
59-
additionalProps.includes(prop),
55+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
56+
shouldForwardProp: (prop: string) => {
57+
// Forward custom props
58+
if (additionalProps.includes(prop)) return true;
59+
60+
return isPropValid(prop);
61+
},
6062
});
6163

62-
// Default styled config with no additional props
6364
export const defaultStyledConfig = createStyledConfig();

0 commit comments

Comments
 (0)