Add map drawer
This commit break map css. Will need to refactor how the map renders
This commit is contained in:
108
client/less/drawers.less
Normal file
108
client/less/drawers.less
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* based off of https://github.com/gitterHQ/sidecar
|
||||||
|
* license: MIT
|
||||||
|
*/
|
||||||
|
.drawer {
|
||||||
|
width:500px;
|
||||||
|
|
||||||
|
z-index: 20000;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
|
||||||
|
display: -webkit-flex;
|
||||||
|
display: flex;
|
||||||
|
-webkit-flex-direction: row;
|
||||||
|
flex-direction: row;
|
||||||
|
background-color: @body-bg;
|
||||||
|
border-left: 1px solid #ddd;
|
||||||
|
box-shadow: -12px 0 18px 0 rgba(50, 50, 50, 0.1);
|
||||||
|
|
||||||
|
transition: transform 0.3s cubic-bezier(0.16, 0.22, 0.22, 1.7);
|
||||||
|
|
||||||
|
&.is-collapsed:not(.is-loading) {
|
||||||
|
-webkit-transform: translateX(110%);
|
||||||
|
transform: translateX(110%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add some "extension" so that there isn't a gap
|
||||||
|
* when we translate(via animation) more than 100% */
|
||||||
|
&:after {
|
||||||
|
content: '';
|
||||||
|
|
||||||
|
z-index: -1;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 100%;
|
||||||
|
bottom: 0;
|
||||||
|
right: -100%;
|
||||||
|
|
||||||
|
background-color: @body-bg;
|
||||||
|
}
|
||||||
|
iframe {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer-action-bar {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
|
||||||
|
display: -webkit-flex;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
padding-bottom: 5px;
|
||||||
|
padding-right:10px;
|
||||||
|
padding-top:5px;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer-action-item {
|
||||||
|
display: -webkit-flex;
|
||||||
|
display: flex;
|
||||||
|
/* main axis */
|
||||||
|
justify-content: center;
|
||||||
|
/* cross axis */
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
|
||||||
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
|
|
||||||
|
opacity: 0.65;
|
||||||
|
background: none;
|
||||||
|
background-position: center center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 22px 22px;
|
||||||
|
border: 0;
|
||||||
|
outline: none;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
cursor: hand;
|
||||||
|
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
filter: hue-rotate(80deg) saturate(150);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer-action-pop-out {
|
||||||
|
margin-right: -4px;
|
||||||
|
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMDAgMTcxLjQyOSIgZmlsbD0iIzNhMzEzMyI+PHBhdGggZD0iTTE1Ny4xNDMsMTAzLjU3MXYzNS43MTRjMCw4Ljg1NC0zLjE0NCwxNi40MjYtOS40MzEsMjIuNzEzcy0xMy44NTgsOS40MzEtMjIuNzEyLDkuNDMxSDMyLjE0MyBjLTguODU0LDAtMTYuNDI1LTMuMTQ0LTIyLjcxMi05LjQzMVMwLDE0OC4xNCwwLDEzOS4yODVWNDYuNDI5YzAtOC44NTQsMy4xNDQtMTYuNDI1LDkuNDMxLTIyLjcxMiBjNi4yODctNi4yODc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ItMy44MzItNDMuMDI0LTExLjQ5NiBjLTEzLjEzMy03LjY2NC0yMy41MzEtMTguMDYyLTMxLjE5NC0zMS4xOTRDMy44MzIsMTE1LjYwNywwLDEwMS4yNjUsMCw4NS43MTRTMy44MzIsNTUuODIyLDExLjQ5Niw0Mi42OSBjNy42NjQtMTMuMTMzLDE4LjA2Mi0yMy41MzEsMzEuMTk0LTMxLjE5NEM1NS44MjIsMy44MzIsNzAuMTY0LDAsODUuNzE0LDBzMjkuODkzLDMuODMyLDQzLjAyNCwxMS40OTYgYzEzLjEzMyw3LjY2NCwyMy41MywxOC4wNjIsMzEuMTk0LDMxLjE5NEMxNjcuNTk3LDU1LjgyMiwxNzEuNDI5LDcwLjE2NCwxNzEuNDI5LDg1LjcxNHoiLz48L3N2Zz4=)
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
@import "lib/bootstrap/bootstrap";
|
@import "lib/bootstrap/bootstrap";
|
||||||
@import "lib/bootstrap-social/bootstrap-social";
|
@import "lib/bootstrap-social/bootstrap-social";
|
||||||
@import "lib/ionicons/ionicons";
|
@import "lib/ionicons/ionicons";
|
||||||
@import "lib/animate.min.less";
|
@import "lib/animate.min.less";
|
||||||
@ -1171,7 +1171,4 @@ and (max-width : 400px) {
|
|||||||
@import "challenge.less";
|
@import "challenge.less";
|
||||||
@import "toastr.less";
|
@import "toastr.less";
|
||||||
@import "map.less";
|
@import "map.less";
|
||||||
|
@import "drawers.less";
|
||||||
ul > li {
|
|
||||||
list-style-type: disc;
|
|
||||||
}
|
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.map-fixed-header {
|
.map-fixed-header {
|
||||||
position: fixed;
|
position: absolute;
|
||||||
background: white;
|
background: white;
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -158,7 +158,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.map-wrapper {
|
.map-wrapper {
|
||||||
position: absolute;
|
|
||||||
display: block;
|
display: block;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -6,10 +6,12 @@ import { connect } from 'react-redux';
|
|||||||
import { contain } from 'redux-epic';
|
import { contain } from 'redux-epic';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
|
import MapDrawer from './components/Map-Drawer.jsx';
|
||||||
import {
|
import {
|
||||||
fetchUser,
|
fetchUser,
|
||||||
initWindowHeight,
|
initWindowHeight,
|
||||||
updateNavHeight
|
updateNavHeight,
|
||||||
|
toggleMapDrawer
|
||||||
} from './redux/actions';
|
} from './redux/actions';
|
||||||
|
|
||||||
import { submitChallenge } from './routes/challenges/redux/actions';
|
import { submitChallenge } from './routes/challenges/redux/actions';
|
||||||
@ -24,18 +26,24 @@ const mapStateToProps = createSelector(
|
|||||||
state => state.app.points,
|
state => state.app.points,
|
||||||
state => state.app.picture,
|
state => state.app.picture,
|
||||||
state => state.app.toast,
|
state => state.app.toast,
|
||||||
|
state => state.app.isMapDrawerOpen,
|
||||||
|
state => state.app.isMapAlreadyLoaded,
|
||||||
state => state.challengesApp.toast,
|
state => state.challengesApp.toast,
|
||||||
(
|
(
|
||||||
username,
|
username,
|
||||||
points,
|
points,
|
||||||
picture,
|
picture,
|
||||||
toast,
|
toast,
|
||||||
|
isMapDrawerOpen,
|
||||||
|
isMapAlreadyLoaded,
|
||||||
showChallengeComplete
|
showChallengeComplete
|
||||||
) => ({
|
) => ({
|
||||||
username,
|
username,
|
||||||
points,
|
points,
|
||||||
picture,
|
picture,
|
||||||
toast,
|
toast,
|
||||||
|
isMapDrawerOpen,
|
||||||
|
isMapAlreadyLoaded,
|
||||||
showChallengeComplete
|
showChallengeComplete
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -44,7 +52,8 @@ const bindableActions = {
|
|||||||
initWindowHeight,
|
initWindowHeight,
|
||||||
updateNavHeight,
|
updateNavHeight,
|
||||||
fetchUser,
|
fetchUser,
|
||||||
submitChallenge
|
submitChallenge,
|
||||||
|
toggleMapDrawer
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchContainerOptions = {
|
const fetchContainerOptions = {
|
||||||
@ -67,7 +76,10 @@ export class FreeCodeCamp extends React.Component {
|
|||||||
updateNavHeight: PropTypes.func,
|
updateNavHeight: PropTypes.func,
|
||||||
initWindowHeight: PropTypes.func,
|
initWindowHeight: PropTypes.func,
|
||||||
showChallengeComplete: PropTypes.number,
|
showChallengeComplete: PropTypes.number,
|
||||||
submitChallenge: PropTypes.func
|
submitChallenge: PropTypes.func,
|
||||||
|
isMapDrawerOpen: PropTypes.bool,
|
||||||
|
isMapAlreadyLoaded: PropTypes.bool,
|
||||||
|
toggleMapDrawer: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillReceiveProps({
|
componentWillReceiveProps({
|
||||||
@ -122,8 +134,22 @@ export class FreeCodeCamp extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { username, points, picture, updateNavHeight } = this.props;
|
const {
|
||||||
const navProps = { username, points, picture, updateNavHeight };
|
username,
|
||||||
|
points,
|
||||||
|
picture,
|
||||||
|
updateNavHeight,
|
||||||
|
isMapDrawerOpen,
|
||||||
|
isMapAlreadyLoaded,
|
||||||
|
toggleMapDrawer
|
||||||
|
} = this.props;
|
||||||
|
const navProps = {
|
||||||
|
username,
|
||||||
|
points,
|
||||||
|
picture,
|
||||||
|
updateNavHeight,
|
||||||
|
toggleMapDrawer
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -131,6 +157,11 @@ export class FreeCodeCamp extends React.Component {
|
|||||||
<Row>
|
<Row>
|
||||||
{ this.props.children }
|
{ this.props.children }
|
||||||
</Row>
|
</Row>
|
||||||
|
<MapDrawer
|
||||||
|
isAlreadyLoaded={ isMapAlreadyLoaded }
|
||||||
|
isOpen={ isMapDrawerOpen }
|
||||||
|
toggleMapDrawer={ toggleMapDrawer }
|
||||||
|
/>
|
||||||
<ToastContainer
|
<ToastContainer
|
||||||
className='toast-bottom-right'
|
className='toast-bottom-right'
|
||||||
ref='toaster'
|
ref='toaster'
|
||||||
|
37
common/app/components/Drawer.jsx
Normal file
37
common/app/components/Drawer.jsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import React, { PropTypes } from 'react';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
|
||||||
|
export default class Drawer extends React.Component {
|
||||||
|
static displayName = 'Drawer';
|
||||||
|
static propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
isOpen: PropTypes.bool,
|
||||||
|
closeDrawer: PropTypes.func
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { isOpen, closeDrawer, children } = this.props;
|
||||||
|
const drawerClass = classnames({
|
||||||
|
drawer: true,
|
||||||
|
'is-collapsed': !isOpen
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<aside className={ drawerClass }>
|
||||||
|
<div className='drawer-action-bar'>
|
||||||
|
<a
|
||||||
|
aria-label='open map in new tab'
|
||||||
|
className='drawer-action-item drawer-action-pop-out'
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
aria-label='close map aside'
|
||||||
|
className='drawer-action-item drawer-action-collapse'
|
||||||
|
onClick={ closeDrawer }
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='drawer-content'>
|
||||||
|
{ children }
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
30
common/app/components/Map-Drawer.jsx
Normal file
30
common/app/components/Map-Drawer.jsx
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import React, { PropTypes } from 'react';
|
||||||
|
import NoSSR from 'react-no-ssr';
|
||||||
|
|
||||||
|
import Drawer from './Drawer.jsx';
|
||||||
|
import ShowMap from '../routes/challenges/components/map/Show.jsx';
|
||||||
|
|
||||||
|
export default class MapDrawer extends React.Component {
|
||||||
|
static displayName = 'MapDrawer';
|
||||||
|
static propTypes = {
|
||||||
|
isOpen: PropTypes.bool,
|
||||||
|
isAlreadyLoaded: PropTypes.bool,
|
||||||
|
toggleMapDrawer: PropTypes.func
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { isOpen, isAlreadyLoaded, toggleMapDrawer } = this.props;
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
closeDrawer={ toggleMapDrawer }
|
||||||
|
isOpen={ isOpen }
|
||||||
|
>
|
||||||
|
<NoSSR>
|
||||||
|
<div>
|
||||||
|
{ isAlreadyLoaded || isOpen ? <ShowMap /> : null }
|
||||||
|
</div>
|
||||||
|
</NoSSR>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -31,13 +31,16 @@ const toggleButtonChild = (
|
|||||||
|
|
||||||
export default class extends React.Component {
|
export default class extends React.Component {
|
||||||
static displayName = 'Nav';
|
static displayName = 'Nav';
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object
|
||||||
|
};
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
points: PropTypes.number,
|
points: PropTypes.number,
|
||||||
picture: PropTypes.string,
|
picture: PropTypes.string,
|
||||||
signedIn: PropTypes.bool,
|
signedIn: PropTypes.bool,
|
||||||
username: PropTypes.string,
|
username: PropTypes.string,
|
||||||
updateNavHeight: PropTypes.func
|
updateNavHeight: PropTypes.func,
|
||||||
|
toggleMapDrawer: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -45,12 +48,39 @@ export default class extends React.Component {
|
|||||||
this.props.updateNavHeight(navBar.clientHeight);
|
this.props.updateNavHeight(navBar.clientHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderMapLink(isOnMap, toggleMapDrawer) {
|
||||||
|
if (isOnMap) {
|
||||||
|
return (
|
||||||
|
<li role='presentation'>
|
||||||
|
<a
|
||||||
|
href='#'
|
||||||
|
onClick={ e => e.preventDefault()}
|
||||||
|
>
|
||||||
|
Map
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<LinkContainer
|
||||||
|
eventKey={ 1 }
|
||||||
|
to='/map'>
|
||||||
|
<NavItem
|
||||||
|
onClick={ toggleMapDrawer }
|
||||||
|
target='/map'
|
||||||
|
>
|
||||||
|
Map
|
||||||
|
</NavItem>
|
||||||
|
</LinkContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
renderLinks() {
|
renderLinks() {
|
||||||
return navLinks.map(({ content, link, react, target }, index) => {
|
return navLinks.map(({ content, link, react, target }, index) => {
|
||||||
if (react) {
|
if (react) {
|
||||||
return (
|
return (
|
||||||
<LinkContainer
|
<LinkContainer
|
||||||
eventKey={ index + 1 }
|
eventKey={ index + 2 }
|
||||||
key={ content }
|
key={ content }
|
||||||
to={ link }>
|
to={ link }>
|
||||||
<NavItem
|
<NavItem
|
||||||
@ -110,7 +140,14 @@ export default class extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { username, points, picture } = this.props;
|
const {
|
||||||
|
username,
|
||||||
|
points,
|
||||||
|
picture,
|
||||||
|
toggleMapDrawer
|
||||||
|
} = this.props;
|
||||||
|
const { router } = this.context;
|
||||||
|
const isOnMap = router.isActive('/map');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar
|
<Navbar
|
||||||
@ -123,6 +160,7 @@ export default class extends React.Component {
|
|||||||
className='hamburger-dropdown'
|
className='hamburger-dropdown'
|
||||||
navbar={ true }
|
navbar={ true }
|
||||||
pullRight={ true }>
|
pullRight={ true }>
|
||||||
|
{ this.renderMapLink(isOnMap, toggleMapDrawer) }
|
||||||
{ this.renderLinks() }
|
{ this.renderLinks() }
|
||||||
{ this.renderPoints(username, points) }
|
{ this.renderPoints(username, points) }
|
||||||
{ this.renderSignin(username, picture) }
|
{ this.renderSignin(username, picture) }
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
[{
|
[{
|
||||||
"content": "Map",
|
|
||||||
"link": "/map"
|
|
||||||
}, {
|
|
||||||
"content": "Chat",
|
"content": "Chat",
|
||||||
"link": "//gitter.im/FreeCodeCamp/FreeCodeCamp",
|
"link": "//gitter.im/FreeCodeCamp/FreeCodeCamp",
|
||||||
"target": "_blank"
|
"target": "_blank"
|
||||||
|
@ -46,3 +46,10 @@ export const createErrorObservable = error => Observable.just({
|
|||||||
type: types.handleError,
|
type: types.handleError,
|
||||||
error
|
error
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// drawers
|
||||||
|
export const toggleMapDrawer = createAction(
|
||||||
|
types.toggleMapDrawer,
|
||||||
|
e => e.preventDefault()
|
||||||
|
);
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
import { handleActions } from 'redux-actions';
|
import { handleActions } from 'redux-actions';
|
||||||
import types from './types';
|
import types from './types';
|
||||||
|
|
||||||
|
const initialState = {
|
||||||
|
title: 'Learn To Code | Free Code Camp',
|
||||||
|
username: null,
|
||||||
|
picture: null,
|
||||||
|
points: 0,
|
||||||
|
isSignedIn: false,
|
||||||
|
csrfToken: '',
|
||||||
|
windowHeight: 0,
|
||||||
|
navHeight: 0
|
||||||
|
};
|
||||||
|
|
||||||
export default handleActions(
|
export default handleActions(
|
||||||
{
|
{
|
||||||
[types.updateTitle]: (state, { payload = 'Learn To Code' }) => ({
|
[types.updateTitle]: (state, { payload = 'Learn To Code' }) => ({
|
||||||
@ -30,16 +41,12 @@ export default handleActions(
|
|||||||
[types.updateNavHeight]: (state, { payload: navHeight }) => ({
|
[types.updateNavHeight]: (state, { payload: navHeight }) => ({
|
||||||
...state,
|
...state,
|
||||||
navHeight
|
navHeight
|
||||||
|
}),
|
||||||
|
[types.toggleMapDrawer]: state => ({
|
||||||
|
...state,
|
||||||
|
isMapAlreadyLoaded: true,
|
||||||
|
isMapDrawerOpen: !state.isMapDrawerOpen
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
{
|
initialState
|
||||||
title: 'Learn To Code | Free Code Camp',
|
|
||||||
username: null,
|
|
||||||
picture: null,
|
|
||||||
points: 0,
|
|
||||||
isSignedIn: false,
|
|
||||||
csrfToken: '',
|
|
||||||
windowHeight: 0,
|
|
||||||
navHeight: 0
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
@ -19,5 +19,8 @@ export default createTypes([
|
|||||||
// data handling
|
// data handling
|
||||||
'updateChallengesData',
|
'updateChallengesData',
|
||||||
'updateJobsData',
|
'updateJobsData',
|
||||||
'updateHikesData'
|
'updateHikesData',
|
||||||
|
|
||||||
|
// drawers
|
||||||
|
'toggleMapDrawer'
|
||||||
], 'app');
|
], 'app');
|
||||||
|
Reference in New Issue
Block a user