diff --git a/src/articles/articles.ts b/src/articles/ArticleContext.tsx similarity index 53% rename from src/articles/articles.ts rename to src/articles/ArticleContext.tsx index 255bf33..60a7472 100644 --- a/src/articles/articles.ts +++ b/src/articles/ArticleContext.tsx @@ -1,7 +1,8 @@ +import {createContext, lazy, LazyExoticComponent, PropsWithChildren, useContext, useState} from "react"; import {Path} from "../router/router"; import {MDXContent} from "mdx/types"; -import {lazy, LazyExoticComponent} from "react"; import allBlack from "../img/IMG_3095.jpg"; +import {Reader} from "./Reader"; export interface Article { name: string, @@ -21,4 +22,19 @@ export const ARTICLES: Article[] = [ published: new Date(Date.parse("3/15/2026")), article: lazy(() => import("./mdx/high-school.mdx")) } -]; \ No newline at end of file +] + +const articleContext = + createContext>>([undefined, function(){}]); + +export function useArticle() { + return useContext(articleContext); +} + +export default function ArticleProvider({ children }: PropsWithChildren) { + const state = useState
(undefined); + return + + {children} + ; +} \ No newline at end of file diff --git a/src/articles/ArticlesList.tsx b/src/articles/ArticlesList.tsx index 0038220..b78c022 100644 --- a/src/articles/ArticlesList.tsx +++ b/src/articles/ArticlesList.tsx @@ -1,31 +1,28 @@ -import {Article, ARTICLES} from "./articles"; -import {useState} from "react"; +import {Article, ARTICLES, useArticle} from "./ArticleContext"; import "./list.sass"; import {ReactComponent as BoxSvg} from "../img/blog-box.svg"; import {Reader} from "./Reader"; export function ArticlesList() { - const [reading, setReading] = useState
(null); - return
{ ARTICLES.map(a => - + ) }
- +
} -function BlogBox(props: { article: Article, setReading: (_: Article) => void}) { - const {article, - article: {name, description, thumbnail, published}, - setReading} = props; +function BlogBox(props: { article: Article }) { + const {article, article: {name, description, thumbnail, published} } = props; + + const [, setReading] = useArticle(); return ( + + ) + } + + ) } \ No newline at end of file diff --git a/src/nav/menu.sass b/src/nav/menu.sass index 5b59066..800475c 100644 --- a/src/nav/menu.sass +++ b/src/nav/menu.sass @@ -2,8 +2,15 @@ .menu position: absolute - display: flex - flex-direction: column + z-index: 999 + &, ul + display: flex + flex-direction: column + list-style: none + button + font-weight: bold + text-decoration: underline + font-size: 1rem background: nav.$menu color: white width: 25%