-
Notifications
You must be signed in to change notification settings - Fork 17
Update Storybook stories with new sidenav display logic #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brentswisher
merged 22 commits into
release/14.0.0
from
bugfix/storybook-side-navigation
Mar 7, 2024
Merged
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3c3c839
fix(sidenav): update react report storybook example
brentswisher 2c6cf64
fix(sidenav): update web component reports storybook example
brentswisher aa5e71b
fix(layout): default sidenav layouts to open
brentswisher 39f71ae
fix(sidenav): update storybook mobile breakpoint to match wc version
brentswisher 45e802f
chore: add changeset
brentswisher 374c8f1
fix(sidenav): default stories to use close button
brentswisher eb988ad
fix(sidenav): update import syntax
brentswisher 7872a6b
Merge branch 'release/14.0.0' into bugfix/storybook-side-navigation
brentswisher 75a5450
refactor: update sidenav stories to use a ResizeObserver
brentswisher 9513276
chore: trigger new build
daneah 030561c
chore(deps-dev): bump vite from 4.3.9 to 4.5.2 (#672)
dependabot[bot] df1137e
DropdownMenuNav: Add pharos-elevation-level-3 token (#670)
mtorres3 e526157
Update link, dropdown-menu-nav, and popover to use a11y-label (#675)
sirrah-tam c9fdffb
Fix the all-contributors badge (#680)
daneah 5812187
Icon: Add "add to folder" icon (#678)
mariadevadoss 3b5432b
chore: version packages (#685)
github-actions[bot] 4fe4245
chore(deps): bump ip from 1.1.8 to 1.1.9 (#687)
dependabot[bot] 3246aed
fix(icon): add media query style for WHCM (#689)
sirrah-tam 826086f
chore(deps): bump es5-ext from 0.10.62 to 0.10.64 (#692)
dependabot[bot] d958675
chore(deps): upgrade to Yarn 4 (#694)
daneah 73369cb
fix: prevent report example from being tree-shaken
brentswisher bca6eeb
Merge branch 'release/14.0.0' into bugfix/storybook-side-navigation
daneah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
--- | ||
'@ithaka/pharos': patch | ||
--- | ||
|
||
Update storybook stories to work with new sidenav display logic |
This file contains hidden or 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 hidden or 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
107 changes: 107 additions & 0 deletions
107
packages/pharos/src/pages/reports/react/ReportExample.tsx
This file contains hidden or 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,107 @@ | ||
import { useEffect, type FC, useState } from 'react'; | ||
import { Sidenav } from './Sidenav'; | ||
import { CreateReportModal } from './CreateReportModal'; | ||
import { ReportsTable } from './ReportsTable'; | ||
import { historyTable, scheduledTable } from '../mocks'; | ||
import logo from '@config/assets/images/reports/jstor-horizontal.svg'; | ||
|
||
import { | ||
PharosHeading, | ||
PharosLink, | ||
PharosButton, | ||
PharosTabs, | ||
PharosTab, | ||
PharosTabPanel, | ||
PharosToaster, | ||
PharosLayout, | ||
} from '../../../react-components'; | ||
|
||
export const ReportExample: FC = () => { | ||
const mobileBreakpoint = 1055; | ||
const [isMobile, setIsMobile] = useState<boolean>(window.innerWidth < mobileBreakpoint); | ||
const [isSidenavDisplayed, setIsSidenavDisplayed] = useState<boolean>(!isMobile); | ||
|
||
useEffect(() => { | ||
const handleResize = () => { | ||
const windowWidth = window.innerWidth; | ||
setIsSidenavDisplayed(windowWidth >= mobileBreakpoint); | ||
setIsMobile(windowWidth < mobileBreakpoint); | ||
}; | ||
|
||
window.addEventListener('resize', handleResize); | ||
|
||
return () => { | ||
window.removeEventListener('resize', handleResize); | ||
}; | ||
}, []); | ||
return ( | ||
<> | ||
<div className="reports-page__container"> | ||
<Sidenav open={isSidenavDisplayed} showCloseButton={isMobile} /> | ||
<main id="main-content"> | ||
<PharosLayout preset="1-col--sidenav" className="reports-page__container--main-content"> | ||
<div className="reports-page__container--top" slot="top"> | ||
<div className="reports-page__container--nav-header"> | ||
<PharosButton | ||
variant="subtle" | ||
icon="menu" | ||
data-sidenav-id="report-sidenav" | ||
a11yLabel="Open side navigation" | ||
/> | ||
<img src={logo} alt="logo" width="96" height="24" /> | ||
<span className="reports-page__separator">/</span> | ||
<PharosHeading level={1} preset="4" noMargin> | ||
Admin | ||
</PharosHeading> | ||
</div> | ||
<PharosButton | ||
variant="subtle" | ||
iconRight="chevron-down" | ||
className="reports-page__button--user" | ||
> | ||
Gerry Larry Burla | ||
</PharosButton> | ||
</div> | ||
<div className="reports-page__container--disclaimer"> | ||
<PharosHeading level={2} preset="5--bold"> | ||
COUNTER 5 Usage Reports | ||
</PharosHeading> | ||
<p> | ||
Welcome to the COUNTER 5 reporting service for participating institutions. JSTOR | ||
offers COUNTER 5 compliant reports for usage beginning January 2019. COUNTER 4 | ||
reports are still available for usage from January 2017 - April 2019 from the{' '} | ||
<PharosLink href="#">COUNTER 4 reporting service</PharosLink>. Please visit our | ||
COUNTER 5 <PharosLink href="#">support page</PharosLink> for more information on | ||
JSTOR usage reports. | ||
</p> | ||
</div> | ||
<div className="reports-page__container--table"> | ||
<PharosButton | ||
className="reports-page__button--create" | ||
data-modal-id="create-report-modal" | ||
> | ||
Create Report | ||
</PharosButton> | ||
<PharosTabs> | ||
<PharosTab id="tab-1" data-panel-id="panel-1"> | ||
Report History | ||
</PharosTab> | ||
<PharosTab id="tab-2" data-panel-id="panel-2"> | ||
Scheduled Reports | ||
</PharosTab> | ||
<PharosTabPanel id="panel-1" slot="panel" style={{ overflow: 'visible' }}> | ||
{ReportsTable(historyTable)} | ||
</PharosTabPanel> | ||
<PharosTabPanel id="panel-2" slot="panel"> | ||
{ReportsTable(scheduledTable)} | ||
</PharosTabPanel> | ||
</PharosTabs> | ||
</div> | ||
</PharosLayout> | ||
</main> | ||
</div> | ||
<PharosToaster></PharosToaster> | ||
<CreateReportModal /> | ||
</> | ||
); | ||
}; |
This file contains hidden or 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 hidden or 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
118 changes: 118 additions & 0 deletions
118
packages/pharos/src/pages/reports/wc/reports-example.ts
This file contains hidden or 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,118 @@ | ||
import { LitElement, html } from 'lit'; | ||
import { ReportsTable } from './reports-table'; | ||
import { historyTable, scheduledTable } from '../mocks'; | ||
import { CreateReportModal } from './create-report-modal'; | ||
import { Sidenav } from './sidenav'; | ||
import logo from '@config/assets/images/reports/jstor-horizontal.svg'; | ||
|
||
class ReportsExample extends LitElement { | ||
override createRenderRoot() { | ||
// Keep example element in the light DOM to allow sharing styles with React story | ||
return this; | ||
} | ||
readonly #mobileBreakpoint = 1055; | ||
isMobile: boolean; | ||
isSidenavDisplayed: boolean; | ||
|
||
static override get properties() { | ||
return { | ||
isMobile: { type: Boolean }, | ||
isSidenavDisplayed: { type: Boolean }, | ||
}; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.isMobile = window.innerWidth < this.#mobileBreakpoint; | ||
this.isSidenavDisplayed = window.innerWidth >= this.#mobileBreakpoint; | ||
} | ||
|
||
override connectedCallback() { | ||
super.connectedCallback(); | ||
window.addEventListener('resize', this.resizeHandler.bind(this)); | ||
} | ||
|
||
override disconnectedCallback() { | ||
window.removeEventListener('resize', this.resizeHandler.bind(this)); | ||
super.disconnectedCallback(); | ||
} | ||
|
||
resizeHandler() { | ||
const windowWidth = window.innerWidth; | ||
this.isSidenavDisplayed = windowWidth >= this.#mobileBreakpoint; | ||
this.isMobile = windowWidth < this.#mobileBreakpoint; | ||
} | ||
|
||
override render() { | ||
return html`<div class="reports-page__container"> | ||
${Sidenav(this.isSidenavDisplayed, this.isMobile)} | ||
<main id="main-content"> | ||
<storybook-pharos-layout | ||
preset="1-col--sidenav" | ||
class="reports-page__container--main-content" | ||
> | ||
<div class="reports-page__container--top" slot="top"> | ||
<div class="reports-page__container--nav-header"> | ||
<storybook-pharos-button | ||
data-sidenav-id="report-sidenav" | ||
variant="subtle" | ||
a11yLabel="Open side navigation" | ||
icon="menu" | ||
></storybook-pharos-button> | ||
<img src="${logo}" alt="logo" width="96" height="24" /> | ||
<span class="reports-page__separator">/</span> | ||
<storybook-pharos-heading level="1" preset="4" no-margin | ||
>Admin</storybook-pharos-heading | ||
> | ||
</div> | ||
<storybook-pharos-button | ||
variant="subtle" | ||
icon-right="chevron-down" | ||
class="reports-page__button--user" | ||
>Gerry Larry Burla | ||
</storybook-pharos-button> | ||
</div> | ||
<div class="reports-page__container--disclaimer"> | ||
<storybook-pharos-heading level="2" preset="5--bold" | ||
>COUNTER 5 Usage Reports</storybook-pharos-heading | ||
> | ||
<p> | ||
Welcome to the COUNTER 5 reporting service for participating institutions. JSTOR | ||
offers COUNTER 5 compliant reports for usage beginning January 2019. COUNTER 4 | ||
reports are still available for usage from January 2017 - April 2019 from the | ||
<storybook-pharos-link href="#">COUNTER 4 reporting service</storybook-pharos-link>. | ||
Please visit our COUNTER 5 | ||
<storybook-pharos-link href="#">support page</storybook-pharos-link> | ||
for more information on JSTOR usage reports. | ||
</p> | ||
</div> | ||
<div class="reports-page__container--table"> | ||
<storybook-pharos-button | ||
class="reports-page__button--create" | ||
data-modal-id="create-report-modal" | ||
>Create Report | ||
</storybook-pharos-button> | ||
<storybook-pharos-tabs> | ||
<storybook-pharos-tab id="tab-1" data-panel-id="panel-1" | ||
>Report History</storybook-pharos-tab | ||
> | ||
<storybook-pharos-tab id="tab-2" data-panel-id="panel-2" | ||
>Scheduled Reports</storybook-pharos-tab | ||
> | ||
<storybook-pharos-tab-panel id="panel-1" slot="panel" style="overflow: visible"> | ||
${ReportsTable(historyTable)} | ||
</storybook-pharos-tab-panel> | ||
<storybook-pharos-tab-panel id="panel-2" slot="panel"> | ||
${ReportsTable(scheduledTable)} | ||
</storybook-pharos-tab-panel> | ||
</storybook-pharos-tabs> | ||
</div> | ||
</storybook-pharos-layout> | ||
</main> | ||
</div> | ||
<storybook-pharos-toaster></storybook-pharos-toaster> | ||
${CreateReportModal()}`; | ||
} | ||
} | ||
|
||
customElements.define('reports-example', ReportsExample); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.