Skip to content

Instantly share code, notes, and snippets.

View petertenhoor's full-sized avatar
🔥

Peter ten Hoor petertenhoor

🔥
View GitHub Profile
@petertenhoor
petertenhoor / FitText.js
Created March 11, 2020 09:37
Fitty implementation in React
import fitty from "fitty"
import PropTypes from "prop-types"
import Parser from "html-react-parser"
import {PureComponent} from "react"
class FitText extends PureComponent {
/**
* Define default value for reference element
*/
@petertenhoor
petertenhoor / css-only-radio-switch.scss
Last active October 6, 2019 19:19
CSS only radio button switch
.switch-field {
overflow: hidden;
input[type="radio"] {
display: none;
&:checked + label {
background-color: $color-light-orange;
border-color: $color-primary-orange;
z-index: 2;
@petertenhoor
petertenhoor / QuantityInput.js
Created July 20, 2019 15:32
Simple quantity input JS class
class QuantityInput {
/**
* QuantityInput constructor
*
* @param $inputElement
* @param $plusElement
* @param $minusElement
*/
constructor($inputElement = null, $plusElement = null, $minusElement = null) {
//validations
@petertenhoor
petertenhoor / download-attribute-fallback.js
Created June 25, 2019 08:03
Simple ES5 fallback for download attribute (IE11)
(function () {
'use strict';
//handle browsers that do not support download attribute
if (Modernizr.adownload === false) {
//get array of all links and area's with download attributes
var $downloadElements = Array.prototype.slice.call(document.querySelectorAll('a[download], area[download]'));
//remove download attributes
@petertenhoor
petertenhoor / GraphqlCachComponent.php
Created February 19, 2019 21:42
WP GraphQL serverside caching example
<?php
namespace PTH;
/**
* Class GraphqlCacheComponent
*
* @package PTH
*/
class GraphqlCacheComponent extends Singleton