Comments (3)
Something alongside this
/**
*
* @param items Array of [label, iconName, pageComponent]
* @returns
*/
const getItems = (items: [string, string, JSX.Element][]) => {
return items.map((item, index) => {
return getItem(item[0], index, getIcon(item[1], collapsed), item[2]);
});
};
const items = getItems([
["Common Lore", "CommonLore", <CommonLorePage />],
["Planes of Existence", "Locations", <LocationsPage />],
["Deities", "Deities", <DeitiesPage />],
["Races", "Races", <RacesPage />],
["Tables", "Tables", <TablesPage />],
["Library", "Library", <LibraryPage />],
["Pricing", "Pricing", <PricingPage />],
["Tools", "Tools", <ToolsPage />],
["Homebrews", "Homebrews", <HomebrewsPage />],
["Map Overlay", "MapOverlay", <MapOverlayPage />],
["Map Legend", "MapLegend", <MapLegendPage />],
]);```
from teothe.
import { useEffect, useState } from "react";
import { render } from "react-dom";
import { Menu, Image, Avatar } from "antd";
import Sider from "antd/es/layout/Sider";
import type { MenuProps } from "antd";
import CommonLorePage from "Pages/PageCommonLore";
import DeitiesPage from "Pages/PageDeities";
import TablesPage from "Pages/PageTables";
import LibraryPage from "Pages/PageLibrary";
import MapLegendPage from "Pages/PageMapLegend";
import MapOverlayPage from "Pages/PageMapOverlay";
import LocationsPage from "Pages/PageLocations";
import RacesPage from "Pages/PageRaces";
import HomebrewsPage from "Pages/PageHomebrews";
import PricingPage from "Pages/PageCommonPricing";
import ToolsPage from "Pages/PageTools";
type MenuItem = Required<MenuProps>["items"][number];
function loadPage(pageComponent: React.ReactElement) {
render(pageComponent, document.getElementById("PageContent"));
}
function getIcon(pageName: string, avatarSize: boolean) {
return (
<Avatar
size={avatarSize ? 16 : 24}
src={"./Icons/SideNav/" + pageName + ".svg"}
alt={pageName + " Icon"}
draggable={false}
shape="square"
></Avatar>
);
}
function getItem(
label: React.ReactNode,
key?: React.Key | null,
icon?: React.ReactNode,
children?: any
): MenuItem {
return {
key,
icon,
children,
label,
} as MenuItem;
}
export default function Sidebar() {
const [collapsed, setCollapsed] = useState(false);
useEffect(() => {
loadPage(<CommonLorePage />);
}, []);
/**
*
* @param items Array of [label, iconName, pageComponent]
* @returns
*/
const getItems = (items: [string, string, JSX.Element][]) => {
return items.map((item, index) => {
return getItem(item[0], index, getIcon(item[1], collapsed), item[2]);
});
};
const items = getItems([
["Common Lore", "CommonLore", <CommonLorePage />],
["Planes of Existence", "Locations", <LocationsPage />],
["Deities", "Deities", <DeitiesPage />],
["Races", "Races", <RacesPage />],
["Tables", "Tables", <TablesPage />],
["Library", "Library", <LibraryPage />],
["Pricing", "Pricing", <PricingPage />],
["Tools", "Tools", <ToolsPage />],
["Homebrews", "Homebrews", <HomebrewsPage />],
["Map Overlay", "MapOverlay", <MapOverlayPage />],
["Map Legend", "MapLegend", <MapLegendPage />],
]);
return (
<Sider
collapsible
collapsed={collapsed}
onCollapse={(value) => {
setCollapsed(value);
}}
>
<Image width="200px" height="83px" src="./teothe3K.png" alt="Teothe3K Icon" preview={false} />
<Menu theme="dark" mode="inline" defaultSelectedKeys={["1"]}>
{items.map((item: any) => {
return (
<Menu.Item
key={item.key}
icon={item.icon}
onClick={() => {
loadPage(item.children);
}}
>
{item.label}
</Menu.Item>
);
})}
</Menu>
</Sider>
);
}
Fixed on an older branch, decided not to merge - this doesn't help with the initial rendering problem.
from teothe.
Removed the fixed property from SideNav and children.
from teothe.
Related Issues (20)
- Improve SEO for pages HOT 4
- Fix further global.css and custom css we have HOT 1
- Robots.ts needs to provide an XML for crawlers
- Update function definitions HOT 1
- Navbar MenuItem doesn't appear selected when routed from the URL
- Rewrite pageUpdateCalendar to fit in with the rest of the webapp, regarding layout.tsx and layoutProvider.tsx HOT 1
- CalendarTable responsive cell colouring HOT 2
- Mobile GoUp Caret is not vertically centered. HOT 5
- Merge TODO and remove file. HOT 1
- Share on discord button, and share the paragraph id chain HOT 2
- Fixing divider and divider-like components on following pages
- Add Generators, Quest Idea & NPC HOT 4
- Moon images fail to load when Next/Image HOT 2
- Library buttons spacing
- Implement Achievements page HOT 9
- Copy to clipboard button needs clarification HOT 2
- DMsWorks Tables QOL
- Implement login tokens to pageUpdateCalendar
- Add guilds to the website HOT 3
- Move stuff in the navbar HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from teothe.