-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce new Scaffold component and update docs
- Loading branch information
Showing
15 changed files
with
186 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
id: 'Scaffold' | ||
title: 'Scaffold' | ||
sidebar_label: 'Scaffold' | ||
sidebar_position: 2.1 | ||
--- | ||
|
||
import Type from '../_type-definitions/ScaffoldProps.md'; | ||
|
||
```ts | ||
import { Scaffold } from '@orfium/toolbox'; | ||
``` | ||
|
||
:::info | ||
Must be a descendant of [`ThemeProvider`](https://designlab.orfium.com/?path=/docs/design-system-themeprovider--setting-up-a-button-example). | ||
::: | ||
|
||
## Description | ||
|
||
A component that provides the basic HTML structure for all Orfium applications. | ||
|
||
## Props | ||
|
||
Ƭ [`ScaffoldProps`](../types/ScaffoldProps) | ||
|
||
<Type /> | ||
|
||
:::warning | ||
While you can pass any valid `ReactElement` to the `navigationSlot` and `headerSlot` props, it is really only intended to be | ||
used with [`Navigation`](./Navigation) and [`TopBar`](./TopBar) respectively. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
id: 'ScaffoldProps' | ||
title: 'ScaffoldProps' | ||
sidebar_label: 'ScaffoldProps' | ||
sidebar_position: 1 | ||
--- | ||
import Type from '../_type-definitions/ScaffoldProps.md'; | ||
|
||
|
||
```ts | ||
import { type ScaffoldProps } from '@orfium/toolbox'; | ||
``` | ||
|
||
### Definition | ||
|
||
<Type /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
| Name | Type | Info | | ||
|:-----------------| :------------- | ----------------------------------------------------------------------------------------- | | ||
| `navigationSlot` | `ReactElement` | This **must** be an instance of [`Navigation`](/docs/api/Components/Navigation) component | | ||
| `headerSlot` | `ReactElement` | This **must** be an instance of [`TopBar`](/docs/api/Components/TopBar) component | | ||
| `children` | `ReactNode` | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
documentation/docs/tutorials/01-Installation and Usage/UI/scaffold-component.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
id: 'Scaffold Component' | ||
sidebar_label: 'Scaffold Component' | ||
sidebar_position: 3 | ||
--- | ||
|
||
# Scaffold Component | ||
|
||
## Overview | ||
|
||
In general, the basic HTML structure of almost all Orfium client apps is the following: | ||
|
||
- The [`Navigation`](../../../api/Components/Navigation.mdx) element on the left | ||
- The [`TopBar`](../../../api/Components/TopBar.mdx) element at the top, on the right of the [`Navigation`](../../../api/Components/Navigation.mdx) element | ||
- The main content below the [`TopBar`](../../../api/Components/TopBar.mdx), on the right of the [`Navigation`](../../../api/Components/Navigation.mdx) element | ||
|
||
![Orfium app structure example](/img/example_structure.png) | ||
|
||
The [`Scaffold`](../../../api/Components/Scaffold.mdx) component provides an out-of-the-box solution for setting up your | ||
app with the aforementioned HTML structure. | ||
|
||
:::info | ||
Using [`Scaffold`](../../../api/Components/Scaffold.mdx) is not required in order to use [`Navigation`](../../../api/Components/Navigation.mdx) and [`TopBar`](../../../api/Components/TopBar.mdx). | ||
::: | ||
|
||
## Usage | ||
|
||
In order to use the [`Scaffold`](../../../api/Components/Scaffold.mdx) component, you only have to import it from `@orfium/toolbox` and add it to the file where you build your product's overall layout. | ||
Keep in mind that `@orfium/ictinus` must be installed in your app. Follow these [steps](https://ictinus.herokuapp.com/?path=/story/guide-getting-started--page) before you proceed. | ||
|
||
```tsx | ||
//... | ||
// highlight-next-line | ||
import { Navigation, Scaffold, TopBar } from '@orfium/toolbox'; | ||
//... | ||
|
||
function Layout() { | ||
// .... | ||
|
||
return ( | ||
<Scaffold | ||
navigationSlot={ | ||
<Navigation | ||
header="Earnings & Reports" | ||
menuItems={regularNavigation} | ||
adminMenuItems={adminNavigation} | ||
adminHeader="Orfium Admin" | ||
adminNavigationURLSegment={routerPaths.admin()} | ||
enableAdminMode={isAdmin} | ||
/> | ||
} | ||
headerSlot={<TopBar />} | ||
> | ||
{children} | ||
</Scaffold> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const Wrapper = styled.div` | ||
height: 100%; | ||
height: 100vh; | ||
display: flex; | ||
`; | ||
|
||
export const LocalNav = styled.div` | ||
position: relative; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const GridContainer = styled.div` | ||
display: grid; | ||
grid-template-columns: auto 1fr; | ||
grid-template-rows: 0fr; | ||
grid-template-areas: | ||
'sidebar header' | ||
'sidebar main' | ||
'sidebar main'; | ||
height: 100vh; | ||
`; | ||
|
||
export const Header = styled.header` | ||
grid-area: header; | ||
position: sticky; | ||
top: 0; | ||
padding: 0 ${({ theme }) => theme.spacing.md}; | ||
`; | ||
|
||
export const Contents = styled.main` | ||
grid-area: main; | ||
position: relative; | ||
padding: ${({ theme }) => theme.spacing.md} ${({ theme }) => theme.spacing.md} | ||
${({ theme }) => theme.spacing.lg}; | ||
`; | ||
|
||
export const SideNav = styled.aside` | ||
grid-area: sidebar; | ||
transition: all 0.2s ease-in-out; | ||
position: relative; | ||
z-index: 101; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { type ReactElement, type ReactNode } from 'react'; | ||
import { Contents, GridContainer, Header, SideNav } from './Scaffold.styles'; | ||
|
||
export type ScaffoldProps = { | ||
navigationSlot: ReactElement; | ||
headerSlot: ReactElement; | ||
children: ReactNode; | ||
}; | ||
|
||
export function Scaffold(props: ScaffoldProps) { | ||
const { navigationSlot, headerSlot, children } = props; | ||
|
||
return ( | ||
<GridContainer> | ||
<SideNav>{navigationSlot}</SideNav> | ||
<Header>{headerSlot}</Header> | ||
<Contents>{children}</Contents> | ||
</GridContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Scaffold'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { DEFAULT_NAVBAR_HEIGHT } from './consts'; | ||
export { Navigation, type MenuItem, type NavigationProps } from './Navigation'; | ||
export { Scaffold, type ScaffoldProps } from './Scaffold'; | ||
export { TopBar, type TopBarProps } from './TopBar'; |