Skip to content

Commit c58cdc2

Browse files
committed
🚧 add navigation elements to the dropdown menu
1 parent 91a766d commit c58cdc2

File tree

2 files changed

+61
-34
lines changed

2 files changed

+61
-34
lines changed

client/components/Dropdown.jsx

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
33
import { Link } from 'react-router';
44
import styled from 'styled-components';
55
import { remSize, prop, common } from '../theme';
6+
import IconButton from './mobile/IconButton';
7+
import Button from '../common/Button';
68

79

810
// <ul className="nav__dropdown">
@@ -51,21 +53,21 @@ import { remSize, prop, common } from '../theme';
5153
// color: getThemifyVariable('primary-text-color');
5254
// }
5355
// text-align: left;
54-
// width: #{180 / $base-font-size}rem;
56+
// width: ${remSize(180)};
5557
// display: flex;
5658
// position: absolute;
5759
// flex-direction: column;
5860
// top: 95%;
5961
// height: auto;
6062
// z-index: 9999;
61-
// border-radius: #{6 / $base-font-size}rem;
62-
// -------------
63+
// border-radius: ${remSize(6)};
6364
// & li:first-child {
64-
// border-radius: #{5 / $base-font-size}rem #{5 / $base-font-size}rem 0 0;
65+
// border-radius: ${remSize(5)} ${remSize(5)} 0 0;
6566
// }
6667
// & li:last-child {
67-
// border-radius: 0 0 #{5 / $base-font-size}rem #{5 / $base-font-size}rem;
68+
// border-radius: 0 0 ${remSize(5)} ${remSize(5)};
6869
// }
70+
// -------------
6971
// & li {
7072
// & button,
7173
// & a {
@@ -74,9 +76,9 @@ import { remSize, prop, common } from '../theme';
7476
// }
7577
// width: 100%;
7678
// text-align: left;
77-
// padding: #{8 / $base-font-size}rem #{16 / $base-font-size}rem;
79+
// padding: ${remSize(8)} ${remSize(16)};
7880
// }
79-
// height: #{35 / $base-font-size}rem;
81+
// height: ${remSize(35)};
8082
// cursor: pointer;
8183
// display: flex;
8284
// align-items: center;
@@ -105,10 +107,10 @@ import { remSize, prop, common } from '../theme';
105107
// }
106108

107109

108-
const DropdownWrapper = styled.div`
110+
const DropdownWrapper = styled.ul`
109111
background-color: ${prop('Modal.background')};
110112
border: 1px solid ${prop('Modal.border')};
111-
box-shadow: 0 0 18px 0 ${common.shadowColor};
113+
box-shadow: 0 0 18px 0 ${prop('shadowColor')};
112114
color: ${prop('primaryTextColor')};
113115
114116
text-align: left;
@@ -120,45 +122,68 @@ const DropdownWrapper = styled.div`
120122
height: auto;
121123
z-index: 9999;
122124
border-radius: ${remSize(6)};
123-
`;
124125
126+
& li:first-child { border-radius: ${remSize(5)} ${remSize(5)} 0 0; }
127+
& li:last-child { border-radius: 0 0 ${remSize(5)} ${remSize(5)}; }
128+
129+
& li:hover {
130+
131+
background-color: ${prop('Button.hover.background')};
132+
color: ${prop('Button.hover.foreground')};
133+
134+
& button, & a {
135+
color: ${prop('Button.hover.foreground')};
136+
}
137+
}
138+
139+
li {
140+
height: ${remSize(36)};
141+
cursor: pointer;
142+
display: flex;
143+
align-items: center;
144+
145+
& button,
146+
& a {
147+
color: ${prop('primaryTextColor')};
148+
width: 100%;
149+
text-align: left;
150+
padding: ${remSize(8)} ${remSize(16)};
151+
}
152+
}
125153
126-
// @include themify() {
127-
// background-color: map-get($theme-map, 'modal-background-color');
128-
// border: 1px solid map-get($theme-map, 'modal-border-color');
129-
// box-shadow: 0 0 18px 0 getThemifyVariable('shadow-color');
130-
// color: getThemifyVariable('primary-text-color');
131-
// }
154+
`;
155+
156+
// { onPress
157+
// ? <IconButton
158+
// : <Link to={to}>{title}</Link>}
132159

160+
const MaybeIcon = (Element, label) => Element && <Element aria-label={label} />;
133161

134162
const Dropdown = ({ items }) => (
135163
<DropdownWrapper>
136-
<h1>space</h1>
137-
<h1>space</h1>
138-
<h1>space</h1>
139-
<h1>space</h1>
140164
{/* className="nav__items-left" */}
141-
<ul className="nav__items-left nav__dropdown nav__item nav__item--open">
142-
<h1 className="nav__dropdown-item">hello</h1>
143-
<h1 className="nav__dropdown-item">hello</h1>
144-
{items && items.map(({ title }) => (
145-
<li className="nav__dropdown-item" key={`nav-${title && title.toLowerCase()}`}>
146-
<h1>space</h1>
147-
</li>
148-
))
149-
}
150-
</ul>
165+
{items && items.map(({ title, icon, href }) => (
166+
<li key={`nav-${title && title.toLowerCase()}`}>
167+
<Link to={href}>
168+
{MaybeIcon(icon, `Navigate to ${title}`)}
169+
{title}
170+
</Link>
171+
</li>
172+
))
173+
}
151174
</DropdownWrapper>
152175
);
153176

154177
Dropdown.propTypes = {
155178
items: PropTypes.arrayOf(PropTypes.shape({
156-
action: PropTypes.func
157-
}))
179+
action: PropTypes.func,
180+
icon: PropTypes.func,
181+
href: PropTypes.string
182+
})),
158183
};
159184

160185
Dropdown.defaultProps = {
161-
items: []
186+
items: [],
162187
};
163188

164189
export default Dropdown;

client/modules/IDE/pages/MobileIDEView.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ const MobileIDEView = (props) => {
5858
// const overlayActive = name => (overlay === name);
5959

6060
const headerNavOptions = [
61-
{ icon: PreferencesIcon, title: 'Preferences', route: '/mobile/preferences' }
61+
{ icon: PreferencesIcon, title: 'Preferences', href: '/mobile/preferences' },
62+
{ icon: PreferencesIcon, title: 'Examples', href: '/mobile/examples' },
63+
{ icon: PreferencesIcon, title: 'Original View', href: '/mobile/preferences' }
6264
];
6365

6466
return (

0 commit comments

Comments
 (0)