Skip to content

Instantly share code, notes, and snippets.

@moxdev
moxdev / _flickity.scss
Last active September 22, 2023 07:45
Home Page Carousel with Text - Flickity Based #wp #jsLibrary
/*! Flickity v2.1.2
https://flickity.metafizzy.co
---------------------------------------------- */
.flickity-enabled {
position: relative;
}
.flickity-enabled:focus {
outline: none;
@moxdev
moxdev / postcss.config.js
Last active February 26, 2021 14:44 — forked from ryanflorence/postcss.config.js
Tailwind & CSSNANO Postcss config
module.exports = {
plugins: [
require("tailwindcss"),
require("autoprefixer"),
process.env.NODE_ENV === "production" && require("cssnano"),
].filter(Boolean),
};
@moxdev
moxdev / gatsby-browser.js
Created February 23, 2021 14:48
Console log focused elements in GatsbyJS. Add code to the `gatsby-browser.js` file.
/**
* For debugging focus in Gatsby
* @ https://flaviocopes.com/gatsby-load-external-js/
* @ https://hiddedevries.nl/en/blog/2019-01-30-console-logging-the-focused-element-as-it-changes
* @ https://stackoverflow.com/questions/1197575/can-scripts-be-inserted-with-innerhtml
*/
const addScript = () => {
const html = `<script>
document.body.addEventListener('focus', function() {
console.log('focused: ', document.activeElement)
@moxdev
moxdev / media-query.css
Created January 12, 2021 18:48 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@moxdev
moxdev / wp-custom-srcset.php
Created March 6, 2019 15:24
Srcset Custom Wordpress #wp
<img src="<?php echo esc_url( $sm_img ); ?>" alt="<?php echo esc_attr( $alt ); ?>"
srcset="
<?php echo esc_url( get_the_post_thumbnail_url( get_the_ID(), 'listing-thumb-sm' ) ); ?> 250w,
<?php echo esc_url( get_the_post_thumbnail_url( get_the_ID(), 'listing-thumb-md' ) ); ?> 550w,
<?php echo esc_url( get_the_post_thumbnail_url( get_the_ID(), 'listing-thumb-lg' ) ); ?> 850w,
<?php echo esc_url( get_the_post_thumbnail_url( get_the_ID(), 'listing-thumb-xlg' ) ); ?> 1150w">
@moxdev
moxdev / gatsby-setup-prettier-eslint-emotion-tailwindcss.md
Last active November 12, 2020 20:09
Gastby with ESLint, Prettier, Stylelint, Emotion Styled Components, Tailwindcss Basic Configs.

Gastby with ESLint, Prettier, Stylelint, Emotion Styled Components, Tailwindcss

basic configs for a new Gatsby build

Install Prettier & ESLint Dev Dependencies

npm i -D babel-eslint babel-preset-gatsby eslint eslint-config-airbnb eslint-config-prettier eslint-config-wesbos eslint-plugin-html eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks prettier

Install Tailwind, Emotion, Emotion Styled Components & Twin Macro Dependencies

@moxdev
moxdev / category.js
Created October 15, 2020 17:55
IDEA: You can create Categories (e.g. Programming Basics). Inside these you can create individual lessons (e.g. What are variables?, what are recursions?). If I want to create a Lesson inside I category now, I don't want to reference the category manually but want the category already selected for reference in the new lesson document. So there s…
import { FaListAlt } from 'react-icons/lib/fa'
export default {
title: "Category",
name: "category",
type: "document",
icon: FaListAlt,
fields: [
{
title: "Name",
@moxdev
moxdev / deskStructure.js
Created October 15, 2020 17:54
Idea: You can create Categories (e.g. Programming Basics). Inside these you can create individual lessons (e.g. What are variables?, what are recursions?).
import S from "@sanity/desk-tool/structure-builder"
import { FaFileText, FaEdit, FaComment, FaPlayCircle, FaQuestionCircle, FaCheckCircle } from 'react-icons/lib/fa'
export default () =>
S.list()
.title("App")
.items([
S.listItem()
.title("Content")
.icon(FaFileText)
@moxdev
moxdev / wp_add_img_title.php
Created December 16, 2019 18:09
Add titles to uploaded images in WordPress
/**
* Sets img title of uploaded attachment.
* If no title, will use the alt as a defualt title.
*
* @param array $attr Image tag attributes.
* @param WP_Post $attachment The WP_Post object for the attachment.
* @link https://developer.wordpress.org/reference/hooks/wp_get_attachment_image_attributes/
*
* @return array (maybe) filtered image tag attributes.
*/
@moxdev
moxdev / evoluent-verticalmouse.xml
Created November 12, 2019 18:43 — forked from patrickwelker/evoluent-verticalmouse.xml
Karabiner Template to setup a secondary function key with the Evoluent Vertical Mouse. In this example Button 6 gets assigned the following modifiers: Shift-Right, Control-Right, Option-Right and Command-Right. Import via `<include path="YOUR-PATH-HERE/evoluent-verticalmouse.xml" />`
<?xml version="1.0"?>
<root>
<item>
<name>Evoluent VerticalMouse</name>
<appendix>All customizations only apply for the Evoluent VerticalMouse.</appendix>
<appendix>Note: button 4 (the mouse scroll button) and button 5 are swapped in Karabiner. I still use the default Evoluent labeling.</appendix>
<devicevendordef>
<vendorname>EVOLUENT</vendorname>
<vendorid>0x1a7c</vendorid>
</devicevendordef>