-
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.
- Loading branch information
Ross Bulat
committed
Feb 19, 2024
1 parent
db7e647
commit 2052904
Showing
12 changed files
with
318 additions
and
368 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
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,14 @@ | ||
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
import { ComponentBase } from "@polkadot-cloud/react/types"; | ||
|
||
/** | ||
* @name Body | ||
* @summary An element that houses Side and Main. | ||
*/ | ||
export const Body = ({ children, style }: ComponentBase) => ( | ||
<div className="core-body" style={style}> | ||
{children} | ||
</div> | ||
); |
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,19 @@ | ||
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
import { ComponentBase } from "@polkadot-cloud/react/types"; | ||
import type { ForwardedRef } from "react"; | ||
import { forwardRef } from "react"; | ||
|
||
/** | ||
* @name Main | ||
* @summary A column flex wrapper that hosts the main page content. | ||
*/ | ||
export const Main = forwardRef( | ||
({ children, style }: ComponentBase, ref?: ForwardedRef<HTMLDivElement>) => ( | ||
<div className="core-main" ref={ref} style={style}> | ||
{children} | ||
</div> | ||
) | ||
); | ||
Main.displayName = "Main"; |
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,43 @@ | ||
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
import { appendOrEmpty } from "@polkadot-cloud/utils"; | ||
import type { CSSProperties } from "react"; | ||
import { ComponentBase } from "@polkadot-cloud/react/types"; | ||
|
||
export type SideProps = ComponentBase & { | ||
// whether the side menu should be open on smaller screens. | ||
open: boolean; | ||
// whether side menu is in minimised state. | ||
minimised: boolean; | ||
// optional width property to be applied to maximised side. | ||
width?: string | number; | ||
}; | ||
|
||
/** | ||
* @name Side | ||
* @summary An element that houses the side menu and transitions to a toggle-able fixed overlay | ||
* on smaller screens. | ||
* @summary Handles maximised and minimised transitions. | ||
*/ | ||
export const Side = ({ | ||
children, | ||
style, | ||
open, | ||
minimised, | ||
width = "20rem", | ||
}: SideProps) => { | ||
const vars = { "--core-side-width": width } as CSSProperties; | ||
|
||
return ( | ||
<div | ||
style={{ ...vars, ...style }} | ||
className={`core-side${appendOrEmpty(!open, "hidden")}${appendOrEmpty( | ||
minimised, | ||
"minimised" | ||
)}`} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; |
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,63 @@ | ||
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
.page-padding { | ||
padding-left: 1.25rem; | ||
padding-right: 1.25rem; | ||
|
||
/* NOTE: same as `PageWidthSmallThreshold` + 1 constant in `src/consts.ts`. */ | ||
@media (min-width: 826px) { | ||
padding-left: 3.5rem; | ||
padding-right: 3.5rem; | ||
} | ||
|
||
/* NOTE: same as `PageWidthSmallThreshold` + 1 constant in `src/consts.ts`. */ | ||
@media (min-width: 826px) { | ||
padding: 0 5rem 0 2.5rem; | ||
} | ||
} | ||
|
||
.core-body { | ||
position: relative; | ||
display: flex; | ||
flex-grow: 1; | ||
} | ||
|
||
.core-main { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
max-width: 100%; | ||
flex: 1; | ||
} | ||
|
||
.core-side { | ||
z-index: 7; | ||
position: sticky; | ||
top: 0; | ||
height: 100vh; | ||
flex: 0; | ||
display: flex; | ||
flex-direction: column; | ||
overflow: hidden; | ||
transition: all 0.5s cubic-bezier(0.1, 1, 0.2, 1); | ||
|
||
/* maximised by default, or minimised otherwise. */ | ||
min-width: var(--core-side-width); | ||
max-width: var(--core-side-width); | ||
|
||
&.minimised { | ||
min-width: 75px; | ||
max-width: 75px; | ||
} | ||
|
||
@media (max-width: 1150px) { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
|
||
&.hidden { | ||
left: calc(var(--core-side-width) * -1); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.