Skip to content

Instantly share code, notes, and snippets.

View domitriusclark's full-sized avatar
🏃‍♂️
Lost in the code

Domitrius domitriusclark

🏃‍♂️
Lost in the code
View GitHub Profile
/* eslint-disable object-curly-spacing */
import { Command, flags } from '@oclif/command'
const { prompt } = require("enquirer")
const copy = require("copy-template-dir")
const path = require("path")
const fs = require("fs")
const util = require("util")
class Mycli extends Command {
import React from 'react';
import { useDropzone } from 'react-dropzone';
import { useUpload } from '../hooks/useCloudinary';
import {
Text,
Button,
Input,
InputGroup,
InputRightElement,
@domitriusclark
domitriusclark / useSearch.js
Created June 25, 2020 14:47
useSearch describes a way to handle piping options to a serverless endpoint that actually handles the search
import { useMutation } from 'react-query';
import fetch from 'isomorphic-unfetch';
export default function useSearch({ endpoint } = {}) {
if (!endpoint) {
throw new Error("Must provide an endpoint to search");
}
let expressionConfig = "";
function Image({ publicId, transformations, width, height, alt }) {
const { generateUrl, url, status, error } = useImage({ cloudName: 'testing-hooks-upload' });
React.useEffect(() => {
// Now instead of getImage, we call the `generateUrl` function, better describing the action we're taking internally and what to expect back
generateUrl({
publicId,
transformations: {
// by supplying height and width seperately from the transformations object,
// we can use the height and width to dictate the size of the element AND the transformations
@domitriusclark
domitriusclark / useSearch.test.js
Created April 29, 2020 06:58
single test from useSearch
it('updates data to an array on successful request', async () => {
let server = new Server({
routes() {
this.post("/example-endpoint", () => ({
resources: [
{ id: 1, public_id: "image1" },
{ id: 2, public_id: "image2" },
{ id: 3, public_id: "image3" }
]
}));
@domitriusclark
domitriusclark / ImageUpload.js
Created April 2, 2020 15:18
Image Upload to cloudinary
/** @jsx jsx */
import { css, jsx } from '@emotion/core';
import React from 'react';
import { useMutation, gql } from '@apollo/client';
import { useDropzone } from 'react-dropzone';
const UPLOAD_IMAGE_TO_CLOUDINARY = gql`
mutation UploadImageToCloudinary($file: String! $uploadOptions: UploadOptionsInput){
uploadImage(file: $file uploadOptions: $uploadOptions) {
public_id
import React, { Component } from 'react';
import './App.css';
const ShowingYourName = (props) => {
return (
<p>{props.firstName}</p>
)
}
class App extends Component {