use fragments instead of div to avoid layout problems

This commit is contained in:
Sebastian Sdorra
2020-07-02 11:27:46 +02:00
parent 8c67f6f048
commit e8eaaf486f
2 changed files with 12 additions and 7 deletions

View File

@@ -25,6 +25,11 @@ import React from "react";
import { storiesOf } from "@storybook/react";
import SplitAndReplace from "./SplitAndReplace";
import { Icon } from "@scm-manager/ui-components";
import styled from "styled-components";
const Wrapper = styled.div`
margin: 2rem;
`;
storiesOf("SplitAndReplace", module).add("Simple replacement", () => {
const replacements = [
@@ -41,12 +46,12 @@ storiesOf("SplitAndReplace", module).add("Simple replacement", () => {
];
return (
<>
<div className={"container"}>
<Wrapper>
<SplitAndReplace text={"'So this is it,` said Arthur, 'We are going to die.`"} replacements={replacements} />
</div>
<div className={"container"}>
</Wrapper>
<Wrapper>
<SplitAndReplace text={"'Yes,` said Ford, 'except... no! Wait a minute!`"} replacements={replacements} />
</div>
</Wrapper>
</>
);
});

View File

@@ -39,11 +39,11 @@ const textWrapper = (s: string) => {
const first = s.startsWith(" ") ? <>&nbsp;</> : "";
const last = s.endsWith(" ") ? <>&nbsp;</> : "";
return (
<div>
<>
{first}
{s}
{last}
</div>
</>
);
};
@@ -52,7 +52,7 @@ const SplitAndReplace: FC<Props> = ({ text, replacements }) => {
if (parts.length === 0) {
return <>{parts[0]}</>;
}
return <div className={"media"}>{parts}</div>;
return <>{parts}</>;
};
export default SplitAndReplace;