Skip to content

Commit d781dd6

Browse files
author
Kubit
committed
Improve replaceContent
1 parent d07b071 commit d781dd6

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

src/components/storybook/replaceContent/replaceContent.styled.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled, { css } from 'styled-components';
33
export const ReplaceContentStyled = styled.div<{
44
width?: string;
55
height?: string;
6+
margin?: string;
67
backgroundColor?: string;
78
}>`
89
display: flex;
@@ -12,6 +13,7 @@ export const ReplaceContentStyled = styled.div<{
1213
gap: 1rem;
1314
width: ${({ width }) => width || '100%'};
1415
height: ${({ height }) => height || '200px'};
16+
margin: ${({ margin }) => margin || '0px'};
1517
padding: 20px;
1618
background-color: ${({ backgroundColor }) => backgroundColor || 'rgb(234 240 254)'};
1719
color: #236df6;

src/components/storybook/replaceContent/replaceContent.tsx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,30 @@ interface IReplaceContent extends AriaType {
99
children?: React.ReactNode;
1010
width?: string;
1111
height?: string;
12+
margin?: string;
1213
id?: string;
1314
role?: ROLES;
1415
as?: React.ElementType;
1516
}
1617

17-
export const ReplaceContent = ({ children, ...props }: IReplaceContent): JSX.Element => {
18-
return (
19-
<ReplaceContentStyled as={props.as} {...props}>
20-
<img alt="" height={48} src={ICONS.ICON_REPLACE} width={48} />
21-
{!children ? (
22-
<>
23-
<span>Replace here your Content</span>
24-
</>
25-
) : (
26-
children
27-
)}
28-
</ReplaceContentStyled>
29-
);
30-
};
18+
export const ReplaceContent = React.forwardRef(
19+
(
20+
{ children, ...props }: IReplaceContent,
21+
ref: React.ForwardedRef<HTMLDivElement>
22+
): JSX.Element => {
23+
return (
24+
<ReplaceContentStyled as={props.as} {...props} ref={ref}>
25+
<img alt="" height={48} src={ICONS.ICON_REPLACE} width={48} />
26+
{!children ? (
27+
<>
28+
<span>Replace here your Content</span>
29+
</>
30+
) : (
31+
children
32+
)}
33+
</ReplaceContentStyled>
34+
);
35+
}
36+
);
37+
38+
ReplaceContent.displayName = 'ReplaceContent';

0 commit comments

Comments
 (0)