Skip to content

Commit

Permalink
fix: support new ui (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveen Yadav authored Jul 25, 2023
1 parent 6034a3d commit f7f409b
Show file tree
Hide file tree
Showing 41 changed files with 604 additions and 2,095 deletions.
1,179 changes: 73 additions & 1,106 deletions ui/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
},
"dependencies": {
"@hookform/resolvers": "^3.0.1",
"@raystack/apsara": "0.9.7",
"@radix-ui/colors": "^0.1.8",
"@radix-ui/react-form": "^0.0.2",
"@radix-ui/react-icons": "^1.3.0",
"@raystack/apsara": "0.10.5",
"@stitches/react": "^1.2.8",
"@tanstack/react-table": "^8.9.3",
"dotenv": "^16.0.3",
"ramda": "^0.29.0",
"re-resizable": "^6.9.9",
Expand Down
84 changes: 69 additions & 15 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,78 @@
import { Flex } from "@raystack/apsara";
import { Flex, ScrollArea, Sidebar } from "@raystack/apsara";
import "@raystack/apsara/index.css";
import { Outlet } from "react-router-dom";
import "./App.css";
import Layout from "./components/Layout";
import Sidebar from "./components/sidebar/Sidebar";

export type NavigationItemsTypes = {
active?: boolean;
to?: string;
name: string;
icon?: React.ReactNode;
};

const BRAND_NAME = "Shield";
const navigationItems: NavigationItemsTypes[] = [
{
name: "Dashboard",
to: `/console/dashboard`,
},
{
name: "Organisations",
to: `/console/organisations`,
},
{
name: "Projects",
to: `/console/projects`,
},
{
name: "Users",
to: `/console/users`,
},
{
name: "Groups",
to: `/console/groups`,
},
{
name: "Roles",
to: `/console/roles`,
},
];

function App() {
return (
<Layout
sidebar={
<Sidebar>
<Flex direction="column" css={{ width: "100%" }}>
<Sidebar.Header></Sidebar.Header>
<Sidebar.Content></Sidebar.Content>
<div style={{ display: "flex", height: "100vh", overflow: "hidden" }}>
<Sidebar>
<Flex direction="column" style={{ maxWidth: "250px" }}>
<Sidebar.Logo name={BRAND_NAME} />
<Flex
// @ts-ignore
style={{
marginTop: "22px",
maxHeight: "calc(100vh - 120px)",
}}
>
<ScrollArea style={{ paddingRight: "var(--mr-16)", width: "100%" }}>
<Sidebar.Navigations>
{navigationItems.map((nav) => (
<Sidebar.NavigationCell
key={nav.name}
href={nav.to}
active={nav.active}
>
{nav.name}
</Sidebar.NavigationCell>
))}
</Sidebar.Navigations>
</ScrollArea>
</Flex>
<Sidebar.Footer></Sidebar.Footer>
</Sidebar>
}
>
<Outlet />
</Layout>
</Flex>
<Sidebar.Footer></Sidebar.Footer>
</Sidebar>
<Flex style={{ flexGrow: "1", overflow: "auto" }}>
<Outlet />
</Flex>
;
</div>
);
}

Expand Down
56 changes: 56 additions & 0 deletions ui/src/components/CustomField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
FormControl,
FormField,
FormLabel,
FormMessage,
} from "@radix-ui/react-form";
import { Flex, Text, TextField } from "@raystack/apsara";

import { Control, Controller, UseFormRegister } from "react-hook-form";
import { capitalizeFirstLetter } from "~/utils/helper";

type CustomFieldNameProps = {
name: string;
register: UseFormRegister<any>;
control: Control<any, any>;
};

export const CustomFieldName = ({
name,
register,
control,
}: CustomFieldNameProps) => {
return (
<FormField name={name}>
<Flex
gap="medium"
style={{
alignItems: "baseline",
justifyContent: "space-between",
}}
>
<FormLabel>
<Text>{capitalizeFirstLetter(name)}</Text>
</FormLabel>
<FormMessage match="valueMissing">Please enter your {name}</FormMessage>
<FormMessage match="typeMismatch">
Please provide a valid {name}
</FormMessage>
</Flex>
<FormControl asChild>
<Controller
name={name}
control={control}
rules={{ required: true }}
render={({ field }) => (
<TextField {...field} required placeholder={`Enter your ${name}`} />
)}
/>
</FormControl>
</FormField>
);
};

const styles = {
main: { padding: "32px", width: "80%", margin: 0 },
};
16 changes: 10 additions & 6 deletions ui/src/components/DialogTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Flex, Table } from "@raystack/apsara";
import { DataTable, Flex } from "@raystack/apsara";
import { ColumnDef } from "@tanstack/table-core";
import { tableStyle } from "~/styles";

type DialogTableProps = {
columns: ColumnDef<any, any>[];
Expand All @@ -15,11 +14,16 @@ export default function DialogTable({
return (
<Flex
direction="row"
css={{ height: "100%", width: "100%", minWidth: "1020px" }}
style={{ height: "100%", width: "100%", minWidth: "1020px" }}
>
<Table css={tableStyle} columns={columns} data={data ?? []}>
{header && <Table.TopContainer>{header}</Table.TopContainer>}
</Table>
<DataTable
data={data ?? []}
// @ts-ignore
columns={columns}
style={{ width: "100%" }}
>
{header && <DataTable.Toolbar>{header}</DataTable.Toolbar>}
</DataTable>
</Flex>
);
}
28 changes: 8 additions & 20 deletions ui/src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Box, Flex, styled } from "@raystack/apsara";
import { Box, Flex } from "@raystack/apsara";
import React from "react";
import Resizable from "~/components/Resizable";

type Props = {
header?: React.ReactNode;
Expand All @@ -16,25 +15,17 @@ const RESIZABLE = {
maxWidth: "330px",
minHeight: "100%",
};
const ResizableContainer = styled(Resizable, {});

export default function Layout({ header, children, sidebar }: Props) {
return (
<Box>
<Flex direction={"row"} css={containerStyle}>
<ResizableContainer
minWidth={RESIZABLE.minWidth}
maxWidth={RESIZABLE.maxWidth}
minHeight={RESIZABLE.minHeight}
defaultSize={{
width: RESIZABLE.width,
height: RESIZABLE.height,
}}
>
<Flex direction={"row"} style={containerStyle}>
<Flex direction="column" style={{ width: "250px" }}>
{sidebar}
</ResizableContainer>
<Flex as={"main"} direction="column" css={mainContainerStyle}>
</Flex>
<Flex direction="column" style={{ flexGrow: 1, position: "relative" }}>
{header}
<Flex css={contentContainerStyle}>{children}</Flex>
<Flex style={contentContainerStyle}>{children}</Flex>
</Flex>
</Flex>
</Box>
Expand All @@ -49,10 +40,7 @@ const containerStyle = {
alignItems: "stretch",
};

const mainContainerStyle = {
flexGrow: 1,
position: "relative",
};


const contentContainerStyle = {
overflow: "auto",
Expand Down
50 changes: 0 additions & 50 deletions ui/src/components/Resizable.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions ui/src/components/dialog/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export function DialogHeader({ title }: DialogHeaderProps) {
<Flex
justify="between"
align="center"
css={{ padding: "16px 32px", width: "98%", height: "52px" }}
style={{ padding: "16px 32px", width: "98%", height: "52px" }}
>
<Text css={{ fontSize: "14px", fontWeight: "500" }}>{title}</Text>
<Text style={{ fontSize: "14px", fontWeight: "500" }}>{title}</Text>
<Image src="/share.svg" />
</Flex>
);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/sheet/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type SheetFooterProps = {
};

export function SheetFooter({ children, css }: SheetFooterProps) {
return <Flex css={{ ...styles.footer, ...css }}>{children}</Flex>;
return <Flex style={{ ...styles.footer, ...css }}>{children}</Flex>;
}

const styles = {
Expand Down
10 changes: 4 additions & 6 deletions ui/src/components/sheet/header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Flex, Text } from "@raystack/apsara";
import { Cross1Icon } from "@radix-ui/react-icons";
import { Flex, Text } from "@raystack/apsara";

type SheetHeaderProps = {
title: string;
Expand All @@ -8,8 +8,8 @@ type SheetHeaderProps = {

export function SheetHeader({ title, onClick }: SheetHeaderProps) {
return (
<Flex css={styles.header}>
<Text size="4" css={{ fontWeight: "500" }}>
<Flex justify="between" style={styles.header}>
<Text size={4} style={{ fontWeight: "500" }}>
{title}
</Text>
<Cross1Icon onClick={onClick} />
Expand All @@ -19,9 +19,7 @@ export function SheetHeader({ title, onClick }: SheetHeaderProps) {

const styles = {
header: {
flexDirection: "row",
justifyContent: "space-between",
padding: "18px 32px",
borderBottom: "1px solid $gray4",
borderBottom: "1px solid var(--border-base)",
},
};
20 changes: 0 additions & 20 deletions ui/src/components/sidebar/Sidebar.tsx

This file was deleted.

Loading

0 comments on commit f7f409b

Please sign in to comment.