Original article: https://apoorv.blog/typed-css-modules-reactjs/
- Add the typescript-plugin:
yarn add --dev typescript-plugin-css-modules| # Deploy frontend after successful backend deployment in sequence | |
| # If frontend changed, deploy only frontend | |
| # If backend changed, deploy only backend | |
| # If frontend and backend, deploy frontend after backend | |
| name: "Deploy services" | |
| on: | |
| push: | |
| branches: ["main"] | |
| jobs: |
| /* | |
| Tiny, smart, single-method animation library for CSS animations - TweenMax-style. | |
| Returns a Promise that resolves when the transition has ended. | |
| Usage: | |
| Single element: | |
| AnimationService.animate(element, time, to) | |
| AnimationService.animate(element, time, from, to) | |
| Multiple elements with stagger: |
| /* | |
| Template literals for-loop example | |
| Using `Array(5).join(0).split(0)`, we create an empty array | |
| with 5 items which we can iterate through using `.map()` | |
| */ | |
| var element = document.createElement('div') | |
| element.innerHTML = ` | |
| <h1>This element is looping</h1> | |
| ${Array(5).join(0).split(0).map((item, i) => ` |
Original article: https://apoorv.blog/typed-css-modules-reactjs/
yarn add --dev typescript-plugin-css-modules| /** | |
| Value first, might be nicer | |
| @example | |
| const [value] = tryCatch(doSomething()) | |
| if (!value) { | |
| // something went wrong | |
| } | |
| */ | |
| const tryCatch = async <TSuccess, TError extends Error>( |
| import { getBrowserPlatform } from '@/src/lib/browser-platform/browser-platform'; | |
| const DESKTOP_UA = | |
| 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36'; | |
| const IPHONE_UA = | |
| 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'; | |
| const ANDROID_UA = | |
| 'Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36'; | |
| describe('browser-platform', () => { |
| /* | |
| Template literals forEach example | |
| Using Array.map(), we can create a forEach within template literals. | |
| */ | |
| var items = [ | |
| { name: 'Teddy' }, | |
| { name: 'Dolores' }, | |
| { name: 'William' }, | |
| { name: 'Bernard' } |
| # Convert a video file to 720p with 24fps | |
| /opt/homebrew/bin/ffmpeg -i "$@" -preset slow -codec:a aac -b:a 128k -codec:v libx264 -pix_fmt yuv420p -b:v 2500k -minrate 1500k -maxrate 4000k -bufsize 5000k -vf scale=-1:720 -filter:v fps=24 "$@-converted.mp4" | |
| # Simpler | |
| /opt/homebrew/bin/ffmpeg -y -i "$@" -preset slow -codec:a aac -b:a 128k -codec:v libx264 -pix_fmt yuv420p -b:v 2500k -filter:v "scale=-2:720, fps=48" "$@-converted.mp4" | |
| # Convert audio to .mp3 | |
| /opt/homebrew/bin/ffmpeg -y -i "$@" -vn -ar 44100 -ac 2 -b:a 192k "$@.mp3" |
| /* | |
| Template literals if-statement example | |
| Using a single-line conditional, we can create an if-statements within template literals. | |
| */ | |
| function makeHTML(title) { | |
| return ` | |
| ${title ? ` | |
| This element has a title, and it is "${title}" | |
| ` : ` |