We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9806e1b commit 3b6d917Copy full SHA for 3b6d917
3 files changed
src/components/Button/Button.scss
src/components/Button/Button.tsx
@@ -1,4 +1,4 @@
1
-import "./Button.scss";
+import { StyledButton } from "./styles";
2
3
interface ButtonProps {
4
name: string;
@@ -8,9 +8,9 @@ interface ButtonProps {
8
9
function Button({ name, width = "100%", onClick }: ButtonProps) {
10
return (
11
- <button style={{ width }} onClick={onClick}>
+ <StyledButton width={width} onClick={onClick}>
12
{name}
13
- </button>
+ </StyledButton>
14
);
15
}
16
export default Button;
src/components/Button/styles.ts
@@ -0,0 +1,6 @@
+import styled from "@emotion/styled";
+
+export const StyledButton = styled.button<{ width: string | number }>`
+ width: ${(props) =>
5
+ typeof props.width === "string" ? props.width : `${props.width}px`};
6
+`;
0 commit comments