Skip to content

Commit

Permalink
create generic link component
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoussand committed Jun 26, 2023
1 parent c7c6986 commit be4cd3f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
4 changes: 4 additions & 0 deletions public/product_assets/images/white-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions src/components/ui/Buttons/AppLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Link } from "@mui/material";
import Image from "next/image";

interface IAppLink {
text: string;
link: string;
}

const AppLink: React.FC<IAppLink> = ({ text, link }) => {
return (
<Link
href={link}
sx={{
display: "flex",
width: "fit-content",
textTransform: "uppercase",
color: "white",
padding: "10px 20px",
borderRadius: "75px",
backgroundColor: "primary.main",
":hover": {
backgroundColor: "primary.dark",
},
alignSelf: "center",
gap: "10px",
}}
>
{text}
<Image
src={require("public/product_assets/images/white-arrow.svg")}
alt=""
/>
</Link>
);
};

export default AppLink;
10 changes: 3 additions & 7 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Stack, Container, Fab, Link, List, Paper } from "@mui/material";
import { Stack, Container, List, Paper } from "@mui/material";
import { Box } from "@mui/system";
import { useAtom } from "jotai";
import type { NextPage } from "next";
import Image from "next/image";
import { useEffect } from "react";

import AppBar from "components/ui/AppBar/AppBar";
import AppLink from "src/components/ui/Buttons/AppLink";
import { cartAtom } from "src/store/cart";

const Home: NextPage = () => {
Expand Down Expand Up @@ -54,12 +55,7 @@ const Home: NextPage = () => {
</Paper>
</Box>
</Stack>

<Link href="/fruits">
<Fab color="secondary" variant="extended" size="large">
Je démarre mes courses
</Fab>
</Link>
<AppLink text="Commencer l'expérience" link="/fruits" />
</Stack>
</Container>
</>
Expand Down

0 comments on commit be4cd3f

Please sign in to comment.