-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split "Button and Link" component into separate Button and ButtonLink component Made button configurable with a new buttonType property
- Loading branch information
1 parent
a87b2a3
commit 02947d9
Showing
8 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
import styled from "styled-components"; | ||
import { Link } from "react-router-dom"; | ||
|
||
export const StyledLink = styled(Link)` | ||
export const StyledButton = styled.button` | ||
display: inline-block; | ||
padding: 10px 20px; | ||
color: white; | ||
background-color: var(--primary-color); | ||
background-color: var(--default-color); | ||
text-decoration: none; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
&:hover { | ||
background-color: color-mix(in srgb, var(--primary-color) 80%, white); | ||
background-color: color-mix(in srgb, var(--default-color) 80%, white); | ||
} | ||
&:active { | ||
background-color: color-mix(in srgb, var(--primary-color) 70%, black); | ||
background-color: color-mix(in srgb, var(--default-color) 70%, black); | ||
} | ||
`; | ||
|
||
export const StyledDeleteButton = styled.button` | ||
display: inline-block; | ||
padding: 10px 20px; | ||
color: white; | ||
background-color: var(--delete-color); | ||
text-decoration: none; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
&:hover { | ||
background-color: color-mix(in srgb, var(--delete-color) 80%, white); | ||
} | ||
&:active { | ||
background-color: color-mix(in srgb, var(--delete-color) 70%, black); | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
import { ReactNode } from "react"; | ||
import { StyledLink } from "./Button.styled.ts"; | ||
import { StyledButton, StyledDeleteButton } from "./Button.styled.ts"; | ||
|
||
type ButtonProps = { | ||
children: ReactNode; | ||
href: string; | ||
handleOnClick: () => void; | ||
buttonType: "default" | "delete"; | ||
}; | ||
|
||
export default function Button({ children, href }: ButtonProps) { | ||
return <StyledLink to={href}>{children}</StyledLink>; | ||
export default function Button({ | ||
children, | ||
handleOnClick, | ||
buttonType, | ||
}: ButtonProps) { | ||
return ( | ||
<> | ||
{buttonType === "default" && ( | ||
<StyledButton onClick={handleOnClick}>{children}</StyledButton> | ||
)} | ||
{buttonType === "delete" && ( | ||
<StyledDeleteButton onClick={handleOnClick}> | ||
{children} | ||
</StyledDeleteButton> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ReactNode } from "react"; | ||
import { StyledLink } from "./Link.styled.ts"; | ||
|
||
type ButtonLinkProps = { | ||
children: ReactNode; | ||
href: string; | ||
}; | ||
|
||
export default function ButtonLink({ children, href }: ButtonLinkProps) { | ||
return <StyledLink to={href}>{children}</StyledLink>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import styled from "styled-components"; | ||
import { Link } from "react-router-dom"; | ||
|
||
export const StyledLink = styled(Link)` | ||
display: inline-block; | ||
padding: 10px 20px; | ||
color: white; | ||
background-color: var(--primary-color); | ||
text-decoration: none; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
&:hover { | ||
background-color: color-mix(in srgb, var(--primary-color) 80%, white); | ||
} | ||
&:active { | ||
background-color: color-mix(in srgb, var(--primary-color) 70%, black); | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters