Skip to content
Snippets Groups Projects
Commit bab8ddab authored by Ray Schamp's avatar Ray Schamp
Browse files

Clean up menu positioning

parent e33d7326
No related branches found
No related tags found
No related merge requests found
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
.menu { .menu {
/* blocklyToolboxDiv is 40 */ /* blocklyToolboxDiv is 40 */
z-index: 50; z-index: 50;
top: 31px;
} }
.menu-bar-item { .menu-bar-item {
......
...@@ -23,7 +23,7 @@ import communityIcon from './icon--see-community.svg'; ...@@ -23,7 +23,7 @@ import communityIcon from './icon--see-community.svg';
import dropdownCaret from '../language-selector/dropdown-caret.svg'; import dropdownCaret from '../language-selector/dropdown-caret.svg';
import scratchLogo from './scratch-logo.svg'; import scratchLogo from './scratch-logo.svg';
const MenuBarItemTooltip = ({id, place="bottom", children}) => ( const MenuBarItemTooltip = ({id, place = 'bottom', children}) => (
<ComingSoonTooltip <ComingSoonTooltip
className={styles.comingSoon} className={styles.comingSoon}
place={place} place={place}
...@@ -40,6 +40,45 @@ MenuBarItemTooltip.propTypes = { ...@@ -40,6 +40,45 @@ MenuBarItemTooltip.propTypes = {
place: PropTypes.oneOf(['top', 'bottom', 'left', 'right']) place: PropTypes.oneOf(['top', 'bottom', 'left', 'right'])
}; };
const MenuItemTooltip = ({id, children}) => (
<ComingSoonTooltip
className={styles.comingSoon}
place="right"
tooltipClassName={styles.comingSoonTooltip}
tooltipId={id}
>
{children}
</ComingSoonTooltip>
);
MenuItemTooltip.propTypes = {
children: PropTypes.node,
id: PropTypes.string
};
const MenuBarMenu = ({
children,
onRequestClose,
open,
place = 'right'
}) => (
<Menu
className={styles.menu}
open={open}
place={place}
onRequestClose={onRequestClose}
>
{children}
</Menu>
);
MenuBarMenu.propTypes = {
children: PropTypes.node,
onRequestClose: PropTypes.func,
open: PropTypes.bool,
place: PropTypes.oneOf(['left', 'right'])
};
const MenuBar = props => ( const MenuBar = props => (
<Box className={styles.menuBar}> <Box className={styles.menuBar}>
<div className={styles.mainMenu}> <div className={styles.mainMenu}>
...@@ -65,17 +104,22 @@ const MenuBar = props => ( ...@@ -65,17 +104,22 @@ const MenuBar = props => (
onMouseUp={props.onClickFile} onMouseUp={props.onClickFile}
> >
<div className={classNames(styles.fileMenu)}>File</div> <div className={classNames(styles.fileMenu)}>File</div>
<Menu <MenuBarMenu
className={styles.menu}
open={props.fileMenuOpen} open={props.fileMenuOpen}
onRequestClose={props.onRequestCloseFile} onRequestClose={props.onRequestCloseFile}
> >
<MenuItem>New</MenuItem> <MenuItemTooltip id="new">
<MenuItem>Save now</MenuItem> <MenuItem>New</MenuItem>
<MenuItem>Save as a copy</MenuItem> </MenuItemTooltip>
<MenuItemTooltip id="save">
<MenuItem>Save now</MenuItem>
</MenuItemTooltip>
<MenuItemTooltip id="copy">
<MenuItem>Save as a copy</MenuItem>
</MenuItemTooltip>
<MenuItem>Upload from your computer</MenuItem> <MenuItem>Upload from your computer</MenuItem>
<MenuItem>Download to your computer</MenuItem> <MenuItem>Download to your computer</MenuItem>
</Menu> </MenuBarMenu>
</div> </div>
<div className={classNames(styles.menuBarItem)}> <div className={classNames(styles.menuBarItem)}>
<MenuBarItemTooltip id="edit-menu"> <MenuBarItemTooltip id="edit-menu">
......
...@@ -2,42 +2,28 @@ ...@@ -2,42 +2,28 @@
.menu { .menu {
position: absolute; position: absolute;
right: 0;
border: 1px solid $ui-black-transparent; border: 1px solid $ui-black-transparent;
border-radius: 0 0 5px 5px; border-radius: 0 0 4px 4px;
background-color: $motion-primary; background-color: $motion-primary;
padding: 10px; padding: 10px;
max-width: 260px; max-width: 260px;
overflow: visible; overflow: visible;
color: $ui-white; color: $ui-white;
font-size: .8125rem;
font-weight: normal; font-weight: normal;
margin: 0;
} }
/* .menu.left {
a { right: 0;
&:link,
&:visited,
&:active {
background-color: transparent;
color: $ui-white;
}
} }
input { .menu.right {
// 100% minus border and padding left: 0;
margin-bottom: 12px;
width: calc(100% - 30px);
} }
label {
display: block;
margin-bottom: 5px;
}
*/
.menu-item { .menu-item {
display: block; display: block;
line-height: 30px; line-height: 34px;
white-space: nowrap; white-space: nowrap;
} }
...@@ -46,17 +32,6 @@ label { ...@@ -46,17 +32,6 @@ label {
border-top: 1px solid $ui-black-transparent; border-top: 1px solid $ui-black-transparent;
} }
/* a {
display: block;
padding: 0 10px;
&:hover {
background-color: $ui-black-transparent;
text-decoration: none;
}
}
*/
$arrow-border-width: 14px; $arrow-border-width: 14px;
.with-arrow { .with-arrow {
margin-top: $arrow-border-width; margin-top: $arrow-border-width;
...@@ -82,9 +57,3 @@ $arrow-border-width: 14px; ...@@ -82,9 +57,3 @@ $arrow-border-width: 14px;
content: ""; content: "";
} }
/*
@media only screen and (max-width: $tablet - 1) {
min-width: 160px;
}
*/
...@@ -5,10 +5,11 @@ import React from 'react'; ...@@ -5,10 +5,11 @@ import React from 'react';
import styles from './menu.css'; import styles from './menu.css';
const MenuComponent = ({ const MenuComponent = ({
open = false,
children,
className = '', className = '',
componentRef children,
componentRef,
open = false,
place = 'right'
}) => { }) => {
if (open) { if (open) {
return ( return (
...@@ -17,7 +18,9 @@ const MenuComponent = ({ ...@@ -17,7 +18,9 @@ const MenuComponent = ({
styles.menu, styles.menu,
className, className,
{ {
[styles.open]: open [styles.open]: open,
[styles.left]: place === 'left',
[styles.right]: place === 'right'
} }
)} )}
ref={componentRef} ref={componentRef}
...@@ -33,7 +36,8 @@ MenuComponent.propTypes = { ...@@ -33,7 +36,8 @@ MenuComponent.propTypes = {
children: PropTypes.node, children: PropTypes.node,
className: PropTypes.string, className: PropTypes.string,
componentRef: PropTypes.func, componentRef: PropTypes.func,
open: PropTypes.bool open: PropTypes.bool,
place: PropTypes.oneOf(['left', 'right'])
}; };
const MenuItem = ({ const MenuItem = ({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment