Skip to content

Instantly share code, notes, and snippets.

@wking-io
wking-io / gradient.json
Last active November 26, 2018 20:48
API for Codepen | Gradients.
{
"data": [
{
"name": "warmFlame",
"direction": "90deg",
"colors": ["#ff9a9e", "#fad0c4"],
"positions": ["0%", "100%"]
},
{
"name": "youngPassion",
@wking-io
wking-io / index.js
Last active September 18, 2017 20:40
Ref callback returning undefined in componentDidMount.
const Child = ({ createFormHeight, getChildRef }) => (
<CreateForm createFormHeight={createFormHeight}>
// getting reference from here
<div ref={getChildRef}>
// form markup here
</div>
</CreateForm>
);
class Parent extends Component {
@wking-io
wking-io / gist:a8f5aafd0824bd8ffa1afc7a02e687df
Last active October 4, 2017 16:46
Check User Auth Component
import React from 'react'
import { graphql, gql } from 'react-apollo';
import storage from 'store';
const isLoggedIn = ({ children, user }) => {
if(user) {
return children;
}
};
@wking-io
wking-io / acf_custom_search.php
Last active March 18, 2024 14:04
How to search a specific custom post type and the ACF fields within
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* This could easily be something that is added to the admin as a plugin so that users can
* add searchable fields in an options table
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
@wking-io
wking-io / create.bash
Last active October 5, 2017 14:22
Create New Create React App Project
npx create-react-app my-app
cd my-app/
npm start
@wking-io
wking-io / REST.txt
Created October 5, 2017 14:23
REST Book request
GET /books/:id
@wking-io
wking-io / factory.js
Last active October 11, 2017 02:59
Note to self: Remember to assign the destructured array/object an empty array/object when giving destructured function arguments default values.
const makeSandwich = ({
bread = 'wheat',
meat = 'turkey',
cheese = 'american',
toppings = []
} = {}) => ({
bread,
meat,
cheese,
toppings,
@wking-io
wking-io / header.php
Last active October 11, 2017 19:00
Add responsive background images for slider and preload them. #library #wordpress
<?php
// make sure it is the correct template
if (is_page_template( 'templates/template.php' )) :
$slider_posts = array();
// check if the repeater field has rows of data
if( have_rows('slider_posts') ) :
// loop through the rows of data
while ( have_rows('slider_posts') ) : the_row();
// display a sub field value
if (!empty(get_sub_field('the_post'))) :
@wking-io
wking-io / magical-underline.scss
Last active October 11, 2017 19:38
How do I make a magical underline that works on line breaks and can be any color I want? #library #scss
.underline--magical {
background-image: linear-gradient;
background-repeat: none;
background-size: 100% 4px; // how-thick;
background-position: 0 8px; // how-far-down;
}
@wking-io
wking-io / get-sibs.js
Last active October 10, 2018 12:32
How do I get all the siblings of an element?
const getSibs = (el) => Array
.from(el.parentNode.childNodes)
.filter(child => child.nodeType == 1 && child != el);