Skip to content

Commit 8225807

Browse files
committed
👌 subst left/right props with align prop on <Dropdown />
1 parent 8acd6ec commit 8225807

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

client/components/Dropdown.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const DropdownWrapper = styled.ul`
1616
right: ${props => (props.right ? 0 : 'initial')};
1717
left: ${props => (props.left ? 0 : 'initial')};
1818
19+
${props => (props.align === 'right' && 'right: 0;')}
20+
${props => (props.align === 'left' && 'left: 0;')}
21+
1922
2023
text-align: left;
2124
width: ${remSize(180)};
@@ -57,8 +60,8 @@ const DropdownWrapper = styled.ul`
5760
// TODO: Add Icon to the left of the items in the menu
5861
// const MaybeIcon = (Element, label) => Element && <Element aria-label={label} />;
5962

60-
const Dropdown = ({ items, right, left }) => (
61-
<DropdownWrapper right={right} left={left}>
63+
const Dropdown = ({ items, align }) => (
64+
<DropdownWrapper align={align} >
6265
{/* className="nav__items-left" */}
6366
{items && items.map(({ title, icon, href }) => (
6467
<li key={`nav-${title && title.toLowerCase()}`}>
@@ -73,8 +76,7 @@ const Dropdown = ({ items, right, left }) => (
7376
);
7477

7578
Dropdown.propTypes = {
76-
right: PropTypes.bool,
77-
left: PropTypes.bool,
79+
align: PropTypes.oneOf(['left', 'right']),
7880
items: PropTypes.arrayOf(PropTypes.shape({
7981
action: PropTypes.func,
8082
icon: PropTypes.func,
@@ -84,8 +86,7 @@ Dropdown.propTypes = {
8486

8587
Dropdown.defaultProps = {
8688
items: [],
87-
right: false,
88-
left: false,
89+
align: null
8990
};
9091

9192
export default Dropdown;

client/modules/IDE/pages/MobileIDEView.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ const MobileIDEView = (props) => {
5757
const {
5858
preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage,
5959
selectedFile, updateFileContent, files,
60-
closeEditorOptions, showEditorOptions, showKeyboardShortcutModal, setUnsavedChanges,
60+
closeEditorOptions, showEditorOptions,
6161
startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console,
6262
showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch
6363
} = props;
6464

6565
const [tmController, setTmController] = useState(null); // eslint-disable-line
6666

6767

68-
const [triggerNavDropdown, NavDropDown] = useAsModal(<Dropdown right items={headerNavOptions} />);
68+
const [triggerNavDropdown, NavDropDown] = useAsModal(<Dropdown align="right" items={headerNavOptions} />);
6969

7070
return (
7171
<Screen fullscreen>
@@ -213,10 +213,6 @@ MobileIDEView.propTypes = {
213213

214214
showEditorOptions: PropTypes.func.isRequired,
215215

216-
showKeyboardShortcutModal: PropTypes.func.isRequired,
217-
218-
setUnsavedChanges: PropTypes.func.isRequired,
219-
220216
startRefreshSketch: PropTypes.func.isRequired,
221217

222218
stopSketch: PropTypes.func.isRequired,

0 commit comments

Comments
 (0)