From 050c9270ff32c6109d666d27528723631e94a8b3 Mon Sep 17 00:00:00 2001 From: Borghild Selle <104756130+BorghildSelle@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:47:57 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8E=A8=20=20fix=20card=20and=20tsconf?= =?UTF-8?q?ig=20#2616=20(#2625)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :art: fix card and tsconfig * ✏️ Small card adjustment #2616 --------- Co-authored-by: Malin J. --- sanityv3/schemas/objects/card.tsx | 18 ++++++++---------- sanityv3/tsconfig.json | 5 +++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sanityv3/schemas/objects/card.tsx b/sanityv3/schemas/objects/card.tsx index d9a53d602..c789fdad6 100644 --- a/sanityv3/schemas/objects/card.tsx +++ b/sanityv3/schemas/objects/card.tsx @@ -1,23 +1,21 @@ /* eslint-disable react/display-name */ -import { forwardRef } from 'react' import { configureBlockContent } from '../editors' import type { PortableTextBlock } from 'sanity' -import { Stack, Text, Card } from '@sanity/ui' +import { Text, Card, Box } from '@sanity/ui' import blocksToText from '../../helpers/blocksToText' -const CardField = forwardRef((props: any) => { +const CardField = (props: any) => { + const { renderDefault } = props return ( - - - + + If only title are used it will render only title as statement. If content below are used, both title and content will be rendered. - - <>{props.renderDefault(props)} - + <>{renderDefault(props)} + ) -}) +} const blockConfig = { h2: false, diff --git a/sanityv3/tsconfig.json b/sanityv3/tsconfig.json index cac52d8e5..61c33dfa1 100644 --- a/sanityv3/tsconfig.json +++ b/sanityv3/tsconfig.json @@ -1,5 +1,10 @@ { "extends": "../tsconfig.base.json", + "compilerOptions": { + "paths": { + "react": ["./node_modules/@types/react"] + } + }, "include": ["**/*.ts", "**/*.tsx"], "exclude": ["node_modules"] } From eaa9ceb42d77db8c3d4ed3bb82f0dd99d580b813 Mon Sep 17 00:00:00 2001 From: "Malin J." Date: Fri, 1 Nov 2024 14:47:27 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Rewrite=20to=20structu?= =?UTF-8?q?retool=20from=20desktool=20#2607=20(#2613)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sanityv3/sanity.config.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sanityv3/sanity.config.tsx b/sanityv3/sanity.config.tsx index a26be3c4c..1c7ccd40e 100644 --- a/sanityv3/sanity.config.tsx +++ b/sanityv3/sanity.config.tsx @@ -18,7 +18,7 @@ import type { DocumentBadgeComponent, DocumentFieldAction, } from 'sanity' -import { deskTool, StructureBuilder } from 'sanity/desk' +import { structureTool } from 'sanity/structure' import deskStructure, { defaultDocumentNodeResolver } from './deskStructure' import { schemaTypes } from './schemas' import { initialValueTemplates } from './initialValueTemplates' @@ -88,8 +88,8 @@ const getConfig = (datasetParam: string, projectIdParam: string, isSecret = fals }, plugins: [ documentInternationalization(i18n), - deskTool({ - structure: (S: StructureBuilder, context: ConfigContext) => { + structureTool({ + structure: (S, context: ConfigContext) => { return deskStructure(S, context) }, defaultDocumentNode: defaultDocumentNodeResolver, From f702613dfb4e3bc763b3df32592fd0dbd2fb7c34 Mon Sep 17 00:00:00 2001 From: Borghild Date: Sun, 3 Nov 2024 19:44:01 +0100 Subject: [PATCH 3/3] :art: add fall back for server --- sanityv3/schemas/textSnippets.ts | 6 ++++++ web/core/Carousel/Carousel.tsx | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sanityv3/schemas/textSnippets.ts b/sanityv3/schemas/textSnippets.ts index fc1bfdbfb..62f7b057e 100644 --- a/sanityv3/schemas/textSnippets.ts +++ b/sanityv3/schemas/textSnippets.ts @@ -12,6 +12,7 @@ export const groups = { orderAnnualReportsForm: { title: 'Order annual reports form', hidden: !Flags.HAS_ORDER_REPORT_FORM }, form: { title: 'Form', hidden: !Flags.HAS_FORMS }, cookie: { title: 'Cookie' }, + carousel: { title: 'Carousel' }, others: { title: 'Others' }, } const snippets: textSnippet = { @@ -766,6 +767,11 @@ const snippets: textSnippet = { defaultValue: 'Switch to', group: groups.others, }, + carousel_controls: { + title: 'Carousel controls', + defaultValue: 'Carousel controls', + group: groups.carousel, + }, } type textSnippetGroup = { title: string; hidden?: boolean } diff --git a/web/core/Carousel/Carousel.tsx b/web/core/Carousel/Carousel.tsx index ee7f9401e..3ce34ceeb 100644 --- a/web/core/Carousel/Carousel.tsx +++ b/web/core/Carousel/Carousel.tsx @@ -27,6 +27,7 @@ import { useMediaQuery } from '../../lib/hooks/useMediaQuery' import { CarouselEventItem } from './CarouselEventItem' import { CarouselKeyNumberItem } from './CarouselKeyNumberItem' import { CarouselIframeItem } from './CarouselIframeItem' +import { FormattedMessage } from 'react-intl' export type DisplayModes = 'single' | 'scroll' export type Layouts = 'full' | 'default' @@ -357,7 +358,9 @@ export const Carousel = forwardRef(function Carousel internalAutoRotation ? 'justify-between' : 'justify-end' }`} > -
{`Carousel controls`}
+
+ +
{internalAutoRotation && ( (function Carousel title={`Go to previous`} aria-controls={carouselItemsId} mode="previous" - disabled={displayMode === 'scroll' && scrollPosition === 'start'} + disabled={(displayMode === 'scroll' && scrollPosition === 'start') ?? false} onClick={() => { if (variant === 'image' && displayMode === 'single') { loopSlidePrev() @@ -392,7 +395,7 @@ export const Carousel = forwardRef(function Carousel title={`Go to next`} mode="next" aria-controls={carouselItemsId} - disabled={displayMode === 'scroll' && scrollPosition === 'end'} + disabled={(displayMode === 'scroll' && scrollPosition === 'end') ?? false} onClick={() => { if (variant === 'image' && displayMode === 'single') { loopSlideNext()