This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const filteredObject = (name, filters = []) => ({ | |
name, | |
type: 'object', | |
fields: [ | |
{name: 'size', type: 'string', hidden: () => filters.includes('size')}, | |
{name: 'tone', type: 'string', hidden: () => filters.includes('tone')} | |
] | |
}) | |
export default { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { data, loading } = useListeningQuery( | |
query, | |
{ | |
params: params ?? {}, | |
initialData: page, | |
enabled: preview, | |
delay: 250, | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
name: 'slug', | |
title: 'Slug', | |
type: 'slug', | |
options: { | |
source: 'title', | |
isUnique: async (slug, options) => { | |
const {document: sanityDocument} = options | |
// Filter out additional parts of the _id to get the original |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-negated-condition */ | |
/* eslint-disable react/prop-types */ | |
/* eslint-disable react/display-name */ | |
/* eslint-disable max-nested-callbacks */ | |
/** | |
* inputComponent drop-in replacement for `sanity-plugin-tabs` | |
* Provided as-is with no explicit or implied future support | |
* Addresses some UI issues with that plugin, but may introduce others | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable react/prop-types */ | |
/** | |
* This is a Custom Input POC for a Reference field with defined search parameters on the target document | |
* The built-in reference field currently can filter results but only statically, not using the search query | |
* | |
* This custom input is NOT recommended as it lacks some of the amazing features of the built-in reference field | |
* It's also a bit wonky in terms of the UI, but it's a start | |
* ...and it does solve this one specific use case | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Custom Input that will resolve Sanity's default UI for field editing | |
* As well as display some contextual information from the document | |
* This is example is for an `array` field of `car` type fields | |
* For which the default UI is shown below an image from the first array item | |
* | |
* The implementation is *not* bulletproof and only has basic handling | |
* of the potential pitfalls of recursive rendering of the | |
* <FormBuilderInput /> component | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState} from 'react' | |
import {Box, Text, Container, Card, Stack, Flex} from '@sanity/ui' | |
import subDays from 'date-fns/subDays' | |
import {format} from 'date-fns' | |
import DateTimeInput from 'part:@sanity/form-builder' | |
export default function DateTimeDisplay() { | |
const [fromDate, setFromDate] = useState(subDays(new Date(), 1)) | |
const [toDate, setToDate] = useState(new Date()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import {Box, Card, Container, Text} from '@sanity/ui' | |
import {useCurrentUser} from './useCurrentUser' | |
export default function SuperSecretTool() { | |
const {roles} = useCurrentUser() | |
const isAdmin = roles?.length ? roles.find((role) => role?.name === 'administrator') : false | |
if (!isAdmin) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import {withDocument} from 'part:@sanity/form-builder' | |
import {Stack, Card, Flex, Text} from '@sanity/ui' | |
import {format} from 'date-fns' | |
const WORD_LENGTH = 5 | |
function Guess({char, answer, index}) { | |
const answerSplit = answer.split('') | |
let tone = `default` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import {Stack, Card, Flex, Switch, Label, Box, Text, Autocomplete, Button} from '@sanity/ui' | |
import {AddIcon, TrashIcon} from '@sanity/icons' | |
import {daysOfTheWeek, hoursOfTheDay} from './data' | |
export default function TradingHours() { | |
// Update how trading times are searched for | |
const handleAutocompleteFilter = (query, option) => { | |
// Treat a search for 1.00 as 1:00 |