This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
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.
[migrate] Home page & components
- Loading branch information
Showing
12 changed files
with
337 additions
and
146 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { OffcanvasBox, OffcanvasBoxProps } from 'boot-cell'; | ||
import { observable } from 'mobx'; | ||
import { WebCell, attribute, component, observer } from 'web-cell'; | ||
|
||
export interface DrawerProps extends OffcanvasBoxProps {} | ||
|
||
export interface Drawer extends WebCell<DrawerProps> {} | ||
|
||
@component({ | ||
tagName: 'md-drawer', | ||
mode: 'open' | ||
}) | ||
@observer | ||
export class Drawer extends HTMLElement implements WebCell<DrawerProps> { | ||
@attribute | ||
@observable | ||
accessor open = false; | ||
|
||
@observable | ||
accessor narrow = false; | ||
|
||
updateScreen = () => (this.narrow = innerWidth < innerHeight); | ||
|
||
mountedCallback() { | ||
this.updateScreen(); | ||
|
||
globalThis.addEventListener('resize', this.updateScreen); | ||
} | ||
|
||
disconnectedCallback() { | ||
globalThis.removeEventListener('resize', this.updateScreen); | ||
} | ||
|
||
renderContent() { | ||
const { title, narrow, open } = this; | ||
|
||
return ( | ||
<> | ||
<div className="sticky-top shadow-sm d-flex justify-content-between align-items-center p-3"> | ||
{title} | ||
|
||
{narrow && ( | ||
<md-icon-button onClick={() => (this.open = true)}> | ||
<md-icon>menu</md-icon> | ||
</md-icon-button> | ||
)} | ||
</div> | ||
{narrow ? ( | ||
<OffcanvasBox | ||
title={title} | ||
show={open} | ||
onHide={() => (this.open = false)} | ||
> | ||
<slot /> | ||
</OffcanvasBox> | ||
) : ( | ||
<slot /> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
render() { | ||
return ( | ||
<> | ||
<link | ||
rel="stylesheet" | ||
href="https://unpkg.com/[email protected]/dist/css/bootstrap.min.css" | ||
/> | ||
{this.renderContent()} | ||
</> | ||
); | ||
} | ||
} |
Oops, something went wrong.
91f3626
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for material-cell ready!
✅ Preview
https://material-cell-ljl8gb3yh-techquery.vercel.app
Built with commit 91f3626.
This pull request is being automatically deployed with vercel-action