Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ yarn-debug.log*
yarn-error.log*

# Editors
.chrome
.vscode/*
!.vscode/launch.json
.tm_properties
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/src",
"userDataDir": "${workspaceRoot}/.chrome",
"sourceMapPathOverrides": {
"webpack:///src/*": "${webRoot}/*"
}
}
]
}
2 changes: 0 additions & 2 deletions README.old.md

This file was deleted.

21 changes: 15 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"name": "frontend-prototype",
"name": "frontend-prototype-ts",
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/jest": "^19.2.3",
"@types/node": "^7.0.18",
"@types/react": "^15.0.24",
"@types/react-dom": "^15.5.0",
"@types/react-redux": "^4.4.40",
"@types/react-router-dom": "^4.0.4",
"@types/react-router-redux": "^5.0.1",
"@types/redux": "^3.6.0",
"glamor": "^2.20.24",
"glamorous": "^3.13.0",
"react": "^15.5.4",
Expand All @@ -13,12 +21,13 @@
"redux": "^3.6.0"
},
"devDependencies": {
"react-scripts": "0.9.5"
"react-scripts-ts": "1.3.0",
"typescript": "next"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"start": "react-scripts-ts start",
"build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
}
}
64 changes: 32 additions & 32 deletions src/components/App.js → src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import glamorous, { ThemeProvider } from 'glamorous';
import React from 'react';
import * as React from 'react';
import { Route, Switch } from 'react-router-dom';
import { connect, Provider } from 'react-redux';
import { Provider } from 'react-redux';
import { applyMiddleware, createStore } from 'redux';

import AppMenu, { width as appMenuWidth } from './AppMenu';
import AppMenu from './AppMenu';
import AppRouter, { middleware as historyMiddleware } from './AppRouter';
import Footer from './Footer';
import Header from './Header';
import { Config } from '../config';
import reducer from '../reducers';
import About from '../screens/About';
import Home from '../screens/Home';
import NotFound from '../screens/NotFound';
import Issues from '../screens/Issues';
import Organizations from '../screens/Organizations';
import { percent, rem } from '../styles/sizes';
import theme from '../styles/theme';


const store = createStore(reducer, applyMiddleware(historyMiddleware));
Expand All @@ -24,26 +24,38 @@ const AppOuter = glamorous.div({
height: percent(100)
});

const StyledAppInner = glamorous.div((props, theme) => ({
const StyledAppInner = glamorous.div({
display: 'flex',
flexDirection: 'column',
minHeight: percent(100),
transform: props.menu.isOpen && `translateX(-${appMenuWidth})`,
transition: 'transform 0.15s',
}));
minHeight: percent(100)
});

const AppHeader = glamorous(Header)({
flexShrink: 0
});

const AppBody = glamorous.div({
display: 'flex',
flexDirection: 'column',
flex: 1
});

const AppFooter = glamorous(Footer)({
marginTop: rem(1)
});

const BaseAppInner = props => {
const AppInner = () => {
return (
<AppRouter>
<StyledAppInner {...props}>
<StyledAppInner>
<AppHeader />
<AppMenu />
<AppBody>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/about/" component={About} />
<Route exact path="/issues/" component={Issues} />
<Route exact path="/organizations/" component={Organizations} />
<Route exact={true} path="/" component={Home} />
<Route exact={true} path="/about/" component={About} />
<Route exact={true} path="/issues/" component={Issues} />
<Route exact={true} path="/organizations/" component={Organizations} />
<Route component={NotFound} />
</Switch>
</AppBody>
Expand All @@ -53,25 +65,13 @@ const BaseAppInner = props => {
);
};

const mapStateToProps = ({ menu }) => ({ menu });

const AppInner = connect(mapStateToProps)(BaseAppInner);

const AppHeader = glamorous(Header)({
flexShrink: 0
});

const AppBody = glamorous.div({
display: 'flex',
flexDirection: 'column',
flex: 1
});
type Props = {
config: Config
};

const AppFooter = glamorous(Footer)({
marginTop: rem(1)
});
const App = ({ config }: Props) => {
const { theme } = config;

const App = () => {
return (
<Provider store={store}>
<ThemeProvider theme={theme}>
Expand Down
71 changes: 0 additions & 71 deletions src/components/AppMenu.js

This file was deleted.

88 changes: 88 additions & 0 deletions src/components/AppMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import glamorous from 'glamorous';
import * as React from 'react';
import { connect } from 'react-redux';

import { MenuButton, MenuButtonIcon } from './AppMenuButton';
import AppMenuMask from './AppMenuMask';
import Link from './AppMenuLink';
import { HeaderOffset } from './Header';
import { Theme } from '../config';
import { actions, State } from '../reducers/menu';
import { percent, rem } from '../styles/sizes';


type DispatchProps = {
closeMenu: () => void
};

type Props = {
menu: State
};

const BaseCloseButton = ({ closeMenu }: DispatchProps) => {
return (
<HeaderOffset>
<MenuButton onClick={closeMenu}>
<MenuButtonIcon iconTheme="light" name="x" />
</MenuButton>
</HeaderOffset>
);
};

const CloseButton = connect(null, dispatch => ({
closeMenu: () => {
dispatch({ type: actions.CLOSE_MENU });
}
}))(BaseCloseButton);

const List = glamorous.ul((props, theme: Theme) => ({
...theme.common.resetList,
padding: rem(0, 2, 2),
}));

const Item = glamorous.li((props, theme: Theme) => ({
...theme.common.resetList,
margin: rem(0, 0, 1)
}));

const width = rem(16);

const StyledAppMenu = glamorous.nav((props: Props, theme: Theme) => ({
boxSizing: 'border-box',
position: 'fixed',
top: 0,
left: percent(100),
width: width,
height: percent(100),
boxShadow: props.menu.isOpen ? `${rem(0, 0, 1)} ${theme.colors.appMenuShadow}` : '',
overflow: 'auto',
...theme.colors.appMenu,
transform: props.menu.isOpen ? `translateX(-${width})` : '',
transition: 'transform 0.15s, box-shadow 0.15s',
zIndex: 3
}));

const BaseAppMenu = (props: Props) => {
const { menu } = props;

return (
<div>
{menu.isOpen && <AppMenuMask />}
<StyledAppMenu {...props}>
<CloseButton />
<List>
<Item><Link to="/">Home</Link></Item>
<Item><Link to="/organizations/">Organizations</Link></Item>
<Item><Link to="/issues/">Issues</Link></Item>
<Item><Link to="/about/">About Democratizr</Link></Item>
</List>
</StyledAppMenu>
</div>
);
};

const mapStateToProps = ({ menu }): Props => ({ menu });

const AppMenu = connect(mapStateToProps)(BaseAppMenu);

export default AppMenu;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import glamorous from 'glamorous';
import React from 'react';
import * as React from 'react';
import { connect } from 'react-redux';

import Button from './Button';
Expand All @@ -9,7 +9,7 @@ import { medium } from '../styles/breakpoints';
import { percent, rem } from '../styles/sizes';


const MenuButton = glamorous(Button)({
export const MenuButton = glamorous(Button)({
boxSizing: 'border-box',
width: rem(1),
height: rem(1),
Expand All @@ -24,20 +24,24 @@ const MenuButton = glamorous(Button)({
}
});

const MenuButtonIcon = glamorous(Icon)({
export const MenuButtonIcon = glamorous(Icon)({
width: percent(100),
height: percent(100)
});

const BaseAppMenuButton = ({ toggleMenu }) => {
type DispatchProps = {
toggleMenu: () => void
};

const BaseAppMenuButton = ({ toggleMenu }: DispatchProps) => {
return (
<MenuButton onClick={toggleMenu}>
<MenuButtonIcon iconTheme="light" name="hamburger" />
</MenuButton>
);
};

const mapDispatchToProps = dispatch => {
const mapDispatchToProps = (dispatch): DispatchProps => {
return {
toggleMenu: () => {
dispatch({ type: actions.TOGGLE_MENU });
Expand Down
Loading