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 { useState } from 'react'; | |
export default function useSessionStorage(key, initialValue) { | |
const [item, setInnerValue] = useState(() => { | |
try { | |
return window.sessionStorage.getItem(key) | |
? JSON.parse(window.sessionStorage.getItem(key)) | |
: initialValue; | |
} catch (error) { | |
return initialValue; |
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(globals){ | |
// module name | |
const MODULE_NAME = 'moduleName'; | |
// define your functions here | |
const functions = { | |
fn1: alert, | |
fn2: console.log | |
}; | |
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
<?php | |
if (have_posts()) { | |
while (have_posts()) { | |
the_post(); | |
if (get_post_mime_type() == 'application/pdf') { | |
// Customize how you display PDF files | |
echo '<a href="' . esc_url(get_permalink()) . '">' . esc_html(get_the_title()) . '</a>'; | |
} else { |
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
/** | |
* useScroll React custom hook | |
* Usage: | |
* const { scrollX, scrollY, scrollDirection } = useScroll(); | |
*/ | |
import { useState, useEffect } from "react"; | |
export function useScroll() { | |
const [lastScrollTop, setLastScrollTop] = useState(0); |
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
// extend basic react component props | |
// simply replace the type and add your props' types | |
interface PersonCardProps extends React.ComponentProps<typeof PersonCard> { | |
name: string; | |
age: number; | |
isAdmin: boolean; | |
} | |
// in this example we're writing a component named PersonCard | |
// with props name, age, and isAdmin |
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
/*-------------------------------------------------*/ | |
/*----------------- LAZY.CSS v1.0 -----------------*/ | |
/*-------- Joshua Cerbito (@joshuacerbito) --------*/ | |
/*-------------------------------------------------*/ | |
/* RESET ALL CONTAINERS */ | |
html, body, div, table, tbody, tfoot, thead, tr, th, td, fieldset, form, label, legend, | |
section, article, aside, header, footer, hgroup, nav, audio, video, canvas, figure, figcaption, time, menu, details | |
{ | |
margin: 0; |
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
<?php | |
// Pre-fills a repeater field (and its sub-fields) with default values | |
// - assuming we have a Repeater field with the key "repeater_field_123" | |
// - with the sub-fields "sub_field_1" and "sub_field_2" | |
function prefill_repeater( $field ) { | |
if ($field['value'] === false) { | |
$field['value'] = array( | |
array( |
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
name: Flywheel SSH Deploy | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: "shivammathur/setup-php@v2" |
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
/*---------------------------------------------------------------*\ | |
RESPONSIVE PROPERTY HANDLER | |
handles the per-breakpoint property for mobile-first approach | |
note: requires a key-less 'breakpoints' scss map | |
e.g. $breakpoints: ( 320px, 760px, 1080px, 1280px ); | |
usage: | |
@include respond(( | |
display: flex, |
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
{ | |
"$schema": "https://openapi.vercel.sh/vercel.json", | |
"buildCommand": "npm run build-storybook", | |
"devCommand": "npm run storybook", | |
"installCommand": "npm install", | |
"framework": null, | |
"outputDirectory": "./storybook-static" | |
} |
NewerOlder