Skip to content

Instantly share code, notes, and snippets.

@3200pro
3200pro / DarkModeImages.js
Last active July 19, 2020 20:58
Gatsby +Sanity: Darkmode image that allow alternate image (Sanity Schema Code)
/** @jsx jsx */
import { jsx, useColorMode } from "theme-ui"
import { buildImageObj } from '../../lib/helpers'
import { imageUrlFor } from '../../lib/image-url'
function DarkModeImage (props) {
const [colorMode] = useColorMode()
const SanityImageToggle = (colorMode == 'light') ? props.primaryImage : props.darkmodeImage
return (
<figure>
@3200pro
3200pro / Figure.js
Last active February 9, 2021 22:52
Figure Ternary Setup For Gatsby & Sanity
import React from 'react'
import { getFluidGatsbyImage } from 'gatsby-source-sanity'
import Img from 'gatsby-image'
import { buildImageObj } from '../../lib/helpers'
import { imageUrlFor } from '../../lib/image-url'
import clientConfig from '../../../client-config'
function Figure(props) {
const data = props
@3200pro
3200pro / figure.js
Created July 12, 2020 23:00
Sanity CMS Figure Schema
export default {
name: "figure",
title: "Image",
type: "image",
options: {
hotspot: true,
},
fields: [
{
title: "Caption",