mirror of
https://github.com/lemeow125/Borrowing-TrackerFrontend.git
synced 2025-06-29 17:05:47 +08:00
Improved login and auth flow
This commit is contained in:
parent
99cd673b12
commit
d878cfb1aa
11 changed files with 249 additions and 99 deletions
65
src/Components/Button/Button.tsx
Normal file
65
src/Components/Button/Button.tsx
Normal file
|
@ -0,0 +1,65 @@
|
|||
import React, { useState } from "react";
|
||||
import styles from "../../styles";
|
||||
import { colors } from "../../styles";
|
||||
|
||||
export interface props {
|
||||
onClick: React.MouseEventHandler<HTMLButtonElement>;
|
||||
label?: string;
|
||||
type: "light" | "dark";
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
export default function Button(props: props) {
|
||||
const [clicked, setClicked] = useState(false);
|
||||
return (
|
||||
<div>
|
||||
<button
|
||||
onClick={props.onClick}
|
||||
onMouseDown={() => {
|
||||
if (!clicked) {
|
||||
setClicked(!clicked);
|
||||
}
|
||||
}}
|
||||
onMouseUp={() => setClicked(false)}
|
||||
onMouseLeave={() => setClicked(false)}
|
||||
style={{
|
||||
borderRadius: 24,
|
||||
minWidth: "128px",
|
||||
maxWidth: "128px",
|
||||
borderColor: colors.button_border,
|
||||
borderStyle: "solid",
|
||||
borderWidth: "2px",
|
||||
paddingBottom: 0,
|
||||
paddingTop: 0,
|
||||
paddingRight: "4px",
|
||||
paddingLeft: "4px",
|
||||
marginBottom: "4px",
|
||||
marginTop: "4px",
|
||||
backgroundColor:
|
||||
props.type == "light"
|
||||
? clicked
|
||||
? colors.button_dark
|
||||
: colors.button_light
|
||||
: clicked
|
||||
? colors.button_light
|
||||
: colors.button_dark,
|
||||
}}
|
||||
>
|
||||
<p
|
||||
style={{
|
||||
...(props.type == "light"
|
||||
? clicked
|
||||
? styles.text_light
|
||||
: styles.text_dark
|
||||
: clicked
|
||||
? styles.text_dark
|
||||
: styles.text_light),
|
||||
...styles.text_S,
|
||||
}}
|
||||
>
|
||||
{props.label}
|
||||
</p>
|
||||
{props.children}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue