forked from www/www-new
parent
1a784a9984
commit
13c20dd88f
@ -0,0 +1,32 @@ |
||||
.button, |
||||
.link { |
||||
font-family: "Poppins", "sans-serif"; |
||||
border-radius: calc(20rem / 16); |
||||
background-color: var(--blue-2); |
||||
color: white; |
||||
border: none; |
||||
outline: none; |
||||
transition-duration: 0.3s; |
||||
font-weight: normal; |
||||
text-align: center; |
||||
} |
||||
|
||||
.button:hover, |
||||
.link:hover { |
||||
background-color: var(--teal-2); |
||||
cursor: pointer; |
||||
} |
||||
|
||||
.link { |
||||
text-decoration: none; |
||||
} |
||||
|
||||
.small { |
||||
padding: calc(5rem / 16) calc(30rem / 16); |
||||
font-size: calc(14rem / 16); |
||||
} |
||||
|
||||
.normal { |
||||
padding: calc(10rem / 16) calc(50rem / 16); |
||||
font-size: calc(18rem / 16); |
||||
} |
@ -0,0 +1,40 @@ |
||||
import React, { AnchorHTMLAttributes, ButtonHTMLAttributes } from "react"; |
||||
import styles from "./Button.module.css"; |
||||
|
||||
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { |
||||
isLink?: false; |
||||
} |
||||
|
||||
interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> { |
||||
isLink: true; |
||||
} |
||||
|
||||
type Props = (ButtonProps | LinkProps) & { size?: "small" | "normal" }; |
||||
|
||||
export function Button(props: Props) { |
||||
const btnSize = props.size ? props.size : "normal"; |
||||
if (props.isLink) { |
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { size, isLink, ...otherProps } = props; |
||||
return ( |
||||
<a |
||||
{...otherProps} |
||||
target="_blank" |
||||
className={`${styles.link} ${styles[btnSize]} ${ |
||||
otherProps.className ?? "" |
||||
}`}
|
||||
/> |
||||
); |
||||
} else { |
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { size, isLink, ...otherProps } = props; |
||||
return ( |
||||
<button |
||||
{...otherProps} |
||||
className={`${styles.button} ${styles[btnSize]} ${ |
||||
otherProps.className ?? "" |
||||
}`}
|
||||
/> |
||||
); |
||||
} |
||||
} |
Loading…
Reference in new issue