-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor view wrappers into a <View> component
- Loading branch information
Showing
11 changed files
with
103 additions
and
83 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,28 @@ | ||
|
||
.view { | ||
height: 100%; | ||
max-height: 100%; | ||
background-color: var(--background); | ||
flex: 1 1 auto; | ||
overflow: auto; | ||
position: relative; | ||
} | ||
|
||
.centered { | ||
display: flex; | ||
justify-content: center; | ||
scrollbar-gutter: stable; | ||
} | ||
|
||
.hasPadding { | ||
padding: 40px; | ||
} | ||
|
||
.viewWithSideNav { | ||
display: flex; | ||
overflow: hidden; | ||
} | ||
|
||
.viewContent { | ||
flex: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import cx from 'classnames'; | ||
|
||
import type SideNav from '../SideNav/SideNav'; | ||
|
||
import styles from './View.module.css'; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
sideNav?: React.ReactElement<typeof SideNav>; | ||
layout?: 'centered'; | ||
hasPadding?: boolean; | ||
className?: string; | ||
}; | ||
|
||
/** | ||
* Default View to be used by all route components | ||
*/ | ||
export default function View(props: Props) { | ||
const viewClassNames = cx(styles.view, { | ||
[styles.viewWithSideNav]: props.sideNav, | ||
[styles.centered]: props.layout === 'centered', | ||
}); | ||
|
||
const contentClassNames = cx(props.className, { | ||
[styles.hasPadding]: props.hasPadding, | ||
}); | ||
|
||
if (props.sideNav) { | ||
return ( | ||
<div className={viewClassNames}> | ||
{props.sideNav} | ||
<div className={`${contentClassNames} ${styles.viewContent}`}> | ||
{props.children} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className={cx(viewClassNames, contentClassNames)}> | ||
{props.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
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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