From c08956593dd4f680173f473816c28bba4bff9960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Rodrigues?= <93675410+MarioRodrigues10@users.noreply.github.com> Date: Sun, 26 Nov 2023 18:30:03 +0000 Subject: [PATCH 1/4] chore: standardize buttons using a button component (#571) * chore: use a Button component chore: use a Button component * fix: run formatter * fix: styling problems * fix: implement suggestions * chore: implement suggestions * fix: implement suggestions * fix: implement suggestions * fix: build error * fix: build error * fix: types error in button --- components/Button/index.tsx | 30 +++++++++++++++---- components/Layout/Layout.tsx | 2 +- components/QRScanner/index.jsx | 2 +- layout/Attendee/Profile/Profile.tsx | 12 ++++---- layout/Attendee/Wheel/Wheel.tsx | 14 ++++----- .../components/Challenges/Challenge/index.tsx | 2 +- layout/Hackathon/components/Hero/index.jsx | 2 +- .../components/Regulations/index.jsx | 2 +- layout/Home/components/Hackathon/index.jsx | 2 +- layout/Home/components/Hero/Pitch/index.jsx | 5 ++-- layout/Home/components/Speakers/index.jsx | 5 ++-- layout/Login/components/LoginForm/index.tsx | 4 +-- layout/Product/Product.tsx | 14 ++++----- .../components/ResetPasswordForm/index.tsx | 2 +- layout/SignUp/components/SignUpForm/index.tsx | 8 ++--- layout/Staff/Prize/Prize.tsx | 4 +-- .../components/StaffRedeemButton/index.jsx | 8 +++-- .../dashboard/SponsorBadgeButton/index.jsx | 9 ++++-- .../dashboard/SponsorPrizeButton/index.jsx | 9 ++++-- .../spotlight/SpotlightButton/index.jsx | 9 ++++-- layout/shared/Leaderboard/Leaderboard.tsx | 20 ++++++------- pages/register/[uuid].js | 4 +-- 22 files changed, 99 insertions(+), 70 deletions(-) diff --git a/components/Button/index.tsx b/components/Button/index.tsx index 87dcc5f3..d2ff5b36 100644 --- a/components/Button/index.tsx +++ b/components/Button/index.tsx @@ -1,27 +1,45 @@ -import { ButtonHTMLAttributes } from "react"; +import { ButtonHTMLAttributes, ReactNode } from "react"; -interface Props extends ButtonHTMLAttributes { - text: string; +interface Props extends Omit, "title"> { + title: ReactNode; + description?: string; customStyle?: string; + bold?: boolean; + disabled?: boolean; +} + +interface ButtonTitleProps { + title: ReactNode; + bold?: boolean; } export default function Button({ - text, + title, + description, type, disabled, onClick, customStyle, + bold, + ...rest }: Props) { return ( ); } + +function ButtonTitle({ title, bold }: ButtonTitleProps) { + const className = bold ? "font-ibold" : "font-iregular"; + return
{title}
; +} diff --git a/components/Layout/Layout.tsx b/components/Layout/Layout.tsx index 2a82e41b..21c4feef 100644 --- a/components/Layout/Layout.tsx +++ b/components/Layout/Layout.tsx @@ -174,7 +174,7 @@ function MobileNavbar({ diff --git a/components/QRScanner/index.jsx b/components/QRScanner/index.jsx index 9a043354..5d05d4be 100644 --- a/components/QRScanner/index.jsx +++ b/components/QRScanner/index.jsx @@ -52,7 +52,7 @@ function QRScanner({ {removeClose !== true && ( + + title="SPIN THE WHEEL" + description={`${price} tokens💰`} + bold={true} + />
diff --git a/layout/Challenges/components/Challenges/Challenge/index.tsx b/layout/Challenges/components/Challenges/Challenge/index.tsx index 24935b26..065cdeea 100644 --- a/layout/Challenges/components/Challenges/Challenge/index.tsx +++ b/layout/Challenges/components/Challenges/Challenge/index.tsx @@ -6,7 +6,7 @@ function Action({ text, url }) {
diff --git a/layout/Hackathon/components/Hero/index.jsx b/layout/Hackathon/components/Hero/index.jsx index b360cc59..04adabc4 100644 --- a/layout/Hackathon/components/Hero/index.jsx +++ b/layout/Hackathon/components/Hero/index.jsx @@ -24,7 +24,7 @@ export default function Hero() {
diff --git a/layout/Home/components/Speakers/index.jsx b/layout/Home/components/Speakers/index.jsx index a1ebfccb..12c38d12 100644 --- a/layout/Home/components/Speakers/index.jsx +++ b/layout/Home/components/Speakers/index.jsx @@ -15,8 +15,9 @@ export default function Speakers() {
diff --git a/layout/Login/components/LoginForm/index.tsx b/layout/Login/components/LoginForm/index.tsx index 5f2412a5..7bd2a561 100644 --- a/layout/Login/components/LoginForm/index.tsx +++ b/layout/Login/components/LoginForm/index.tsx @@ -51,10 +51,10 @@ export default function LoginForm() { href="/forgot-password" /> + title="REDEEM" + description={`${product.price} tokens 💰`} + bold={true} + /> )}
diff --git a/layout/ResetPassword/components/ResetPasswordForm/index.tsx b/layout/ResetPassword/components/ResetPasswordForm/index.tsx index c3855666..2a942c19 100644 --- a/layout/ResetPassword/components/ResetPasswordForm/index.tsx +++ b/layout/ResetPassword/components/ResetPasswordForm/index.tsx @@ -96,7 +96,7 @@ export default function ResetPasswordForm() {
+
); } diff --git a/layout/moonstone/sponsor/dashboard/SponsorBadgeButton/index.jsx b/layout/moonstone/sponsor/dashboard/SponsorBadgeButton/index.jsx index 3fb2f6ef..5eb272bd 100644 --- a/layout/moonstone/sponsor/dashboard/SponsorBadgeButton/index.jsx +++ b/layout/moonstone/sponsor/dashboard/SponsorBadgeButton/index.jsx @@ -1,3 +1,5 @@ +import Button from "@components/Button"; + export default function SponsorBadgeButton({ sponsor, all }) { let text = all ? ( <> @@ -8,9 +10,10 @@ export default function SponsorBadgeButton({ sponsor, all }) { ); return (
- +
); } diff --git a/layout/moonstone/sponsor/dashboard/SponsorPrizeButton/index.jsx b/layout/moonstone/sponsor/dashboard/SponsorPrizeButton/index.jsx index ae0e2fde..6fad0b9e 100644 --- a/layout/moonstone/sponsor/dashboard/SponsorPrizeButton/index.jsx +++ b/layout/moonstone/sponsor/dashboard/SponsorPrizeButton/index.jsx @@ -1,9 +1,12 @@ +import Button from "@components/Button"; + export default function SponsorPrizeButton({ prize }) { return (
- +
); } diff --git a/layout/moonstone/sponsor/spotlight/SpotlightButton/index.jsx b/layout/moonstone/sponsor/spotlight/SpotlightButton/index.jsx index 40b85b0c..9c518ce8 100644 --- a/layout/moonstone/sponsor/spotlight/SpotlightButton/index.jsx +++ b/layout/moonstone/sponsor/spotlight/SpotlightButton/index.jsx @@ -1,9 +1,12 @@ +import Button from "@components/Button"; + export default function SpotlightButton() { return (
- +
); } diff --git a/layout/shared/Leaderboard/Leaderboard.tsx b/layout/shared/Leaderboard/Leaderboard.tsx index faf30317..29a45442 100644 --- a/layout/shared/Leaderboard/Leaderboard.tsx +++ b/layout/shared/Leaderboard/Leaderboard.tsx @@ -5,6 +5,7 @@ import { withAuth, useAuth } from "@context/Auth"; import Layout from "@components/Layout"; import { Table } from "./components"; +import Button from "@components/Button"; import Day from "@components/Schedule/Day"; import ErrorMessage from "@components/ErrorMessage"; @@ -130,26 +131,25 @@ function Leaderboard() {
- - + title="HALL OF FAME" + />
{error && } diff --git a/pages/register/[uuid].js b/pages/register/[uuid].js index 728191d7..265df8b3 100644 --- a/pages/register/[uuid].js +++ b/pages/register/[uuid].js @@ -86,9 +86,9 @@ function Register() { onChange={(e) => updatePasswordConfirmation(e.currentTarget.value)} />