Skip to content

Commit 9769258

Browse files
committed
refactor(required-fields-indicator, global-header, text-editor): replace Box with div
Replaces Box with Div in components that don't properly utilise Box's layout-specific props. This eliminates unnecessary Box component overhead and reduces the bundle size without affecting functionality or styling
1 parent 2e78315 commit 9769258

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/components/form/required-fields-indicator/required-fields-indicator.component.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import React from "react";
22
import styled from "styled-components";
3-
import { MarginProps } from "styled-system";
4-
import Box from "../../box";
3+
import { margin, MarginProps } from "styled-system";
4+
import BaseTheme from "../../../style/themes/base";
55
import StyledTypography from "../../typography/typography.style";
66

77
export interface RequiredIndicatorProps extends MarginProps {
88
children: React.ReactNode;
99
}
1010

11-
const StyledIndicatorContainer = styled(Box)`
11+
const StyledIndicatorContainer = styled.div`
12+
${margin}
13+
1214
${StyledTypography} {
1315
color: var(--colorsUtilityYin090);
1416
}
@@ -20,6 +22,10 @@ const StyledIndicatorContainer = styled(Box)`
2022
}
2123
`;
2224

25+
StyledIndicatorContainer.defaultProps = {
26+
theme: BaseTheme,
27+
};
28+
2329
export default ({ children, ...rest }: RequiredIndicatorProps) => (
2430
<StyledIndicatorContainer {...rest}>{children}</StyledIndicatorContainer>
2531
);

src/components/global-header/global-header.component.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react";
22
import styled from "styled-components";
33
import { PaddingProps, FlexboxProps } from "styled-system";
4-
import Box from "../box";
54
import NavigationBar from "../navigation-bar";
65
import { TagProps } from "../../__internal__/utils/helpers/tags";
76

@@ -15,7 +14,7 @@ export interface GlobalHeaderProps
1514
logo?: React.ReactNode;
1615
}
1716

18-
const StyledLogo = styled(Box)`
17+
const StyledLogo = styled.div`
1918
display: flex;
2019
align-items: center;
2120
margin-left: var(--spacing200);

src/components/text-editor/text-editor.style.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import styled, { css } from "styled-components";
22

33
import { margin, MarginProps } from "styled-system";
4-
import Box from "../box";
54
import addFocusStyling from "../../style/utils/add-focus-styling";
65

76
type StyledTextEditorWrapperProps = MarginProps;
@@ -20,7 +19,7 @@ interface StyledEditorToolbarWrapperProps {
2019
hasWarningOrError?: boolean;
2120
}
2221

23-
export const StyledTextEditor = styled(Box)`
22+
export const StyledTextEditor = styled.div`
2423
position: relative;
2524
`;
2625

0 commit comments

Comments
 (0)