Skip to content

Instantly share code, notes, and snippets.

@DZuz14
DZuz14 / Hierarchy.js
Created July 17, 2020 19:27
Accordion Hierarchy
<Accordion>
<Accordion.Item>
<Accordion.Collapsed>
…content here
</Accordion.Collapsed>
<Accordion.Expanded>
…content here
</Accordion.Expanded>
</Accordion.Item>
@DZuz14
DZuz14 / Expanded.js
Created July 17, 2020 19:26
Expanded
import React from 'react'
const Expanded = ({ children }) => {
return <div style={styles}>{children}</div>
}
const styles = {
padding: '15px'
}
@DZuz14
DZuz14 / Collapsed.js
Created July 17, 2020 19:22
Collapsed
import React from 'react'
const Collapsed = ({ children }) => (
<div style={styles}>
{children}
</div>
)
const styles = {
color: '#007bff', // blue
@DZuz14
DZuz14 / Wrapper.js
Created July 17, 2020 19:20
Prevent JSX alignment errors
return (
<Accordion>
<div>
<Accordion.Collapsed>
…content here
</Accordion.Collapsed>
<Accordion.Expanded>
…content here
</Accordion.Expanded>
</div>
@DZuz14
DZuz14 / meta.html
Last active May 14, 2020 16:47
Meta Tags for Social Media etc.
<meta name="description" content="" />
<meta name="twitter:title" content="" />
<meta name="twitter:description" content="" />
<meta name="twitter:url" content="" />
<meta name="twitter:image" content="" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@your_twitter_handle" />
<meta property="og:title" content="" />
@DZuz14
DZuz14 / puppeteer.js
Last active March 21, 2020 16:15
Web Scraping With Node.js & Puppeteer 2
const puppeteer = require('puppeteer');
const fs = require('fs')
async function main() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://some-website.com');
// Return an array of all the link text and assign it to sideBarLinks
@DZuz14
DZuz14 / puppeteer.js
Last active March 21, 2020 16:06
Web Scraping With Node.js & Puppeteer
const puppeteer = require('puppeteer');
async function main() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://some-website.com');
// Full access to the browser environment.
await page.evaluate(() => {
@DZuz14
DZuz14 / Slider.js
Last active March 2, 2020 15:05
Slider Final!
/** @jsx jsx */
import React, { useState, useEffect, useRef } from 'react'
import { css, jsx } from '@emotion/core'
import SliderContent from './SliderContent'
import Slide from './Slide'
import Arrow from './Arrow'
import Dots from './Dots'
const getWidth = () => window.innerWidth
@DZuz14
DZuz14 / Slider.js
Created March 2, 2020 15:02
Slider Final!
/** @jsx jsx */
import React, { useState, useEffect, useRef } from 'react'
import { css, jsx } from '@emotion/core'
import SliderContent from './SliderContent'
import Slide from './Slide'
import Arrow from './Arrow'
import Dots from './Dots'
const getWidth = () => window.innerWidth
@DZuz14
DZuz14 / SliderContent.js
Created March 2, 2020 14:51
SliderContent refactor
/** @jsx jsx */
import React from 'react'
import { css, jsx } from '@emotion/core'
const SliderContent = props => (
<div
css={css`
transform: translateX(-${props.translate}px);
transition: transform ease-out ${props.transition}s;
height: 100%;