Compiling everything I've learned about about JavaScript packaging in one place.
- The official standard format.
- Works in many modern browsers.
| import { AppContext } from '../../context'; | |
| export default function Square() { | |
| // Use AppContext as the context and pull off state | |
| const { state } = useContext(AppContext); | |
| // Pull off specific state from the context | |
| const { width, height, activeColor } = state; | |
| return ( |
| import React from 'react'; | |
| import { AppContext } from 'path/to/context'; | |
| export default function Controls() { | |
| // Use AppContext as the context and pull off state and dispatch | |
| const { state, dispatch } = React.useContext(AppContext); | |
| // Create the functions to update state, using the dispatch method passed in | |
| // from the provider | |
| const setWidth = value => dispatch({ type: 'width', payload: value }); |
| import React from 'react'; | |
| // Create the context as AppContext | |
| const AppContext = React.createContext(); | |
| // Define some initial state | |
| const initialState = { | |
| width: 320, | |
| height: 250, | |
| activeColor: '#F44336' |
| import { AppContextProvider } from 'path/to/Context'; | |
| // Import our other components | |
| import Controls from 'path/to/Controls'; | |
| import Square from 'path/to/Square'; | |
| export default function App() { | |
| return ( | |
| // Wrap the Provider around our components. Nice and clean! | |
| <AppContextProvider> |
for file in *.jpg; do mv $file ${file:l}; done
Convert underscores to dashes in filenames. Can be used on any filetype, not just jpg.
for i in *.jpg; do
[[ "$i" = *_* ]] && mv -nv -- "$i" "${i//_/-}"
done
IE 11 and below does not support the CSS property object-fit, so this is a workaround using Modernizr. We are swapping to use a background image if Modernizr detects object-fit isn't supported in the browser.
https://modernizr.com/download?objectfit-setclasses&q=objec
Generate the download and include it on your page.
An intro paragraph about your project.