Skip to content

Commit 3b6d917

Browse files
committed
Refactor Button to use styled components
1 parent 9806e1b commit 3b6d917

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/components/Button/Button.scss

Whitespace-only changes.

src/components/Button/Button.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import "./Button.scss";
1+
import { StyledButton } from "./styles";
22

33
interface ButtonProps {
44
name: string;
@@ -8,9 +8,9 @@ interface ButtonProps {
88

99
function Button({ name, width = "100%", onClick }: ButtonProps) {
1010
return (
11-
<button style={{ width }} onClick={onClick}>
11+
<StyledButton width={width} onClick={onClick}>
1212
{name}
13-
</button>
13+
</StyledButton>
1414
);
1515
}
1616
export default Button;

src/components/Button/styles.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import styled from "@emotion/styled";
2+
3+
export const StyledButton = styled.button<{ width: string | number }>`
4+
width: ${(props) =>
5+
typeof props.width === "string" ? props.width : `${props.width}px`};
6+
`;

0 commit comments

Comments
 (0)