update
This commit is contained in:
parent
3f8360f3f3
commit
5cd6b6ef9d
@ -1,5 +1,11 @@
|
|||||||
import { useLayoutEffect, useState, useRef, useEffect } from "react";
|
import { useLayoutEffect, useState, useRef, useEffect } from "react";
|
||||||
import { ArrowBackIcon, ArrowForwardIcon, MenuBookIcon, MyLocationIcon } from "./icons/Icons";
|
import {
|
||||||
|
ArrowBackIcon,
|
||||||
|
ArrowForwardIcon,
|
||||||
|
MenuBookIcon,
|
||||||
|
MyLocationIcon,
|
||||||
|
TitleIcon,
|
||||||
|
} from "./icons/Icons";
|
||||||
|
|
||||||
import structureOriginal from "./structure.json";
|
import structureOriginal from "./structure.json";
|
||||||
|
|
||||||
@ -67,12 +73,14 @@ export function TopicListView({ selectedIndex, onChange }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Layout({ children, title }) {
|
function Layout({ children, title, displayTitle }) {
|
||||||
return (
|
return (
|
||||||
<div className="max-w-7xl mx-auto h-full relative flex flex-col">
|
<div className="max-w-7xl mx-auto h-full relative flex flex-col">
|
||||||
<div className="w-full px-4 py-2 font-medium text-large text-white bg-blue-600">
|
{displayTitle && (
|
||||||
<span>{title}</span>
|
<div className="w-full px-4 py-2 font-medium text-large text-white bg-blue-600">
|
||||||
</div>
|
<span>{title}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -82,6 +90,7 @@ export default function App() {
|
|||||||
const [isMenuOpen, setIsMenuOpen] = useState(true);
|
const [isMenuOpen, setIsMenuOpen] = useState(true);
|
||||||
const [selectedIndex, setSelectedIndex] = useState(null);
|
const [selectedIndex, setSelectedIndex] = useState(null);
|
||||||
const [versions, setVersions] = useState(Array.from({ length: structure.length }, () => 0));
|
const [versions, setVersions] = useState(Array.from({ length: structure.length }, () => 0));
|
||||||
|
const [displayTitle, setDisplayTitle] = useState(true);
|
||||||
|
|
||||||
function handleChange(i) {
|
function handleChange(i) {
|
||||||
setSelectedIndex(i);
|
setSelectedIndex(i);
|
||||||
@ -90,25 +99,38 @@ export default function App() {
|
|||||||
|
|
||||||
if (isMenuOpen) {
|
if (isMenuOpen) {
|
||||||
return (
|
return (
|
||||||
<Layout title="Конспект за Държавен Изпит">
|
<Layout title="Конспект за Държавен Изпит" displayTitle>
|
||||||
<TopicListView selectedIndex={selectedIndex} onChange={handleChange} />
|
<TopicListView selectedIndex={selectedIndex} onChange={handleChange} />
|
||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout title={`${selectedIndex + 1}: ${structure[selectedIndex].title}`}>
|
<Layout
|
||||||
|
title={`${selectedIndex + 1}: ${structure[selectedIndex].title}`}
|
||||||
|
displayTitle={displayTitle}
|
||||||
|
>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<Reader file={structure[selectedIndex].files[versions[selectedIndex]]} />
|
<Reader file={structure[selectedIndex].files[versions[selectedIndex]]} />
|
||||||
<div className="absolute bottom-10 flex justify-between px-4 py-2 w-full z-999">
|
<div className="absolute bottom-10 flex justify-between px-4 py-2 w-full z-999">
|
||||||
<button
|
<div className="flex space-x-2">
|
||||||
className="cursor-pointer p-2 rounded-full bg-blue-600 text-white"
|
<button
|
||||||
onClick={() => {
|
className="cursor-pointer p-2 rounded-full bg-blue-600 text-white"
|
||||||
setIsMenuOpen(true);
|
onClick={() => {
|
||||||
}}
|
setIsMenuOpen(true);
|
||||||
>
|
}}
|
||||||
<MenuBookIcon className="fill-gray-100" />
|
>
|
||||||
</button>
|
<MenuBookIcon className="fill-gray-100" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={`cursor-pointer p-2 rounded-full text-white border ${displayTitle ? "bg-blue-100 border-blue-400" : "bg-gray-100 border-gray-400"}`}
|
||||||
|
onClick={() => {
|
||||||
|
setDisplayTitle((prev) => !prev);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TitleIcon className="fill-gray-600" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
{structure[selectedIndex].files.length > 1 && (
|
{structure[selectedIndex].files.length > 1 && (
|
||||||
<div className="flex space-x-1">
|
<div className="flex space-x-1">
|
||||||
{structure[selectedIndex].files.map((file, vIndex) => (
|
{structure[selectedIndex].files.map((file, vIndex) => (
|
||||||
@ -139,7 +161,7 @@ export default function App() {
|
|||||||
{selectedIndex === 0 ? (
|
{selectedIndex === 0 ? (
|
||||||
<div className="flex-1 border-r border-blue-200" />
|
<div className="flex-1 border-r border-blue-200" />
|
||||||
) : (
|
) : (
|
||||||
<div
|
<button
|
||||||
onClick={() => setSelectedIndex((prev) => prev - 1)}
|
onClick={() => setSelectedIndex((prev) => prev - 1)}
|
||||||
className="border-r border-blue-200 w-1/2 flex-1 px-4 py-2 hover:bg-blue-200 cursor-pointer flex align-center justify-start"
|
className="border-r border-blue-200 w-1/2 flex-1 px-4 py-2 hover:bg-blue-200 cursor-pointer flex align-center justify-start"
|
||||||
>
|
>
|
||||||
@ -147,12 +169,12 @@ export default function App() {
|
|||||||
<span className="ml-2 truncate w-full ">
|
<span className="ml-2 truncate w-full ">
|
||||||
{selectedIndex}: {structure[selectedIndex - 1].title}
|
{selectedIndex}: {structure[selectedIndex - 1].title}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</button>
|
||||||
)}
|
)}
|
||||||
{selectedIndex === structure.length - 1 ? (
|
{selectedIndex === structure.length - 1 ? (
|
||||||
<div className="flex-1" />
|
<div className="flex-1" />
|
||||||
) : (
|
) : (
|
||||||
<div
|
<button
|
||||||
onClick={() => setSelectedIndex((prev) => prev + 1)}
|
onClick={() => setSelectedIndex((prev) => prev + 1)}
|
||||||
className="flex-1 px-4 py-2 hover:bg-blue-200 w-1/2 cursor-pointer flex align-center justify-end"
|
className="flex-1 px-4 py-2 hover:bg-blue-200 w-1/2 cursor-pointer flex align-center justify-end"
|
||||||
>
|
>
|
||||||
@ -160,7 +182,7 @@ export default function App() {
|
|||||||
{selectedIndex + 2}: {structure[selectedIndex + 1].title}
|
{selectedIndex + 2}: {structure[selectedIndex + 1].title}
|
||||||
</span>
|
</span>
|
||||||
<ArrowForwardIcon />
|
<ArrowForwardIcon />
|
||||||
</div>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -14,6 +14,22 @@ export function MyLocationIcon({ className }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function TitleIcon({ className }) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
className={className}
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
height="24px"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
width="24px"
|
||||||
|
fill="inherit"
|
||||||
|
>
|
||||||
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
||||||
|
<path d="M5 4v3h5.5v12h3V7H19V4H5z" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function MenuBookIcon({ className }) {
|
export function MenuBookIcon({ className }) {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user