From ee1ace877562d6c826b71f06d6571c8c3e217e5c Mon Sep 17 00:00:00 2001 From: Rico Kahler Date: Wed, 17 Apr 2024 17:05:54 -0500 Subject: [PATCH] test: add sanity-plugin-hotspot-array --- dev/test-studio/package.json | 1 + dev/test-studio/sanity.config.ts | 2 + dev/test-studio/schema/index.ts | 3 + .../schema/plugins/hotspotArray.tsx | 61 +++++++++++++++++++ dev/test-studio/structure/constants.ts | 1 + pnpm-lock.yaml | 56 +++++++++++++++++ 6 files changed, 124 insertions(+) create mode 100644 dev/test-studio/schema/plugins/hotspotArray.tsx diff --git a/dev/test-studio/package.json b/dev/test-studio/package.json index 045f5094f99b..d813d2b2f0cb 100644 --- a/dev/test-studio/package.json +++ b/dev/test-studio/package.json @@ -63,6 +63,7 @@ "refractor": "^3.6.0", "rxjs": "^7.8.0", "sanity": "workspace:*", + "sanity-plugin-hotspot-array": "^2.0.0", "sanity-plugin-mux-input": "^2.2.1", "styled-components": "^6.1.0", "three": "^0.157.0", diff --git a/dev/test-studio/sanity.config.ts b/dev/test-studio/sanity.config.ts index 4ee5b21795a3..8433f5950e87 100644 --- a/dev/test-studio/sanity.config.ts +++ b/dev/test-studio/sanity.config.ts @@ -14,6 +14,7 @@ import {visionTool} from '@sanity/vision' import {defineConfig, definePlugin, type WorkspaceOptions} from 'sanity' import {presentationTool} from 'sanity/presentation' import {structureTool} from 'sanity/structure' +import {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array' import {muxInput} from 'sanity-plugin-mux-input' import {imageAssetSource} from './assetSources' @@ -133,6 +134,7 @@ const sharedSettings = definePlugin({ }), // eslint-disable-next-line camelcase muxInput({mp4_support: 'standard'}), + imageHotspotArrayPlugin(), presenceTool(), routerDebugTool(), tsdoc(), diff --git a/dev/test-studio/schema/index.ts b/dev/test-studio/schema/index.ts index 0b54264a0cd0..ca071b19a8f6 100644 --- a/dev/test-studio/schema/index.ts +++ b/dev/test-studio/schema/index.ts @@ -82,6 +82,7 @@ import playlistTrack from './playlistTrack' import code from './plugins/code' import color from './plugins/color' import geopoint from './plugins/geopoint' +import {hotspot, hotspotArrayTest} from './plugins/hotspotArray' import species from './species' import arrays, {topLevelArrayType, topLevelPrimitiveArrayType} from './standard/arrays' import booleans from './standard/booleans' @@ -253,6 +254,8 @@ export const schemaTypes = [ codeInputType, color, geopoint, + hotspot, + hotspotArrayTest, // Test documents with 3rd party plugin inputs markdown, diff --git a/dev/test-studio/schema/plugins/hotspotArray.tsx b/dev/test-studio/schema/plugins/hotspotArray.tsx new file mode 100644 index 000000000000..d2f7721efff0 --- /dev/null +++ b/dev/test-studio/schema/plugins/hotspotArray.tsx @@ -0,0 +1,61 @@ +import {defineField, defineType, type Rule} from 'sanity' + +export const hotspot = defineType({ + name: 'hotspot', + type: 'object', + fieldsets: [{name: 'position', options: {columns: 2}}], + fields: [ + {name: 'details', type: 'text', rows: 2}, + { + name: 'x', + type: 'number', + readOnly: true, + fieldset: 'position', + initialValue: 50, + validation: (Rule: Rule) => Rule.required().min(0).max(100), + }, + { + name: 'y', + type: 'number', + readOnly: true, + fieldset: 'position', + initialValue: 50, + validation: (Rule: Rule) => Rule.required().min(0).max(100), + }, + ], + preview: { + select: { + title: 'details', + x: 'x', + y: 'y', + }, + prepare({title, x, y}: any) { + return { + title, + subtitle: x && y ? `${x}% x ${y}%` : `No position set`, + } + }, + }, +}) + +export const hotspotArrayTest = defineType({ + name: 'hotspotArrayTest', + type: 'document', + fields: [ + defineField({name: 'title', type: 'string'}), + defineField({name: 'featureImage', type: 'image'}), + defineField({ + name: 'hotspots', + type: 'array', + of: [{type: 'hotspot'}], + options: { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore nbd + imageHotspot: { + imagePath: 'featureImage', + descriptionPath: 'details', + }, + }, + }), + ], +}) diff --git a/dev/test-studio/structure/constants.ts b/dev/test-studio/structure/constants.ts index 3ce03acf5bf6..ed6d657ecb50 100644 --- a/dev/test-studio/structure/constants.ts +++ b/dev/test-studio/structure/constants.ts @@ -29,6 +29,7 @@ export const PLUGIN_INPUT_TYPES = [ 'codeTest', 'colorTest', 'geopointTest', + 'hotspotArrayTest', //'orderableCategory', //'orderableTag', ] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c03de42d3c3d..f41caf1031cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -518,6 +518,9 @@ importers: sanity: specifier: workspace:* version: link:../../packages/sanity + sanity-plugin-hotspot-array: + specifier: ^2.0.0 + version: 2.0.0(@sanity/ui@2.1.3)(react-dom@18.2.0)(react@18.2.0)(sanity@packages+sanity)(styled-components@6.1.8) sanity-plugin-mux-input: specifier: ^2.2.1 version: 2.3.4(@types/react@18.2.78)(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0)(sanity@packages+sanity)(styled-components@6.1.8) @@ -6376,6 +6379,15 @@ packages: - supports-color dev: false + /@sanity/types@3.38.0: + resolution: {integrity: sha512-eBMnX21GJ2+aUAFC4Ddg+RhsyBjRGQXs/DfiDp50FctHn9MngCFoPQjExFet3TkoBg4jy6PJfjFzsUat0/Dyng==} + dependencies: + '@sanity/client': 6.15.14 + '@types/react': 18.2.78 + transitivePeerDependencies: + - supports-color + dev: false + /@sanity/ui-workshop@1.2.11(@sanity/icons@2.11.8)(@sanity/ui@2.1.3)(@types/node@18.19.31)(react-dom@18.2.0)(react@18.2.0)(styled-components@6.1.8): resolution: {integrity: sha512-vzj7upIF7wq2W1HEA0D5VSkR8axaH4Rt07yNTAaas7CLgjSE9r2d+Gnkrq4FIbIuN1GYhhCD+D3/s60GaZrpQw==} hasBin: true @@ -6448,6 +6460,19 @@ packages: - supports-color dev: false + /@sanity/util@3.38.0: + resolution: {integrity: sha512-9LeZWNtpgdWBu5MWzeNtLNtf/EU04+Cno5/DOaxxSLlP76f9iRGCmCPdEViU1GupIuDRRC3itJstjvCWFIs7Vg==} + engines: {node: '>=18'} + dependencies: + '@sanity/client': 6.15.14 + '@sanity/types': 3.38.0 + get-random-values-esm: 1.0.2 + moment: 2.30.1 + rxjs: 7.8.1 + transitivePeerDependencies: + - supports-color + dev: false + /@sanity/uuid@3.0.2: resolution: {integrity: sha512-vzdhqOrX7JGbMyK40KuIwwyXHm7GMLOGuYgn3xlC09e4ZVNofUO5mgezQqnRv0JAMthIRhofqs9f6ufUjMKOvw==} dependencies: @@ -6982,6 +7007,12 @@ packages: resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} dev: true + /@types/lodash-es@4.17.12: + resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==} + dependencies: + '@types/lodash': 4.17.0 + dev: false + /@types/lodash.isequal@4.5.8: resolution: {integrity: sha512-uput6pg4E/tj2LGxCZo9+y27JNyB2OZuuI/T5F+ylVDYuqICLG2/ktjxx0v6GvVntAf8TvEzeQLcV0ffRirXuA==} dependencies: @@ -16736,6 +16767,31 @@ packages: '@sanity/diff-match-patch': 3.1.1 dev: false + /sanity-plugin-hotspot-array@2.0.0(@sanity/ui@2.1.3)(react-dom@18.2.0)(react@18.2.0)(sanity@packages+sanity)(styled-components@6.1.8): + resolution: {integrity: sha512-y+FP4JgRaIKO17cBMyzCCVcxwl3fh7DXEp99QlvZSWUFi3NJJg2ZXFIXc2Om66HNkprfH2ORzEmEZMuDShtlTg==} + engines: {node: '>=18'} + peerDependencies: + '@sanity/ui': ^2.0.0 + react: ^18 + sanity: ^3.0.0 + styled-components: ^6.1 + dependencies: + '@sanity/asset-utils': 1.3.0 + '@sanity/image-url': 1.0.2 + '@sanity/incompatible-plugin': 1.0.4(react-dom@18.2.0)(react@18.2.0) + '@sanity/ui': 2.1.3(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0)(styled-components@6.1.8) + '@sanity/util': 3.38.0 + '@types/lodash-es': 4.17.12 + framer-motion: 11.0.8(react-dom@18.2.0)(react@18.2.0) + lodash-es: 4.17.21 + react: 18.2.0 + sanity: link:packages/sanity + styled-components: 6.1.8(react-dom@18.2.0)(react@18.2.0) + transitivePeerDependencies: + - react-dom + - supports-color + dev: false + /sanity-plugin-mux-input@2.3.4(@types/react@18.2.78)(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0)(sanity@packages+sanity)(styled-components@6.1.8): resolution: {integrity: sha512-GHIFWKXDzYIZreeC/ExEsaIBU7ATgAfjacB8Yo9SN2K1C9YMhdHYbl8S+aCa2QcmrmvHtkAKG3oukg/U0JfUCQ==} engines: {node: '>=14'}