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
/** | |
Fullscreen Class | |
*/ | |
class Fullscreen { | |
constructor() { | |
document.cancelFullScreen = document.webkitCancelFullScreen || document.mozCancelFullScreen || document.cancelFullScreen; |
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
function flattenDeep(arr) { | |
return arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), []); | |
} | |
flattenDeep([[1,2,[3]],4]); |
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
import schema from './schema'; | |
import { ACTIONS } from './action'; | |
export default (state = schema, action) => { | |
switch (action.type) { | |
case ACTIONS.FETCHING: | |
return { | |
...state, | |
isFetching: true |
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
import schema from './schema'; | |
import { ACTIONS } from './action'; | |
export default (state = schema, action) => { | |
switch (action.type) { | |
case ACTIONS.FETCHING_LIST: | |
return { | |
...state, | |
list: { |
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
import schema from './schema'; | |
import { ACTIONS } from './action'; | |
const fetching = substate => (state, action) => { | |
return { | |
...state, | |
[substate]: { | |
...state[substate], | |
...action.value, | |
fetching: true |
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
import styled from 'styled-components' | |
/* | |
* Using the shorthand tag name 'ul' | |
*/ | |
const UnorderedList = styled.ul` | |
list-style: none; | |
li { | |
margin-bottom: 7px; |
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
import styled from 'styled-components' | |
/* | |
* Wrapping a custom component | |
*/ | |
const UnorderedList = styled(({ children, ...rest }) => ( | |
<ul {...rest}> | |
{ children } | |
</ul> | |
))` |
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
import styled, { css } from 'styled-components' | |
// Readable Style | |
const style = css` | |
list-style: none; | |
li { | |
margin-bottom: 7px; | |
} | |
` |
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
import styled, { css } from 'styled-components'; | |
/** | |
* Extending from another component | |
*/ | |
const List = styled.ul` | |
list-style: auto; | |
li { | |
text-transform: uppercase; |
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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import UnorderedList from './UnorderedList'; | |
const App = () => ( | |
<UnorderedList> | |
<li>Item X</li> | |
<li>Item Y</li> | |
</UnorderedList> | |
); |
OlderNewer