1
Fork 0
mirror of https://github.com/Steffo99/unisteffo.git synced 2024-11-22 16:04:21 +00:00

Add SelectSkin and useSubtitle

This commit is contained in:
Steffo 2021-02-02 16:50:32 +01:00 committed by Stefano Pigozzi
parent b4084fa215
commit a77a10991a
8 changed files with 106 additions and 69 deletions

View file

@ -1,22 +1,43 @@
import React, {useState} from "react";
import {Bluelib} from "bluelib/lib/components";
import {Router} from "@reach/router";
import React, {Fragment, useState} from "react";
import {BaseLink, Bluelib, Main} from "bluelib/lib/components";
import {Router, } from "@reach/router";
import Home from "./routes/Home";
import Error404 from "./routes/Error404";
import Gestinfo from "./routes/Gestinfo";
import style from "./App.module.css";
import MainTitle from "./components/MainTitle";
import ContextSetSubtitle from "./contexts/ContextSetSubtitle";
import Footer from "./components/Footer";
export default function App() {
const [skin, setSkin] = useState("rygblue");
const [subtitle, setSubtitle] = useState(null);
return (
<ContextSetSubtitle.Provider value={setSubtitle}>
<Bluelib skin={skin} className={style.app}>
<Router>
<Home path={"/"}/>
<Router primary={false}>
<MainTitle default={true} subtitle={subtitle}/>
</Router>
<Main>
<Router primary={true}>
<Home path={"/"} skin={skin} setSkin={setSkin}/>
<Gestinfo path={"/gestinfo"}/>
<Error404 default/>
</Router>
</Main>
<Router primary={false}>
<Footer default={true}/>
</Router>
</Bluelib>
</ContextSetSubtitle.Provider>
);
}

View file

@ -1,24 +0,0 @@
import React from "react";
import {Main} from "bluelib/lib/components";
import MainTitle from "./MainTitle";
import PropTypes from "prop-types";
import Footer from "./Footer";
export default function Page({children, subtitle}) {
return (
<div>
<MainTitle subtitle={subtitle}/>
<Main>
{children}
</Main>
<Footer/>
</div>
)
}
Page.propTypes = {
children: PropTypes.node,
subtitle: PropTypes.node,
}

View file

@ -0,0 +1,14 @@
import React, {useContext} from "react";
import ContextBluelibSkin from "bluelib/lib/contexts/ContextBluelibSkin";
export default function SelectSkin({skin, setSkin}) {
return (
<span>
<select value={skin} onChange={(event) => setSkin(event.target.value)}>
<option value={null}>Foglio di Carta</option>
<option value={"rygblue"}>Blu Reale</option>
</select>
</span>
);
}

View file

@ -0,0 +1,9 @@
import {createContext} from "react";
function defaultSetter() {
throw new Error("No subtitle setter found.")
}
export default createContext(defaultSetter);

11
src/hooks/useSubtitle.js Normal file
View file

@ -0,0 +1,11 @@
import React, {useContext, useEffect} from "react";
import ContextSetSubtitle from "../contexts/ContextSetSubtitle";
export default function useSubtitle(node) {
const setSubtitle = useContext(ContextSetSubtitle);
useEffect(() => {
setSubtitle(node);
}, [])
}

View file

@ -1,23 +1,19 @@
import React from "react";
import {Paragraph, Box, Title, Color, BaseLink} from "bluelib/lib/components";
import Page from "../components/Page";
import {Paragraph, Color} from "bluelib/lib/components";
import TitleBox from "../components/TitleBox";
import TitleSplit from "../components/TitleSplit";
import useSubtitle from "../hooks/useSubtitle";
export default function Error404() {
useSubtitle(<Color value={"red"}>Errore 404</Color>);
return (
<Page>
<TitleSplit title={<Color value={"red"}>Non trovato</Color>}>
<TitleBox title={<Color value={"red"}>404</Color>}>
<article>
<TitleBox title={<Color value={"red"}>Pagina non trovata</Color>}>
<Paragraph>
Mi spiace, ma la pagina che hai richiesto non sembra esistere :(
</Paragraph>
<Paragraph>
<BaseLink href={"/"}> Torna alla home</BaseLink>
</Paragraph>
</TitleBox>
</TitleSplit>
</Page>
</article>
)
}

View file

@ -1,7 +1,6 @@
import React from "react";
import {Split, Aside, Anchor, Help, Blockquote, Title, Separator, Code, Color, Underline as U, BaseLink as A, Paragraph as P, Bold as B, Italic as I, ListItem as LI, Table} from "bluelib/lib/components";
import LatexMath from "bluelib/lib/components/LatexMath";
import Page from "../../components/Page";
import TitleSplit from "../../components/TitleSplit";
import TitleBox from "../../components/TitleBox";
import IR from "./abbr/IR";
@ -12,19 +11,20 @@ import Ononimi from "./abbr/Ononimi";
import UIN from "./abbr/UIN";
import Regex from "./abbr/Regex";
import Glob from "./abbr/Glob";
import PlusLI from "../../components/PlusLI";
import MinusLI from "../../components/MinusLI";
import Predicato from "./abbr/Predicato";
import Todo from "../../components/Todo";
import IDF from "./abbr/IDF";
import TF from "./abbr/TF";
import TFIDF from "./abbr/TFIDF";
import RSV from "./abbr/RSV";
import useSubtitle from "../../hooks/useSubtitle";
export default function Gestinfo() {
useSubtitle("Gestione dell'informazione");
return (
<Page subtitle={"Gestione dell'informazione"}>
<article>
<Split>
<TitleBox title={"Di cosa si tratta?"}>
<P>
@ -892,6 +892,6 @@ export default function Gestinfo() {
</P>
</TitleBox>
</Page>
</article>
)
}

View file

@ -1,14 +1,16 @@
import React from "react";
import {Split, Size, Color, Anchor, BaseLink as A, Paragraph as P, Bold as B, Italic as I, ListItem as LI} from "bluelib/lib/components";
import Page from "../components/Page";
import TitleSplit from "../components/TitleSplit";
import TitleBox from "../components/TitleBox";
import Todo from "../components/Todo";
import useSubtitle from "../hooks/useSubtitle";
import SelectSkin from "../components/SelectSkin";
export default function Home() {
export default function Home({skin, setSkin}) {
useSubtitle(<span>Appunti open source di <A href={"https://steffo.eu"}>Steffo</A></span>);
return (
<Page subtitle={<span>Appunti open source di <A href={"https://steffo.eu"}>Steffo</A></span>}>
<article>
<Split>
<TitleBox title={"Unisteffo"}>
<P>
@ -17,27 +19,35 @@ export default function Home() {
<P>
Se trovi un errore negli appunti, o un bug del sito, per favore <Anchor href={"https://github.com/Steffo99/appuntiweb/issues/new"}>segnalamelo su GitHub</Anchor>!
</P>
</TitleBox>
<TitleBox title={"Tema"}>
<P>
<Todo>Molte pagine non sono disponibili in quanto il sito è in fase di rinnovo.</Todo>
Se i colori ti deconcentrano, non ti piacciono, o vuoi stampare alcune di queste pagine, puoi cambiare tema del sito qui:
</P>
<P>
<SelectSkin skin={skin} setSkin={setSkin}/>
</P>
</TitleBox>
</Split>
<TitleSplit title={"Università"}>
<TitleBox title={"Primo anno"}>
<ul>
<LI><Size value={"l"}><A href={"/analisi"} disabled={true}>Analisi matematica</A></Size></LI>
<LI><Size value={"l"}><A href={"/algebra"} disabled={true}>Algebra lineare</A></Size></LI>
<LI><Size value={"l"}><A href={"/algoritmi"} disabled={true}>Algoritmi e strutture dati</A></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://github.com/Steffo99/appunti-universitari/tree/master/2018_Analisi1"}>Analisi matematica</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://github.com/Steffo99/appunti-universitari/tree/master/2018_AlgebraLineare"}>Algebra lineare</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://github.com/Steffo99/appunti-universitari/blob/master/2018_ArchitetturaDeiCalcolatori/08_AppuntiEDeduzioni.md"}>Architettura dei calcolatori</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://github.com/Steffo99/appunti-universitari/tree/master/2018_AlgoritmiEStruttureDati"}>Algoritmi e strutture dati</Anchor></Size></LI>
</ul>
</TitleBox>
<TitleBox title={"Secondo anno"}>
<ul>
<LI><Size value={"l"}><A href={"/fisica"} disabled={true}>Fisica</A></Size></LI>
<LI><Size value={"l"}><A href={"/statistica"} disabled={true}>Statistica ed elementi di probabilità</A></Size></LI>
<LI><Size value={"l"}><A href={"/apprendimento"} disabled={true}>Apprendimento ed evoluzione in sistemi artificiali</A></Size></LI>
<LI><Size value={"l"}><A href={"/basididati"} disabled={true}>Basi di dati</A></Size></LI>
<LI><Size value={"l"}><A href={"/calcolo"} disabled={true}>Calcolo numerico</A></Size></LI>
<LI><Size value={"l"}><A href={"/oli"} disabled={true}>Ottimizzazione lineare intera</A></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://old.uni.steffo.eu/#/fisica"}>Fisica</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://github.com/Steffo99/appunti-universitari/tree/master/2019_ProgrammazioneAdOggetti"}>Programmazione ad oggetti</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://old.uni.steffo.eu/#/statistica"}>Statistica ed elementi di probabilità</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://github.com/Steffo99/appunti-universitari/tree/master/2019_SistemiOperativi"}>Sistemi operativi</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://old.uni.steffo.eu/#/apprendimento"}>Apprendimento ed evoluzione in sistemi artificiali</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://old.uni.steffo.eu/#/basididati"}>Basi di dati</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://old.uni.steffo.eu/#/calcolonumerico"}>Calcolo numerico</Anchor></Size></LI>
<LI><Size value={"l"}><Anchor href={"https://old.uni.steffo.eu/#/ottimizzazionelineare"}>Ottimizzazione lineare intera</Anchor></Size></LI>
</ul>
</TitleBox>
<TitleBox title={"Terzo anno"}>
@ -46,6 +56,6 @@ export default function Home() {
</ul>
</TitleBox>
</TitleSplit>
</Page>
</article>
)
}