Skip to content

Instantly share code, notes, and snippets.

@adrian-afergon
adrian-afergon / product.provider.js
Created September 15, 2020 09:37
This gist represent how to consume a GraphQL service using the porposal of React Layers
export const ProductContext = React.createContext({
product: {}
})
const ProductAdapter = ({ handle, children }) => {
const { productRepository } = React.useContext(DependenciesContext)
const [product, setProduct] = React.useState()
React.useEffect(() => {
productRepository.getProductByHandle(handle).then(setProduct)
},[handle])
@deanc
deanc / use-auth.jsx
Last active December 30, 2019 21:05 — forked from gragland/use-auth.jsx
React Hook recipe from https://usehooks.com
import React, { useState, useEffect, useContext, createContext } from "react";
import * as firebase from "firebase/app";
import "firebase/auth";
import firebaseConfig from "../config/firebase";
// Add your Firebase credentials
firebase.initializeApp(firebaseConfig);
const AuthContext = createContext();
@mglaman
mglaman / drush-loop.php
Created July 7, 2019 02:28
ReactPHP Drupal Tasks
<?php declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
function run_command(string $command): void {
$loop = React\EventLoop\Factory::create();
$process = new React\ChildProcess\Process($command);
$process->start($loop);
$process->on('exit', function ($exitCode) use ($command) {
// Trigger alerts that the command finished.
@johndevs
johndevs / get-all-files.gql
Last active March 19, 2022 20:54
Github GraphQL - Get all file contents in repository
# Provide $query as a variable.
# The query is the same as you would enter into the search field e.g. "org:johndevs in:name feedreader"
query GetFilesQuery($branch: GitObjectID, $query: String!) {
search(first: 1, type: REPOSITORY, query: $query) {
edges {
node {
... on Repository {
object(expression: "master:", oid: $branch) {
... on Tree {
@CurtisL
CurtisL / README.md
Created March 12, 2019 20:40
Dynamic ACF Gutenberg Blocks for v5.8

Dynamic ACF Gutenberg Blocks

When ACF v5.8 drops we'll have the ability to create gutenberg blocks from ACF Field Groups. This set of functions will add additional field group options to dynamcily register blocks with various block customization settings.

All you have to do is create your field groups and template.

Usage

@jackbravo
jackbravo / MediaLibraryController.php
Created November 28, 2018 22:19
Example to launch media library with a custom input
<?php
namespace Drupal\layout_manager\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Url;
/**
* Controller to render basic html for client side application.
@tonnguyen
tonnguyen / cache.middleware.js
Created February 13, 2018 21:44
A cache middleware for redux
const cache = store => next => action => {
// handle FETCH action only
if (action.type !== 'FETCH') {
return next(action);
}
// check if cache is available
const data = window['__data'];
if (!data) {
// forward the call to live middleware

Libraries and Tools for React

If you're developing an application based on React it can be helpful if you don't need to develop all the basic UI components yourself. Here you can find a list with various components, component libraries and complete design systems developed with and for React.

As the list got longer and longer I thought it would be better to have a "real" site for it.

👉 Please find the (new) list here: https://react-libs.nilshartmann.net/

<?php
namespace Drupal\waiting_queue\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command;
use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Annotations\DrupalCommand;
@miguelmota
miguelmota / index.html
Last active April 29, 2022 04:46
Hugo render from JSON file data
<!-- posts.json must be at root level -->
{{ $items := getJSON "posts.json" }}
{{ range $item := $items }}
<a href="{{ $item.url }}">{{ $item.name }}</a>
{{ end }}