From 3a0906b864a3682ac6471149a3272bb563b4dbf1 Mon Sep 17 00:00:00 2001 From: "Malin J." Date: Mon, 7 Oct 2024 10:05:10 +0200 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20Cleanup=20#2545=20(?= =?UTF-8?q?#2546)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fieldActions/CustomCopyFieldAction.ts | 7 +--- .../src/BrandmasterAssetSource.tsx | 13 ++----- .../asset-source-fotoware/src/components.tsx | 2 +- sanityv3/sanity.config.tsx | 3 +- .../EventPromotion/EventPromotionInput.tsx | 2 +- sanityv3/schemas/documents/localNewsTag.tsx | 14 +++---- sanityv3/schemas/editors/blockContentType.tsx | 9 ----- sanityv3/schemas/objects/anchorLink.tsx | 9 +---- .../schemas/objects/anchorReferenceField.tsx | 22 +++++------ .../schemas/objects/cookieDeclaration.tsx | 8 +--- .../objects/grid/cellTypes/gridTeaser.tsx | 2 +- sanityv3/schemas/objects/grid/index.tsx | 6 +-- .../objects/imageWithAltAndCaption.tsx | 1 - sanityv3/schemas/objects/newsList.tsx | 39 ++++++++++--------- sanityv3/schemas/objects/stockValuesApi.tsx | 9 +---- sanityv3/schemas/objects/transcript.tsx | 1 - sanityv3/src/previews/Preview.tsx | 19 ++++----- sanityv3/src/previews/PreviewWrapper.tsx | 31 +++++++-------- sanityv3/src/previews/file/filePreview.tsx | 11 ++---- web/pageComponents/search/SearchResults.tsx | 2 +- web/pageComponents/shared/MagazineTagBar.tsx | 28 ------------- .../shared/siteMenu/MenuGroup.tsx | 10 ----- web/sections/Grid/GridLinkArrow.tsx | 1 - web/types/eventTypes.ts | 2 - 24 files changed, 81 insertions(+), 170 deletions(-) diff --git a/sanityv3/actions/fieldActions/CustomCopyFieldAction.ts b/sanityv3/actions/fieldActions/CustomCopyFieldAction.ts index 3d9d84eb0..df21306ef 100644 --- a/sanityv3/actions/fieldActions/CustomCopyFieldAction.ts +++ b/sanityv3/actions/fieldActions/CustomCopyFieldAction.ts @@ -1,11 +1,8 @@ import { CopyIcon } from '@sanity/icons' -import { Toast, useToast } from '@sanity/ui' +import { useToast } from '@sanity/ui' import { useCallback } from 'react' -import { defineDocumentFieldAction } from 'sanity' -import { useTranslation } from 'sanity' -import { useCopyPaste } from 'sanity' -import { useGetFormValue } from 'sanity' +import { defineDocumentFieldAction, useTranslation, useCopyPaste, useGetFormValue } from 'sanity' import { type FormDocumentValue } from 'sanity' export const copyAction = defineDocumentFieldAction({ diff --git a/sanityv3/plugins/asset-source-brandmaster/src/BrandmasterAssetSource.tsx b/sanityv3/plugins/asset-source-brandmaster/src/BrandmasterAssetSource.tsx index b1f36868c..dff8975b1 100644 --- a/sanityv3/plugins/asset-source-brandmaster/src/BrandmasterAssetSource.tsx +++ b/sanityv3/plugins/asset-source-brandmaster/src/BrandmasterAssetSource.tsx @@ -1,16 +1,11 @@ import { useEffect, useCallback, forwardRef, useState, useRef } from 'react' import { createPortal } from 'react-dom' import { Dialog } from '@sanity/ui' -import styled from 'styled-components' const BM_EVENT_NAME = 'dam:plugin-assets-selected-event' const BM_URL = process.env.SANITY_STUDIO_BRANDMASTER_URL || '' const BM_SOURCE = BM_URL + process.env.SANITY_STUDIO_BRANDMASTER_PLUGIN_SOURCE || '' -const Content = styled.div` - margin: 2em; -` - const BrandmasterAssetSource = forwardRef((props: any, ref) => { const { onSelect, onClose } = props @@ -81,17 +76,17 @@ const BrandmasterAssetSource = forwardRef((props: any, ref) => { {container && createPortal(props.children, container)} {BM_SOURCE ? ( - +

Select an image from Brandmaster in the popup window.

Once selected, the upload process should start automatically.

- +
) : ( - +

No Brandmaster source URL found. Please define the URL and path in the enviromental variables to load the iframe.

- +
)} ) diff --git a/sanityv3/plugins/asset-source-fotoware/src/components.tsx b/sanityv3/plugins/asset-source-fotoware/src/components.tsx index f95a536be..b06fd11f4 100644 --- a/sanityv3/plugins/asset-source-fotoware/src/components.tsx +++ b/sanityv3/plugins/asset-source-fotoware/src/components.tsx @@ -87,7 +87,7 @@ export const FotowareWidget = forwardRef((p ref={ref} > - + ) diff --git a/sanityv3/sanity.config.tsx b/sanityv3/sanity.config.tsx index 9e5528892..a26be3c4c 100644 --- a/sanityv3/sanity.config.tsx +++ b/sanityv3/sanity.config.tsx @@ -8,7 +8,7 @@ import { PluginOptions, SchemaTypeDefinition, Template, -} from 'sanity' + buildLegacyTheme } from 'sanity' import type { InputProps, @@ -39,7 +39,6 @@ import { createCustomDuplicateAction } from './actions/CustomDuplicateAction' import { LangBadge } from './schemas/components/LangBadge' import './customStyles.css' import { partialStudioTheme } from './studioTheme' -import { buildLegacyTheme } from 'sanity' import { copyAction } from './actions/fieldActions/CustomCopyFieldAction' export const customTheme = buildLegacyTheme(partialStudioTheme) diff --git a/sanityv3/schemas/components/EventPromotion/EventPromotionInput.tsx b/sanityv3/schemas/components/EventPromotion/EventPromotionInput.tsx index 7059be82b..13bb42b0e 100644 --- a/sanityv3/schemas/components/EventPromotion/EventPromotionInput.tsx +++ b/sanityv3/schemas/components/EventPromotion/EventPromotionInput.tsx @@ -1,4 +1,4 @@ -import { Text, Card, Grid, Stack, Heading, Radio, Inline, Flex, Switch, TextInput } from '@sanity/ui' +import { Text, Card, Grid, Stack, Heading, Radio, Inline, Flex, Switch } from '@sanity/ui' import { set, MemberField } from 'sanity' import { getObjectMemberField } from '../utils/getObjectMemberField' import type { ObjectInputProps } from 'sanity' diff --git a/sanityv3/schemas/documents/localNewsTag.tsx b/sanityv3/schemas/documents/localNewsTag.tsx index 8609f8013..e73d6339e 100644 --- a/sanityv3/schemas/documents/localNewsTag.tsx +++ b/sanityv3/schemas/documents/localNewsTag.tsx @@ -1,24 +1,20 @@ import { languages } from '../../languages' import type { CurrentUser } from 'sanity' -import styled from 'styled-components' import { EdsIcon } from '../../icons' import { tag_more } from '@equinor/eds-icons' -const StyledSpan = styled.span` - display: block; - margin-top: 0.5em; -` - const LocalNewsTagDescription = () => ( <> - The translated names used to display the tag on the web and generate the slugs. - + + The translated names used to display the tag on the web and generate the slugs. + + ⚠️ {' '} Since these values are used to automatically generate slugs; they should only be changed if you know what you are doing. - + ) diff --git a/sanityv3/schemas/editors/blockContentType.tsx b/sanityv3/schemas/editors/blockContentType.tsx index 27f0aba9b..14d944d4f 100644 --- a/sanityv3/schemas/editors/blockContentType.tsx +++ b/sanityv3/schemas/editors/blockContentType.tsx @@ -57,15 +57,6 @@ export const ExtraLargeTextRender = (props: any) => { const { children } = props return {children} } -const Level2BaseStyle = (props: any) => { - const { children } = props - return

{children}

-} - -const Level3BaseStyle = (props: any) => { - const { children } = props - return

{children}

-} // H1 not allowed in block content since it should be a document title. export const configureBlockContent = (options: BlockContentProps = {}): BlockDefinition => { diff --git a/sanityv3/schemas/objects/anchorLink.tsx b/sanityv3/schemas/objects/anchorLink.tsx index a3ab61cce..e16dc8ff5 100644 --- a/sanityv3/schemas/objects/anchorLink.tsx +++ b/sanityv3/schemas/objects/anchorLink.tsx @@ -4,24 +4,19 @@ import { Rule } from 'sanity' import { validateComponentAnchor } from '../validations/validateAnchorReference' import { EdsIcon } from '../../icons' import { Heading, Text, Box } from '@sanity/ui' -import styled from 'styled-components' export type AnchorLink = { _type: 'anchorLink' } -const StyledText = styled(Text)` - margin: 1em 0; -` - const Description = () => { return ( How to use - + Add this component before the component for which you want to have an anchor reference. The anchor reference will be ignored when there is no component following it. - + ) } diff --git a/sanityv3/schemas/objects/anchorReferenceField.tsx b/sanityv3/schemas/objects/anchorReferenceField.tsx index dffee3928..9ceb108c0 100644 --- a/sanityv3/schemas/objects/anchorReferenceField.tsx +++ b/sanityv3/schemas/objects/anchorReferenceField.tsx @@ -1,28 +1,26 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { validateAnchorReference } from '../validations/validateAnchorReference' -import styled from 'styled-components' import { Rule } from 'sanity' -const StyledSpan = styled.span` - display: block; - margin-top: 0.3em; -` - export const AnchorComponentDescription = () => ( <> - Add an optional anchor reference that can be used to link directly to this component. - + + Add an optional anchor reference that can be used to link directly to this component. + + Allowed characters are: letters, numbers, hyphens, and underscores. The # symbol is not needed. - + ) + export const AnchorLinkDescription = () => ( <> - Optional: add the anchor reference of the component/section you want to link directly to. - Results cannot be guaranteed for external URLs. + + Optional: add the anchor reference of the component/section you want to link directly to. + + Results cannot be guaranteed for external URLs. ) - export default { name: 'anchorReferenceField', title: 'Anchor reference', diff --git a/sanityv3/schemas/objects/cookieDeclaration.tsx b/sanityv3/schemas/objects/cookieDeclaration.tsx index 8cf60fbd8..b1f3a644b 100644 --- a/sanityv3/schemas/objects/cookieDeclaration.tsx +++ b/sanityv3/schemas/objects/cookieDeclaration.tsx @@ -1,23 +1,19 @@ import { table_chart } from '@equinor/eds-icons' import { EdsIcon } from '../../icons' import { Heading, Text, Box } from '@sanity/ui' -import styled from 'styled-components' import CompactBlockEditor from '../components/CompactBlockEditor' import { configureTitleBlockContent } from '../editors' -const StyledText = styled(Text)` - margin: 1em 0; -` const titleContentType = configureTitleBlockContent() // eslint-disable-next-line react/display-name const ApiDescription = () => { return ( How to use - + This component will automatically display cookies identified in the website. No configuration is required. This component is to be used on Cookie Policy page. - + ) } diff --git a/sanityv3/schemas/objects/grid/cellTypes/gridTeaser.tsx b/sanityv3/schemas/objects/grid/cellTypes/gridTeaser.tsx index 6468cdbe6..f09351f69 100644 --- a/sanityv3/schemas/objects/grid/cellTypes/gridTeaser.tsx +++ b/sanityv3/schemas/objects/grid/cellTypes/gridTeaser.tsx @@ -3,7 +3,7 @@ import blocksToText from '../../../../helpers/blocksToText' import { configureBlockContent, configureThemedTitleBlockContent } from '../../../editors' import { validateCharCounterEditor } from '../../../validations/validateCharCounterEditor' -import type { PortableTextBlock, Reference, Rule, ValidationContext } from 'sanity' +import type { PortableTextBlock, Reference, Rule } from 'sanity' import type { DownloadableImage } from './../../downloadableImage' import type { DownloadableFile } from '../../files' import type { ImageWithAlt } from '../../imageWithAlt' diff --git a/sanityv3/schemas/objects/grid/index.tsx b/sanityv3/schemas/objects/grid/index.tsx index 34a32bd06..06473b143 100644 --- a/sanityv3/schemas/objects/grid/index.tsx +++ b/sanityv3/schemas/objects/grid/index.tsx @@ -1,6 +1,7 @@ import { PortableTextBlock } from 'sanity' import { EdsIcon } from '../../../icons' import { table_chart } from '@equinor/eds-icons' +import blocksToText from '../../../helpers/blocksToText' export type Grid = { _type: 'grid' @@ -51,10 +52,9 @@ export default { title: 'title', }, prepare({ title = [] }: { title: PortableTextBlock[] }) { - const plainTitle = 'Grid' - + const plainTitle = blocksToText(title) return { - title: plainTitle, + title: plainTitle || 'Grid', subtitle: 'Grid component', media: () => EdsIcon(table_chart), } diff --git a/sanityv3/schemas/objects/imageWithAltAndCaption.tsx b/sanityv3/schemas/objects/imageWithAltAndCaption.tsx index eb2866a83..856f94487 100644 --- a/sanityv3/schemas/objects/imageWithAltAndCaption.tsx +++ b/sanityv3/schemas/objects/imageWithAltAndCaption.tsx @@ -1,5 +1,4 @@ import type { ImageWithAlt } from './imageWithAlt' -import type { Rule } from 'sanity' export type ImageWithAltAndCaption = { _type: 'imageWithAltAndCaption' diff --git a/sanityv3/schemas/objects/newsList.tsx b/sanityv3/schemas/objects/newsList.tsx index 895ca4179..2f875cd96 100644 --- a/sanityv3/schemas/objects/newsList.tsx +++ b/sanityv3/schemas/objects/newsList.tsx @@ -3,32 +3,33 @@ import { EdsIcon } from '../../icons' import { list } from '@equinor/eds-icons' import { configureTitleBlockContent } from '../editors' import CompactBlockEditor from '../components/CompactBlockEditor' -import { Heading, Text, Box } from '@sanity/ui' -import styled from 'styled-components' +import { Card, Text, Box, Stack } from '@sanity/ui' import type { Rule } from 'sanity' const titleContentType = configureTitleBlockContent() -const StyledText = styled(Text)` - margin: 1em 0; -` - // eslint-disable-next-line react/display-name const ComponentDescription = () => { return ( - - How to use - - This component will automatically generate a list of news articles based on the tags you select. - - - - ⚠️ - - Please note that there is no limit on this list: it will generate a list of all articles that - match the selected tag(s). - - + + + + + How to use + + + This component will automatically generate a list of news articles based on the tags you select. + + + + ⚠️ + + Please note that there is no limit on this list: it will generate a list of all articles + that match the selected tag(s). + + + + ) } diff --git a/sanityv3/schemas/objects/stockValuesApi.tsx b/sanityv3/schemas/objects/stockValuesApi.tsx index 76bcfbaeb..06c8c966e 100644 --- a/sanityv3/schemas/objects/stockValuesApi.tsx +++ b/sanityv3/schemas/objects/stockValuesApi.tsx @@ -1,22 +1,17 @@ import { dollar } from '@equinor/eds-icons' import { Box, Heading, Text } from '@sanity/ui' -import styled from 'styled-components' import { EdsIcon } from '../../icons' import type { ColorSelectorValue } from '../components/ColorSelector' -const StyledText = styled(Text)` - margin: 1em 0; -` - // eslint-disable-next-line react/display-name const ApiDescription = () => { return ( How to use - + This component will automatically display up to date Equinor stock values from the OSE and NYSE. No configuration is required. - + ) } diff --git a/sanityv3/schemas/objects/transcript.tsx b/sanityv3/schemas/objects/transcript.tsx index 6c4a74681..2794db0d2 100644 --- a/sanityv3/schemas/objects/transcript.tsx +++ b/sanityv3/schemas/objects/transcript.tsx @@ -1,4 +1,3 @@ -import { defineType, defineField } from 'sanity' import { configureBlockContent } from '../editors/blockContentType' import CompactBlockEditor from '../components/CompactBlockEditor' diff --git a/sanityv3/src/previews/Preview.tsx b/sanityv3/src/previews/Preview.tsx index 1f25ac394..9c45018ca 100644 --- a/sanityv3/src/previews/Preview.tsx +++ b/sanityv3/src/previews/Preview.tsx @@ -1,15 +1,7 @@ import resolveProductionUrl from '../../resolveProductionUrl' -import styled from 'styled-components' import { dataset } from '../lib/datasetHelpers' import { PreviewWrapper } from './PreviewWrapper' -const Frame = styled.iframe` - border: 0; - height: 100%; - left: 0; - width: 100%; -` - const REQUIRES_SLUG = ['news', 'localNews', 'magazine'] export default function Preview({ document }: any) { @@ -33,7 +25,16 @@ export default function Preview({ document }: any) { return ( - +