Skip to content

Instantly share code, notes, and snippets.

View Brlaney's full-sized avatar

Brendan Laney Brlaney

  • TN, United States
View GitHub Profile
@Brlaney
Brlaney / index.js
Created December 21, 2021 23:28
A simple script that saves all rows of data for a specified page number. This endpoint contains 130 pages as of 12/21/2021.
const cheerio = require('cheerio');
const axios = require('axios');
const fs = require('fs');
async function obtainData(num) {
const endpoint = 'https://www.tbpr.org/news-publications/recent-disciplinary-actions?page=' + num;
const file = 'data/pg' + num + '.json';
await axios.get(endpoint).then(urlResponse => {
const $ = cheerio.load(urlResponse.data);
@Brlaney
Brlaney / viewport.tsx
Created November 13, 2021 15:26
A React/Next.js function that returns windowSize for .height & .width values
import React, { useState, useEffect } from 'react';
function useWindowSize() {
// Initialize state with undefined width/height so server and client renders match
const [windowSize, setWindowSize] = useState({
width: undefined,
height: undefined,
});
useEffect(() => {
@Brlaney
Brlaney / Redirect.tsx
Created October 14, 2021 19:16
A Redirect component I continuously re-use in Next.js apps
import { useEffect } from 'react';
import { useRouter } from 'next/router';
const Redirect = ({ to }) => {
const router = useRouter();
useEffect(() => {
router.push(to)
}, [to])
return null
@Brlaney
Brlaney / SvgComponent.tsx
Last active September 22, 2021 14:52
Animated svg component using typescript & framer-motion
import { motion } from 'framer-motion';
import {
mainPathVariant,
shapeVariations
} from '@/lib/config/animations/svgs/svgs';
const color1 = 'rgba(37, 35, 35, 0.3)';
const color2 = 'rgba(202, 222, 252, 0.7)';
/*
@Brlaney
Brlaney / Home.module.scss
Last active October 11, 2021 17:00
Using custom mixins in .scss file
@import '../theme/theme';
@import '../mixins/width';
@import '../mixins/height';
.parent {
height: 100%;
width: 100vw;
color: $bg-d;
display: flex;
flex-direction: column;
@Brlaney
Brlaney / _width.scss
Created September 18, 2021 00:45
scss/mixins/_width.scss
$breakpoints: (
xs: 600px,
sm: 800px,
md: 1000px,
lg: 1200px,
xl: 1500px,
);
@mixin respond-above-width($breakpoint) {
@if map-has-key($breakpoints, $breakpoint) {
@Brlaney
Brlaney / _height.scss
Created September 18, 2021 00:44
scss/mixins/_height.scss
$breakpoints: (
xxs: 575px,
xs: 650px,
sm: 725px,
md: 800px,
lg: 875px,
xlg: 960px,
);
@mixin respond-above-height($breakpoint) {
@Brlaney
Brlaney / _app.tsx
Created July 29, 2021 02:02
Using framer motion with next.js
import * as React from 'react'
import type { AppProps /*, AppContext */ } from 'next/app'
import Head from 'next/head'
import { useRouter } from 'next/router'
import { AnimatePresence } from 'framer-motion'
import theme from '@/lib/theme/theme'
import '@/styles/globals.scss'
export default function MyApp (props: AppProps) {
const { Component, pageProps } = props
@Brlaney
Brlaney / Home.module.scss
Created July 21, 2021 00:10
My Home.module.scss file to be imported into index.tsx for a Next.js app
@import 'themes';
.container {
min-height: 100vh;
padding: 0 0.5rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
@Brlaney
Brlaney / globals.scss
Created July 21, 2021 00:09
A next.js app's globals.scss file example
@import 'themes';
html,
body {
padding: 0;
margin: 0;
background: $c-bg;
color: #fff;
font-family: $primary-font-family;
}