-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[www] Sidebar: Add "Expand/Collapse All" button, store state in local…
…Storage (#7019) * First shot * Store state in localStorage * move „Expand/Collapse All“ button to component * fix „Features“ sidebar (item.disableAccordions) * no need to pass down isScrollSync from scrollSyncSidebar to Sidebar, and from Sidebar to Item * no need to pass down activeItemHash from Sidebar to Item, either * rename sectionHash to openSectionHash * console.logs * Butcher site showcase yaml so this builds on Netlify * Try again * Write to local storage on „Collapse All“ * Position „Expand/Collapse All“ button above the sidebar navigation * not floating, prevents the button conflicting with the „selected“ state of the sidebar navigation items * had to revert „hidden until hover“ scrollbar * hide button on mobile * hide button for „Features“ via `disableExpandAll` in `utils/sidebar/item-list` * Only bookkeep items that have subitems ;) * Test if global.localStorage is available Fixes issue with iOS Safari’s private session mode * Move getInitialState up * Update state.expandAll, fixes „Expand/Collapse All“ button behavior * Tidy * Fix isParentOfActiveItem * Make all but the top-level item active link parents bold * Enable accordions for mobile/below presets.Tablet * Fix sidebar mobile height * Compensate for iOS Safari „dead zone“ * Compensate moar
- Loading branch information
Showing
10 changed files
with
374 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { Fragment } from "react" | ||
import GoFold from "react-icons/lib/go/fold" | ||
import GoUnfold from "react-icons/lib/go/unfold" | ||
|
||
import presets, { colors } from "../../utils/presets" | ||
import { scale, options, rhythm } from "../../utils/typography" | ||
|
||
const ExpandAllButton = ({ onClick, expandAll }) => ( | ||
<button | ||
onClick={onClick} | ||
css={{ | ||
...scale(-2 / 3), | ||
lineHeight: 1, | ||
background: `transparent`, | ||
border: `none`, | ||
borderRadius: presets.radius, | ||
color: colors.gatsby, | ||
display: `flex`, | ||
cursor: `pointer`, | ||
alignItems: `center`, | ||
flexGrow: 0, | ||
marginLeft: `auto`, | ||
paddingTop: rhythm(options.blockMarginBottom / 3), | ||
paddingBottom: rhythm(options.blockMarginBottom / 3), | ||
fontFamily: options.systemFontFamily.join(`,`), | ||
textAlign: `left`, | ||
transition: `all .2s`, | ||
"&:hover": { | ||
background: colors.ui.bright, | ||
}, | ||
}} | ||
> | ||
{expandAll ? ( | ||
<Fragment> | ||
<span>Collapse All</span> | ||
<span css={{ ...styles.icon }}> | ||
<GoFold /> | ||
</span> | ||
</Fragment> | ||
) : ( | ||
<Fragment> | ||
<span>Expand All</span> | ||
<span css={{ ...styles.icon }}> | ||
<GoUnfold /> | ||
</span> | ||
</Fragment> | ||
)} | ||
</button> | ||
) | ||
|
||
export default ExpandAllButton | ||
|
||
const styles = { | ||
icon: { | ||
display: `inline-block`, | ||
fontSize: `.9rem`, | ||
marginLeft: 8, | ||
}, | ||
} |
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.