Skip to content

Commit

Permalink
Merge pull request #38 from aceleradora-TW/26/pagina-detalhe-tema
Browse files Browse the repository at this point in the history
26/pagina detalhe tema
  • Loading branch information
barbaraanger authored Aug 8, 2024
2 parents d0e2c12 + 5327d18 commit ec55c71
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 26 deletions.
5 changes: 3 additions & 2 deletions src/app/Autoestudo/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export default function Autoestudo() {
}

return (
<Box sx={theme.customStyles.centralizeContent} mx={{xs: 2, sm: 3,md: 6, lg: 8 ,xl: 8 }}>
<Grid container columns={{ xl: 12, lg: 9, md: 6, sm: 3 }} rowSpacing={3}>
<Box sx={theme.customStyles.centralizeContent} >
<Grid container columns={{ xl: 12, lg: 9, md: 6, sm: 3 }} rowSpacing={3}
mx={{xs: 2, sm: 3,md: 6, lg: 8 ,xl: 8 }}>
<Grid item xl={12} lg={9} md={6} sm={3} textAlign={{ xs: 'left', sm: 'center' }}>
<Title text={`Bem vindo ao ${pagina}`} />
</Grid>
Expand Down
109 changes: 109 additions & 0 deletions src/app/[detailingTheme]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"use client";
import { Box, Grid} from "@mui/material";
import React from "react";
import { ApiResponse } from "@/types/type";
import { BaseCard } from "@/components/BaseCard";
import { Title } from "@/components/title";
import { CircularProgress } from "@mui/material";
import { ThemeDescription } from "@/components/Description/ThemeDescription";
import { BreadCrumb } from "@/components/BreadCrumb";
import { theme } from "../config/theme";

export default function Home({
params,
}: {
params: { detailingTheme: string };
}) {
const [renderData, setRenderData] = React.useState<ApiResponse>();
const id = params.detailingTheme;

function extractID(pathname: string) {
const id = pathname.split("-")[0];
return id;
}

function TopicsSeparator(topics: string) {
const topic = topics.split(",");
return topic;
}

React.useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch(`/api/stackbyApi/Themes`, {
method: "GET",
});
const parseData: ApiResponse = await response.json();
setRenderData(parseData);
} catch (error) {
console.error("Error fetching data:", error);
}
};

fetchData();
}, []);

if (!renderData) {
return (
<Box
sx={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "100%",
}}
>
<CircularProgress />
</Box>
);
}
return (
<>
<Box
sx={theme.customStyles.centralizeContent}
>
<Grid container columns={{ xl: 12, lg: 9, md: 6, sm: 3 }} rowSpacing={3}
mx={{ xs: 2, sm: 3, md: 6, lg: 8, xl: 8 }}
>
{renderData &&
renderData.data
.filter((element: any) => element.id === extractID(id))
.map((element: any, index: any) => (
<>
<Grid item xl={12} lg={9} md={6} sm={3}>
<BreadCrumb/>
<Title text={element.field.title} />
</Grid>
<Grid item xl={12} lg={9} md={6} sm={3}>
<ThemeDescription text={element.field.description} />
</Grid>
<Grid item xl={12} lg={9} md={6} sm={3}>
<Title text={"Tópicos"} />
</Grid>
<Grid container spacing={2} >
{TopicsSeparator(element.field.topics).map(
(x: any, y: any) => (
<Grid item xl={3} lg={4} md={4} sm={12} xs={12} key={y}>
<BaseCard
title={x}
description={
TopicsSeparator(
element.field.topicsDescription
)[y]
}
route={
TopicsSeparator(element.field.topicsInfo)[y]
}
/>
</Grid>
)
)}
</Grid>

</>
))}
</Grid>
</Box>
</>
);
}
70 changes: 51 additions & 19 deletions src/app/config/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
PaletteColor,
PaletteColorOptions,
ThemeProvider,
createTheme,
createTheme
} from "@mui/material";

import React from "react";
Expand Down Expand Up @@ -144,19 +144,21 @@ declare module "@mui/material/styles" {
color: string;
};
title: {
textAlign: string,
color: string,
margin: string
textAlign: string;
color: string;
margin: string;
};
breadCrumb: {
textDecoration: string;
color: string;
marginTop: number;
};
centralizeContent: {
display: string,
justifyContent: string,
alignItems: string
display: string;
justifyContent: string;
alignItems: string;
maxWidth: string;
margin: string;
}
};
}
Expand Down Expand Up @@ -272,9 +274,11 @@ declare module "@mui/material/styles" {
marginTop?: number;
};
centralizeContent?: {
display?: string,
justifyContent?: string,
alignItems?: string
display?: string;
justifyContent?: string;
alignItems?: string;
maxWidth?: string;
margin?: string;
}
};
}
Expand Down Expand Up @@ -302,7 +306,7 @@ const theme = createTheme({
padding: 2,
boxShadow: "0em 0em 0.4em rgb(44 44 44 / 40% );",
borderRadius: "6px",
margin: 5,
margin: 0,
},
linkActive: {
borderBottom: "solid",
Expand Down Expand Up @@ -375,7 +379,9 @@ const theme = createTheme({
centralizeContent: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
alignItems: 'center',
maxWidth: '1630px',
margin: '0 auto'
},
cardMedia: {
height: 152,
Expand All @@ -392,8 +398,7 @@ const theme = createTheme({
},
breadCrumb: {
textDecoration: "none",
color: themePalette.title,
marginTop: 11.75,
color: themePalette.title
},
},
palette: {
Expand All @@ -419,26 +424,53 @@ const theme = createTheme({
},
typography: {
h1: {
fontSize: "48px",
lineHeight: 1.16,
fontWeight: 500,
letterSpacing: 0.15,
lineHeight: "normal",
[`@media (min-width:0px)`]: {
fontSize: "1.5rem",
},
[`@media (min-width:600px)`]: {
fontSize: "2rem",
},
[`@media (min-width:900px)`]: {
fontSize: "2.5rem",
},
[`@media (min-width:1200px)`]: {
fontSize: "3rem",
},
[`@media (min-width:1536px)`]: {
fontSize: "3.5rem",
}

},

h2: {
fontSize: "25.6px",
lineHeight: 1.6,
fontWeight: 500,
letterSpacing: 0.15,
[`@media (min-width:0px)`]: {
fontSize: "1.2rem",
},
[`@media (min-width:600px)`]: {
fontSize: "1.4rem",
},
[`@media (min-width:1200px)`]: {
fontSize: "1.6rem",
},
[`@media (min-width:1536px)`]: {
fontSize: "1.6rem",
}
},
body1: {
fontSize: "16px",
fontSize: "1rem",
lineHeight: 1.5,
fontWeight: 400,
letterSpacing: 0.15,

},
caption: {
fontSize: "22px",
fontSize: "1.4rem",
lineHeight: 1.6,
fontWeight: 500,
letterSpacing: 0.15,
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "./globals.css";
import ResponsiveAppBar from "@/components/NavBar";
import { ThemeProvider } from '@mui/material/styles';
import { theme } from "@/app/config/theme";
import { Box } from "@mui/material";

const menuItems = ['Nivelamento', 'Autoestudo']

Expand All @@ -23,7 +24,9 @@ export default function RootLayout({
<html lang="en">
<body className={inter.className}>
<ThemeProvider theme={theme}>
<ResponsiveAppBar list={menuItems}/>
<Box sx={{marginBottom:'80px'}}>
<ResponsiveAppBar list={menuItems}/>
</Box>
{children}
</ThemeProvider>
</body>
Expand Down
9 changes: 6 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ export default function Home() {
}

return (
<Box sx={{...theme.customStyles.centralizeContent, mx: {xs: 2, sm: 3,md: 6, lg: 8 ,xl: 8 }}}>
<Grid container columns={{ xl: 12, lg: 9, md: 6, sm: 3 }} rowSpacing={3}>
<Box sx={theme.customStyles.centralizeContent}>
<Grid container columns={{ xl: 12, lg: 9, md: 6, sm: 3 }} rowSpacing={3}
mx= {{xs: 2, sm: 3,md: 6, lg: 8 ,xl: 8 }}>
<Grid item xl={12} lg={9} md={6} sm={3} textAlign={{ xs: 'left', sm: 'center' }}>
<Title text={`Bem vindo ao ${pagina}`} />
</Grid>
<Grid container spacing={2} >
{renderData.data
.filter((element: DataItem) => element.field.category === pagina)
.map((element: DataItem, index: number) => {
const field = element.field as ThemeField;
return (
<Grid item xl={3} lg={3} md={3} sm={3} key={index}>
<Grid item xl={3} lg={4} md={4} sm={6} xs={12} key={index}>
<BaseCard
title={field.title}
description={field.cardDescription}
Expand All @@ -55,6 +57,7 @@ export default function Home() {
</Grid>
);
})}
</Grid>
</Grid>
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/BreadCrumb/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const BreadCrumb: React.FC = () => {
return (
isValidPage && (
<ThemeConfig>
<Box sx={{marginLeft: 10}}>
<Box >
<Stack spacing={2} sx={theme.customStyles.breadCrumb}>
<Breadcrumbs separator={<NavigateNextIcon fontSize="small" sx={{ color: theme.palette.textColor?.main}} />}
aria-label="trilha de navegação">
Expand Down

0 comments on commit ec55c71

Please sign in to comment.