-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83b2fb8
commit ddba6e1
Showing
23 changed files
with
746 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { Component } from 'react' | ||
import { Link } from 'react-router-dom' | ||
import Settings from '../settings' | ||
|
||
class Footer extends Component { | ||
render() { | ||
return window === window.top ? ( | ||
<footer className="footer"> | ||
<Settings /> | ||
<Link className="logo" to="/"> | ||
Wikipedia | ||
</Link> | ||
</footer> | ||
) : null | ||
} | ||
} | ||
|
||
export default Footer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, { Component } from 'react' | ||
import { compose } from 'redux' | ||
import { connect } from 'react-redux' | ||
import { updateSetting } from '../../store/settings' | ||
import withClickOutside from 'react-click-outside' | ||
|
||
import Toggle from '../toggle' | ||
|
||
class Settings extends Component { | ||
constructor() { | ||
super() | ||
this.state = { | ||
open: false | ||
} | ||
} | ||
|
||
handleClickOutside(event) { | ||
if (this.state.open) { | ||
event.preventDefault() | ||
this.setState({ open: false }) | ||
} | ||
} | ||
|
||
render() { | ||
const { settings } = this.props | ||
const { open } = this.state | ||
|
||
return ( | ||
<div className="settings"> | ||
<button | ||
className="settings-button" | ||
onClick={() => this.setState({ open: true })}> | ||
Settings | ||
</button> | ||
{open && ( | ||
<div className="modal settings-modal"> | ||
<button | ||
className="close" | ||
onClick={() => this.setState({ open: false })}> | ||
Close | ||
</button> | ||
<h3>Settings</h3> | ||
|
||
<Toggle | ||
label="Low contrast" | ||
name="lowContrast" | ||
checked={settings.lowContrast} | ||
onChange={this.props.updateSetting} | ||
/> | ||
<p className="settings-hint"> | ||
Reduce eye strain for low-light reading. | ||
</p> | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
const mapStateToProps = ({ settings }) => ({ settings }) | ||
const mapDispatchToProps = { updateSetting } | ||
|
||
export default compose( | ||
connect(mapStateToProps, mapDispatchToProps), | ||
withClickOutside | ||
)(Settings) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
|
||
const Toggle = ({ label, name, checked, onChange }) => ( | ||
<label className="toggle-label" htmlFor={name}> | ||
<span>{label}</span> | ||
<div className="toggle"> | ||
<input | ||
id={name} | ||
className="toggle-input" | ||
type="checkbox" | ||
name={name} | ||
checked={checked} | ||
onChange={({ target: { checked } }) => onChange(name, checked)} | ||
/> | ||
<span className="toggle-ui" /> | ||
</div> | ||
</label> | ||
) | ||
|
||
export default Toggle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,19 @@ | ||
import React from 'react' | ||
import { Switch, Redirect, Route } from 'react-router-dom' | ||
import { connect } from 'react-redux' | ||
|
||
import Home from '../home' | ||
import Page from '../page' | ||
import Media from '../media' | ||
import Header from '../../components/header' | ||
import Footer from '../../components/footer' | ||
|
||
const PageNotFound = () => ( | ||
<div> | ||
<span role="img" aria-label="Sad face"> | ||
😢 | ||
</span> | ||
Not Found | ||
</div> | ||
) | ||
|
||
export default () => ( | ||
<div> | ||
const App = ({ classNames, children }) => ( | ||
<div className={classNames.join(' ')}> | ||
<Header /> | ||
<Switch> | ||
<Route exact path="/" component={Home} /> | ||
<Route exact path="/Main_page" render={() => <Redirect to="/" />} /> | ||
<Route path="/File::title" component={Media} /> | ||
<Route path="/:title" component={Page} /> | ||
<Route component={PageNotFound} /> | ||
</Switch> | ||
{children} | ||
<Footer /> | ||
</div> | ||
) | ||
|
||
const mapStateToProps = ({ settings }) => ({ | ||
classNames: Object.keys(settings).filter(setting => settings[setting]) | ||
}) | ||
|
||
export default connect(mapStateToProps)(App) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
import { Switch, Redirect, Route } from 'react-router-dom' | ||
|
||
import App from './app' | ||
import Home from './home' | ||
import Page from './page' | ||
import Media from './media' | ||
import PageNotFound from './not-found' | ||
|
||
export default () => ( | ||
<App> | ||
<Switch> | ||
<Route exact path="/" component={Home} /> | ||
<Route exact path="/Main_page" render={() => <Redirect to="/" />} /> | ||
<Route path="/File::title" component={Media} /> | ||
<Route path="/:title" component={Page} /> | ||
<Route component={PageNotFound} /> | ||
</Switch> | ||
</App> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
|
||
const PageNotFound = () => ( | ||
<div> | ||
<span role="img" aria-label="Sad face"> | ||
😢 | ||
</span> | ||
Not Found | ||
</div> | ||
) | ||
|
||
export default PageNotFound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { combineReducers, createStore, applyMiddleware } from 'redux' | ||
import thunk from 'redux-thunk' | ||
import createLogger from 'redux-logger' | ||
|
||
import settings from './settings' | ||
|
||
const initialState = {} | ||
|
||
export default () => | ||
createStore( | ||
combineReducers({ | ||
settings | ||
}), | ||
initialState, | ||
applyMiddleware(thunk, createLogger) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export const updateSetting = (name, value) => dispatch => | ||
Promise.resolve() | ||
.then(() => localStorage.setItem(name, value)) | ||
.then(() => | ||
dispatch({ | ||
type: 'SETTINGS/UPDATE', | ||
payload: { name, value } | ||
}) | ||
) | ||
|
||
const getBooleanValue = key => localStorage.getItem(key) === 'true' | ||
|
||
const initialState = { | ||
lowContrast: getBooleanValue('lowContrast') | ||
} | ||
|
||
export default (state = initialState, action) => { | ||
switch (action.type) { | ||
case 'SETTINGS/UPDATE': | ||
const { name, value } = action.payload | ||
return { | ||
...state, | ||
[name]: value | ||
} | ||
default: | ||
return state | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
} | ||
|
||
.page { | ||
.root h2 .mw-headline:before { | ||
h2 .mw-headline:before { | ||
display: none; | ||
} | ||
} | ||
|
Oops, something went wrong.