feat(LinkList): add customizable links
This commit is contained in:
parent
d36cec3d31
commit
4e33174ebe
2 changed files with 11 additions and 6 deletions
src
|
@ -1,14 +1,19 @@
|
||||||
import Sites from '@Data/sites.json'
|
import Sites from '@Data/sites.json'
|
||||||
import { Grid } from "@mui/material";
|
import { Grid } from "@mui/material";
|
||||||
import LinkCard from "./linkcard";
|
import LinkCard from "./linkcard";
|
||||||
import { useContext } from 'react';
|
import { useContext, useEffect, useState } from 'react';
|
||||||
import { ConfigurableLinksContext } from '../contexts/ConfiguarableLinksContext';
|
import { ConfigurableLinksContext } from '../contexts/ConfiguarableLinksContext';
|
||||||
|
import { HomepageLink } from '../classes/HomeplageLink';
|
||||||
|
|
||||||
export default function LinkList() {
|
export default function LinkList() {
|
||||||
const {configurableLinks, setConfigurableLinks} = useContext(ConfigurableLinksContext)
|
const [configurableLinks, setConfigurableLinks] = useState<Array<HomepageLink>>(
|
||||||
|
JSON.parse(localStorage.getItem("configurableLinks") as string) as Array<HomepageLink> ??
|
||||||
|
new Array<HomepageLink>
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2} justifyContent={"center"}>
|
||||||
{Sites.sites.map(site => (
|
{Sites.sites.map(site => (
|
||||||
<Grid item key={site.title}>
|
<Grid item key={site.title}>
|
||||||
<LinkCard
|
<LinkCard
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Sites from '@Data/sites.json'
|
import Sites from '@Data/sites.json'
|
||||||
import { Box, Button, debounce, FormLabel, Grid, OutlinedInput, styled, TextField, Typography } from '@mui/material'
|
import { Box, Button, Container, debounce, FormLabel, Grid, OutlinedInput, styled, TextField, Typography } from '@mui/material'
|
||||||
import React, { useContext, useState } from 'react'
|
import React, { useContext, useState } from 'react'
|
||||||
import MenuBar from '../shared/components/MenuBar'
|
import MenuBar from '../shared/components/MenuBar'
|
||||||
import LinkCard from '../shared/components/linkcard'
|
import LinkCard from '../shared/components/linkcard'
|
||||||
|
@ -27,14 +27,14 @@ function App() {
|
||||||
<>
|
<>
|
||||||
<MenuBar />
|
<MenuBar />
|
||||||
<MenuDrawer />
|
<MenuDrawer />
|
||||||
<Box sx={{m: 4}} maxWidth="lg">
|
<Container sx={{ mt: 4, mb: 4 }} maxWidth="lg">
|
||||||
{currentPage === 'home' ? (
|
{currentPage === 'home' ? (
|
||||||
<LinkList />
|
<LinkList />
|
||||||
): null}
|
): null}
|
||||||
{currentPage === 'edit' ? (
|
{currentPage === 'edit' ? (
|
||||||
<SettingsPage />
|
<SettingsPage />
|
||||||
): null}
|
): null}
|
||||||
</Box>
|
</Container>
|
||||||
<AppSnackBar />
|
<AppSnackBar />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue