Skip to content

Commit

Permalink
HotFix: Fixed Landing Page Menu Buttons (#315)
Browse files Browse the repository at this point in the history
## Changes

- removed extended Prop and included only necessary props for the pixel
buttons
- styling code refactoring
  • Loading branch information
privilegemendes authored Feb 13, 2024
1 parent e1b4343 commit 32c5636
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/components/pixel-button/pixel-button.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { type FC } from "react";
import { styled } from "@mui/material/styles";
import { Button } from "@mui/base";

import { usePlaySFX } from "~/hooks/sounds.js";
import { SelectIcon } from "~/assets/icons/index.js";
import { theme } from "~/styles/theme.js";

interface Props extends React.ComponentProps<typeof Button> {
interface Props {
text: string;
onClick: () => void;
disabled?: boolean;
}

const PixelButtonStyle = styled(Button)({
Expand Down Expand Up @@ -50,18 +53,19 @@ const PixelButtonStyle = styled(Button)({
},
});

export const PixelButton: FC<Props> = ({ text, ...props }) => {
export const PixelButton: FC<Props> = ({ text, onClick, disabled }) => {
const playSfx = usePlaySFX();
const handleClick = async () => {
try {
await playSfx("./sounds/BB_UI_Nav_Click.mp3");
onClick();
} catch (error) {
console.error(error);
}
};

return (
<PixelButtonStyle {...props} onClick={handleClick}>
<PixelButtonStyle disabled={disabled} onClick={handleClick}>
<SelectIcon />
{text}
</PixelButtonStyle>
Expand Down
1 change: 0 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const Homepage = () => {
<PixelButton
onClick={openAboutHandler}
text={text.homepage.about}
sx={styles.aboutButton}
/>
</Stack>
</Stack>
Expand Down
11 changes: 6 additions & 5 deletions src/styles/pages/homepage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type SxProps } from "@mui/material";
import { type SxStyleRecord } from "~/types/sx-style-record.js";
import { zIndex } from "~/styles/z-index.js";
import { theme } from "~/styles";
import { theme } from "~/styles/index.js";

export const styles = {
wrapper: {
Expand Down Expand Up @@ -56,9 +57,9 @@ export const styles = {
"& > button": {
transform: "skew(15deg)",
},
},
aboutButton: {
ml: 2,
"& > button:last-of-type": {
ml: 2,
},
},
buttonText: { textTransform: "none" } satisfies SxProps,
};
} satisfies SxStyleRecord;

0 comments on commit 32c5636

Please sign in to comment.