Remove too specific components

This commit is contained in:
Arnaud 2024-10-23 10:03:24 +02:00
parent 08d6b1f1f7
commit 5b6bf67547
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
11 changed files with 0 additions and 590 deletions

View File

@ -1,30 +0,0 @@
import { Menu } from "lucide-react";
import "./appBar.css";
import { ReactNode } from "react";
type Props = {
/**
* Event triggered when the menu is expanding, after a click on the
* menu button.
*/
onExpand: () => void;
/**
* React node to add to the right part of the application bar
*/
Right: ReactNode;
};
export function AppBar({ onExpand, Right }: Props) {
return (
<div className="appBar">
<div className="appBar-left">
<a className="appBar-burger" onClick={onExpand}>
<Menu size={"1.25rem"} />
</a>
<span>Home</span>
</div>
<div className="appBar-right">{Right}</div>
</div>
);
}

View File

@ -1,32 +0,0 @@
.appBar {
height: 40px;
justify-content: space-between;
border-bottom: 1px solid var(--codex-border-color);
view-transition-name: main-header;
display: flex;
padding: 0.75rem 1.5rem;
}
.appBar-burger {
cursor: pointer;
color: var(--codex-color);
display: flex;
}
.appBar,
.appBar-left,
.appBar-right {
display: flex;
align-items: center;
}
.appBar-left,
.appBar-right {
gap: 0.75rem;
}
@media (min-width: 1000px) {
.appBar-burger {
display: none;
}
}

View File

@ -1,28 +0,0 @@
type Props = {
width?: number;
};
export function LogoInverse({ width = 40 }: Props) {
return (
<svg
width={width}
viewBox="0 0 40 40"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clipPath="url(#clip0_274_4287)">
<path
fillRule="evenodd"
clipRule="evenodd"
d="M19.7001 32.7386C19.7705 32.7792 19.8502 32.8001 19.9306 32.8001C20.0111 32.8001 20.188 32.7225 20.188 32.7225L30.85 26.581C30.8555 26.5783 30.8632 26.5744 30.8706 26.5701C30.942 26.5295 31.0002 26.4707 31.0406 26.4008C31.0819 26.3302 31.1036 26.25 31.1036 26.1685C31.1036 26.1588 31.1032 26.1499 31.1028 26.1432V13.8597C31.1036 13.8486 31.1036 13.8387 31.1036 13.8337L31.1036 13.8324C31.1036 13.7507 31.0818 13.671 31.0413 13.6009C31.0008 13.5302 30.9421 13.4718 30.872 13.4313C30.8644 13.4268 30.8564 13.4225 30.8484 13.4186L20.1868 7.27756C20.179 7.27228 20.1714 7.26767 20.165 7.26389L20.1644 7.26354C20.0937 7.22255 20.0136 7.20151 19.9325 7.20151H19.9306C19.8495 7.20151 19.77 7.22295 19.701 7.26233C19.692 7.26733 19.6837 7.27257 19.6762 7.27763L9.01204 13.4202C9.00655 13.4229 8.99886 13.4269 8.99144 13.4311C8.92049 13.4717 8.86173 13.531 8.82123 13.6011C8.78067 13.6712 8.75879 13.7509 8.75879 13.8327C8.75879 13.8425 8.75919 13.8513 8.75956 13.858V26.1419C8.75876 26.153 8.75878 26.1629 8.75879 26.1679L8.75879 26.1692C8.75879 26.2508 8.78058 26.3312 8.82193 26.4018C8.86238 26.4712 8.92065 26.5296 8.98909 26.5693L8.99047 26.5701L8.99187 26.5708C9.00023 26.5754 9.00781 26.5793 9.01357 26.5822L19.6768 32.7241C19.6818 32.7275 19.6906 32.7332 19.7001 32.7386ZM30.8023 26.4503C30.7969 26.4533 30.7908 26.4564 30.7847 26.4594C30.788 26.4578 30.7915 26.4561 30.7946 26.4544C30.7973 26.4531 30.7999 26.4517 30.8023 26.4503ZM30.9649 26.1472C30.9651 26.1495 30.9652 26.152 30.9653 26.1545C30.9655 26.1589 30.9657 26.1636 30.9657 26.1685C30.9657 26.167 30.9657 26.1655 30.9656 26.164C30.9655 26.158 30.9652 26.1523 30.9649 26.1472ZM20.3983 26.9771L24.3592 29.2549L20.3951 31.538L20.3983 26.9771ZM15.5034 29.2548L19.4645 26.9769L19.4676 31.538L15.5034 29.2548ZM25.7528 23.8924L29.7137 26.1701L25.7497 28.4532L25.7528 23.8924ZM20.3984 25.3628V20.8084L24.3514 23.0856L20.3984 25.3628ZM15.0439 22.2784V17.724L18.9969 20.0012L15.0439 22.2784ZM20.3984 19.1932V14.6388L24.3514 16.916L20.3984 19.1932ZM19.4649 13.0247L15.5038 10.7468L19.468 8.4636L19.4649 13.0247ZM10.1491 26.1701L14.1131 28.4532L14.11 23.8921L10.1491 26.1701ZM24.8194 23.8927L24.8225 28.4527L20.8658 26.1705L24.8194 23.8927ZM15.0438 23.8927L15.0406 28.4527L18.9974 26.1705L15.0438 23.8927ZM26.2198 23.0856L30.178 20.8025V25.3687L26.2198 23.0856ZM9.68483 20.8025V25.3687L13.643 23.0856L9.68483 20.8025ZM15.5111 23.085L19.4644 25.3624V20.8076L15.5111 23.085ZM29.7125 20.0004L25.7529 17.7227V22.2781L29.7125 20.0004ZM10.1503 20.0008L14.1099 22.2785V17.7231L10.1503 20.0008ZM24.8189 17.7232V22.278L20.8656 20.0006L24.8189 17.7232ZM30.178 14.6329V19.1991L26.2198 16.916L30.178 14.6329ZM13.643 16.916L9.68483 19.1991V14.6329L13.643 16.916ZM19.4644 14.6384V19.1928L15.5114 16.9156L19.4644 14.6384ZM29.7141 13.8315L25.7497 11.5482L25.7528 16.1095L29.7141 13.8315ZM14.1135 11.5484L14.1104 16.1095L10.1491 13.8315L14.1135 11.5484ZM24.8225 11.5489L24.8194 16.1089L20.8658 13.8311L24.8225 11.5489ZM18.9974 13.8311L15.0438 16.1089L15.0406 11.5489L18.9974 13.8311ZM24.3596 10.7467L20.3951 8.46359L20.3983 13.0247L24.3596 10.7467Z"
fill="white"
/>
</g>
<defs>
<clipPath id="clip0_274_4287">
<rect width="40" height="40" fill="black" />
</clipPath>
</defs>
</svg>
);
}

View File

@ -1,102 +0,0 @@
import { attributes } from "../utils/attributes";
import "./menu.css";
import { LogoInverse } from "../Logo/LogoInverse";
import { ComponentType, useEffect } from "react";
import { Backdrop } from "../Backdrop/Backdrop";
export type MenuItemComponentProps = {
onClick: () => void;
className: string;
};
export type MenuItem =
| {
type: "separator";
}
| {
type: "menu-item";
Component: ComponentType<MenuItemComponentProps>;
}
| {
type: "menu-title";
title: string;
};
type Props = {
/**
* If true, the menu will be displayed
*/
expanded: boolean;
onClose: () => void;
onOpen?: () => void;
/**
* The menu items to be displayed
*/
items: MenuItem[];
className?: string;
/**
* The application version
*/
version?: string;
};
export function Menu({
expanded,
onClose,
onOpen,
items,
className = "",
version = "",
}: Props) {
useEffect(() => {
if (expanded && onOpen) {
onOpen();
}
}, [expanded, onOpen]);
const renderItem = (i: MenuItem, index: number) => {
switch (i.type) {
case "separator":
return <hr className="menu-item-separator" key={index}></hr>;
case "menu-title":
return (
<small className="menu-title" key={i.title}>
{i.title}
</small>
);
case "menu-item":
return (
<i.Component onClick={onClose} className="menu-item" key={index} />
);
}
};
return (
<>
<Backdrop onClose={onClose} open={expanded} />
<aside
className={`menu ${className}`}
{...attributes({ "aria-expanded": expanded })}
>
<div className="menu-container">
<div className="menu-header">
<LogoInverse width={50} />
<span className="menu-separator">|</span>
<span className="menu-name">Codex</span>
<span className="menu-state">ALPHA {version}</span>
</div>
<div className="menu-items">
{items.map((item, index) => renderItem(item, index))}
</div>
</div>
</aside>
</>
);
}

View File

@ -1,96 +0,0 @@
.menu {
display: flex;
flex-direction: column;
background-color: var(--codex-background-secondary);
border-radius: var(--codex-border-radius);
transform: translatex(-500px);
transition: transform 0.25s;
position: fixed;
min-width: 200px;
z-index: 10;
view-transition-name: main-menu;
height: 100%;
top: 0;
left: 0;
}
.menu-container {
display: flex;
flex-direction: column;
padding: 0.75rem;
flex: 1;
}
.menu-backdrop {
display: none;
}
.menu-items {
flex: 1;
}
.menu[aria-expanded] {
transform: translatex(0);
min-width: 200px;
}
.menu-header {
margin-bottom: 0.75rem;
}
.menu-item,
.menu-header {
display: flex;
align-items: center;
gap: 0.75rem;
}
.menu-item {
padding: 0.75rem;
color: var(--codex-color);
margin-bottom: 0.75rem;
text-decoration: none;
}
.menu-item:hover,
.menu-item.active {
background-color: var(--codex-background-light);
}
.menu-title {
text-transform: uppercase;
padding-top: 0.75rem;
padding-bottom: 0.75rem;
padding-left: 0.75rem;
display: inline-block;
font-weight: 500;
}
.menu-item-separator {
border: 0.1px solid var(--codex-border-color);
width: 100%;
}
.menu-state {
font-size: 0.6rem;
background-color: var(--codex-background-light);
padding: 0.25rem;
border-radius: var(--codex-border-radius);
position: relative;
top: 1px;
}
.menu-footer {
text-align: center;
}
.menu-version {
padding: 0;
}
@media (min-width: 1000px) {
.menu {
transform: translatex(0px);
position: inherit;
}
}

View File

@ -1,42 +0,0 @@
import { ReactNode, useState } from "react";
import { Menu, MenuItem } from "../Menu/Menu";
import { AppBar } from "../AppBar/AppBar";
import "./page.css";
type Props = {
children: ReactNode;
Right: ReactNode;
items: MenuItem[];
version?: string;
};
export function Page({ children, Right, items, version = "" }: Props) {
const [open, setOpen] = useState(false);
const onClose = () => {
setOpen(false);
};
const onExpand = () => {
setOpen(true);
};
return (
<div className="page">
<Menu
expanded={open}
onClose={onClose}
items={items}
version={version}
></Menu>
<main className="page-main">
<AppBar onExpand={onExpand} Right={Right} />
{children}
</main>
</div>
);
}

View File

@ -1,8 +0,0 @@
.page {
display: flex;
flex: 1;
}
.page-main {
flex: 1;
}

View File

@ -19,13 +19,6 @@ export { Backdrop } from "./components/Backdrop/Backdrop";
export { Cell, type CellProps } from "./components/Table/Cell"; export { Cell, type CellProps } from "./components/Table/Cell";
export { Table, type TabSortState } from "./components/Table/Table"; export { Table, type TabSortState } from "./components/Table/Table";
export { Row, type RowProps } from "./components/Table/Row"; export { Row, type RowProps } from "./components/Table/Row";
export {
Menu,
type MenuItem,
type MenuItemComponentProps,
} from "./components/Menu/Menu";
export { AppBar } from "./components/AppBar/AppBar";
export { Page } from "./components/Page/Page";
export { NetworkIndicator } from "./components/NetworkIndicator/NetworkIndicator"; export { NetworkIndicator } from "./components/NetworkIndicator/NetworkIndicator";
export { Tooltip } from "./components/Tooltip/Tooltip"; export { Tooltip } from "./components/Tooltip/Tooltip";
export { Collapse } from "./components/Collapse/Collapse"; export { Collapse } from "./components/Collapse/Collapse";

View File

@ -1,135 +0,0 @@
import type { Meta } from "@storybook/react";
import {
Menu,
MenuItem,
MenuItemComponentProps,
} from "../src/components/Menu/Menu";
import { useState } from "react";
import { fn } from "@storybook/test";
import {
HelpCircle,
Home,
Server,
Settings,
ShoppingBag,
Star,
} from "lucide-react";
import "./Menu.stories.css";
const meta = {
title: "Overlays/Menu",
component: Menu,
parameters: {
layout: "fullscreen",
},
tags: ["autodocs"],
argTypes: {},
args: {
onClose: fn(),
onOpen: fn(),
},
} satisfies Meta<typeof Menu>;
export default meta;
type Props = {
onClose: () => void;
onOpen: () => void;
};
const Template = (p: Props) => {
const [open, setOpen] = useState(false);
const onClose = () => {
p.onClose();
setOpen(false);
};
const onOpen = () => {
setOpen(true);
};
const items = [
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<Home size={"1.25rem"} /> Dashboard
</a>
),
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<Star size={"1.25rem"} /> Favorties
</a>
),
},
{
type: "separator",
},
{
type: "menu-title",
title: "rent",
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<ShoppingBag size={"1.25rem"} /> Purchases
</a>
),
},
{
type: "separator",
},
{
type: "menu-title",
title: "host",
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<Server size={"1.25rem"} /> Availabilities
</a>
),
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<Settings size={"1.25rem"} /> Settings
</a>
),
},
{
type: "separator",
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<HelpCircle size={"1.25rem"} /> Help
</a>
),
},
] satisfies MenuItem[];
return (
<div className="menu-story">
<button onClick={onOpen}>Open menu</button>
<Menu
expanded={open}
onClose={onClose}
onOpen={p.onOpen}
items={items}
className="menu-noSticky"
version="1.0.0"
></Menu>
</div>
);
};
export const Default = Template;

View File

@ -1,7 +0,0 @@
body {
margin: 0;
}
.page {
height: 100vh;
}

View File

@ -1,103 +0,0 @@
import type { Meta, StoryObj } from "@storybook/react";
import { Page } from "../src/components/Page/Page";
import "./Page.stories.css";
import {
Home,
Star,
ShoppingBag,
Server,
Settings,
HelpCircle,
} from "lucide-react";
import { MenuItem, MenuItemComponentProps } from "../src/components/Menu/Menu";
import { NetworkIndicator } from "../src/components/NetworkIndicator/NetworkIndicator";
const meta = {
title: "Layouts/Page",
component: Page,
parameters: {
layout: "fullwidth",
},
tags: ["autodocs"],
argTypes: {},
} satisfies Meta<typeof Page>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {
children: (
<span style={{ padding: "1rem", display: "block" }}>Hello World</span>
),
items: [
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<Home size={"1.25rem"} /> Dashboard
</a>
),
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<Star size={"1.25rem"} /> Favorties
</a>
),
},
{
type: "separator",
},
{
type: "menu-title",
title: "rent",
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<ShoppingBag size={"1.25rem"} /> Purchases
</a>
),
},
{
type: "separator",
},
{
type: "menu-title",
title: "host",
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<Server size={"1.25rem"} /> Availabilities
</a>
),
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<Settings size={"1.25rem"} /> Settings
</a>
),
},
{
type: "separator",
},
{
type: "menu-item",
Component: (p: MenuItemComponentProps) => (
<a {...p}>
<HelpCircle size={"1.25rem"} /> Help
</a>
),
},
] satisfies MenuItem[],
Right: <NetworkIndicator online={true} text="Online" />,
version: "1.0.0",
},
};