-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Dropdown Menu to the mobile IDE View #1513
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
ghalestrilo
merged 31 commits into
processing:develop
from
ghalestrilo:feature/mobile-header-dropdown-menu
Aug 3, 2020
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
ac0c519
:construction: create <Dropdown /> component
ghalestrilo b3e88aa
Merge branch 'develop' of https://github.com/processing/p5.js-web-edi…
ghalestrilo 24e6b36
:bento: create <MoreIcon />
ghalestrilo ca88c4e
:construction: put an invisible <Dropdown /> on MobileIDEView
ghalestrilo 91a766d
:construction: import dropdown list style from scss
ghalestrilo c58cdc2
:construction: add navigation elements to the dropdown menu
ghalestrilo 371e4cc
:alembic: create <OverlayManager /> component
ghalestrilo 9f8b41c
:sparkles: make dropdown menu open and close
ghalestrilo 9bebf9f
:twisted_rightwards_arrows: merge from develop
ghalestrilo 0a065cb
:broom: unhide sidebar
ghalestrilo f7d0631
:ok_hand: remove isRequired from consoleEvents
ghalestrilo 77a40a9
:ok_hand: rename last menu option to 'Original Editor'
ghalestrilo 4abdc65
:twisted_rightwards_arrows: merge from develop
ghalestrilo f5e901a
:ok_hand: add CodeIcon to icons.jsx
ghalestrilo d2dcc1f
:ok_hand: restore Console.jsx classes
ghalestrilo dd37c77
:ok_hand: remove eslint-disable-lines
ghalestrilo f9c0e80
:bug: restore package-lock.json
ghalestrilo b8bdfd9
Merge branch 'develop' into feature/mobile-header-dropdown-menu
ghalestrilo 8339be1
:recycle: create useHideOnBlur hook
ghalestrilo 8da6497
:recycle: create useAsModal HOC
ghalestrilo e430652
:recycle: make dropdown left/rightable
ghalestrilo 7c2a624
:firetruck: restore devtools sidebar
ghalestrilo 10ccc19
:bug: update mobile nav paths
ghalestrilo ea9a2f9
:recycle: make li into styled component
ghalestrilo 8acd6ec
:ok_hand: move hoc to components folder
ghalestrilo 8225807
:ok_hand: subst left/right props with align prop on <Dropdown />
ghalestrilo 7272afe
Merge branch 'develop' into feature/mobile-header-dropdown-menu
catarak ab93a4c
:ok_hand: make dropdown list toggle on enter/click
ghalestrilo ed989ee
Merge branch 'develop' of https://github.com/processing/p5.js-web-edi…
ghalestrilo 78d4fc4
:ok_hand: remove eslint disable lines
ghalestrilo e1fd49b
:bug: fix dropdown defaulting to open
ghalestrilo 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
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,92 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Link } from 'react-router'; | ||
import styled from 'styled-components'; | ||
import { remSize, prop, common } from '../theme'; | ||
import IconButton from './mobile/IconButton'; | ||
import Button from '../common/Button'; | ||
|
||
const DropdownWrapper = styled.ul` | ||
background-color: ${prop('Modal.background')}; | ||
border: 1px solid ${prop('Modal.border')}; | ||
box-shadow: 0 0 18px 0 ${prop('shadowColor')}; | ||
color: ${prop('primaryTextColor')}; | ||
|
||
position: absolute; | ||
right: ${props => (props.right ? 0 : 'initial')}; | ||
left: ${props => (props.left ? 0 : 'initial')}; | ||
|
||
${props => (props.align === 'right' && 'right: 0;')} | ||
${props => (props.align === 'left' && 'left: 0;')} | ||
|
||
|
||
text-align: left; | ||
width: ${remSize(180)}; | ||
display: flex; | ||
flex-direction: column; | ||
height: auto; | ||
z-index: 9999; | ||
border-radius: ${remSize(6)}; | ||
|
||
& li:first-child { border-radius: ${remSize(5)} ${remSize(5)} 0 0; } | ||
& li:last-child { border-radius: 0 0 ${remSize(5)} ${remSize(5)}; } | ||
|
||
& li:hover { | ||
|
||
background-color: ${prop('Button.hover.background')}; | ||
color: ${prop('Button.hover.foreground')}; | ||
|
||
& button, & a { | ||
color: ${prop('Button.hover.foreground')}; | ||
} | ||
} | ||
|
||
li { | ||
height: ${remSize(36)}; | ||
cursor: pointer; | ||
display: flex; | ||
align-items: center; | ||
|
||
& button, | ||
& a { | ||
color: ${prop('primaryTextColor')}; | ||
width: 100%; | ||
text-align: left; | ||
padding: ${remSize(8)} ${remSize(16)}; | ||
} | ||
} | ||
`; | ||
|
||
// TODO: Add Icon to the left of the items in the menu | ||
// const MaybeIcon = (Element, label) => Element && <Element aria-label={label} />; | ||
|
||
const Dropdown = ({ items, align }) => ( | ||
<DropdownWrapper align={align} > | ||
{/* className="nav__items-left" */} | ||
{items && items.map(({ title, icon, href }) => ( | ||
<li key={`nav-${title && title.toLowerCase()}`}> | ||
<Link to={href}> | ||
{/* {MaybeIcon(icon, `Navigate to ${title}`)} */} | ||
{title} | ||
</Link> | ||
</li> | ||
)) | ||
} | ||
</DropdownWrapper> | ||
); | ||
|
||
Dropdown.propTypes = { | ||
align: PropTypes.oneOf(['left', 'right']), | ||
items: PropTypes.arrayOf(PropTypes.shape({ | ||
action: PropTypes.func, | ||
icon: PropTypes.func, | ||
href: PropTypes.string | ||
})), | ||
}; | ||
|
||
Dropdown.defaultProps = { | ||
items: [], | ||
align: null | ||
}; | ||
|
||
export default Dropdown; |
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,27 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { createPortal } from 'react-dom'; | ||
|
||
const OverlayManager = ({ overlay, hideOverlay }) => { | ||
// const [visible, trigger, setRef] = useModalBehavior(); | ||
|
||
const jsx = ( | ||
<React.Fragment> | ||
{/* <div ref={setRef} > | ||
{visible && <Dropdown items={headerNavOptions} />} | ||
</div> */} | ||
</React.Fragment> | ||
); | ||
|
||
return jsx && createPortal(jsx, document.body); | ||
}; | ||
|
||
|
||
OverlayManager.propTypes = { | ||
overlay: PropTypes.string, | ||
hideOverlay: PropTypes.func.isRequired, | ||
}; | ||
|
||
OverlayManager.defaultProps = { overlay: null }; | ||
|
||
export default OverlayManager; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { useModalBehavior } from '../utils/custom-hooks'; | ||
|
||
export default (component) => { | ||
const [visible, trigger, setRef] = useModalBehavior(); | ||
|
||
const wrapper = () => <div ref={setRef}> {visible && component} </div>; // eslint-disable-line | ||
|
||
return [trigger, wrapper]; | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -34,7 +34,8 @@ class App extends React.Component { | |
render() { | ||
return ( | ||
<div className="app"> | ||
{this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />} | ||
{/* FIXME: Remove false */} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming you want to remove this for this PR! |
||
{false && this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />} | ||
{this.props.children} | ||
</div> | ||
); | ||
|
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
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
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.