diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 656272a4ff1..e934853352d 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -65,6 +65,7 @@ const config = { { ignores: { componentPatterns: ['motion$'], + attributes: ['animate', 'closed', 'exit', 'fill', 'full', 'initial', 'size'], }, }, ], @@ -231,6 +232,43 @@ const config = { '@sanity/i18n/no-attribute-template-literals': 'off', }, }, + + // Prefer local components vs certain @sanity/ui imports (in sanity package) + { + files: ['packages/sanity/**'], + rules: { + 'no-restricted-imports': [ + 'error', + { + paths: [ + { + name: '@sanity/ui', + importNames: [ + 'Button', + 'ButtonProps', + 'Dialog', + 'DialogProps', + 'MenuButton', + 'MenuButtonProps', + 'MenuGroup', + 'MenuGroupProps', + 'MenuItem', + 'MenuItemProps', + 'Popover', + 'PopoverProps', + 'Tab', + 'TabProps', + 'Tooltip', + 'TooltipProps', + ], + message: + 'Please use the (more opinionated) exported components in sanity/src/ui-components instead.', + }, + ], + }, + ], + }, + }, ], } diff --git a/dev/design-studio/package.json b/dev/design-studio/package.json index 123d1be11fc..c354ba2326a 100644 --- a/dev/design-studio/package.json +++ b/dev/design-studio/package.json @@ -31,8 +31,8 @@ "start": "../.bin/sanity start --port 4000" }, "dependencies": { - "@sanity/icons": "^2.6.0", - "@sanity/ui": "^1.9.3", + "@sanity/icons": "^2.8.0", + "@sanity/ui": "2.0.0-beta.13", "react": "^18.2.0", "react-dom": "^18.2.0", "sanity": "3.22.1", diff --git a/dev/embedded-studio/package.json b/dev/embedded-studio/package.json index d467a011742..9e3ec765075 100644 --- a/dev/embedded-studio/package.json +++ b/dev/embedded-studio/package.json @@ -8,7 +8,7 @@ "preview": "vite preview" }, "dependencies": { - "@sanity/ui": "1.9.3", + "@sanity/ui": "2.0.0-beta.13", "react": "^18.2.0", "react-dom": "^18.2.0", "sanity": "3.22.1", diff --git a/dev/studio-e2e-testing/components-api/index.tsx b/dev/studio-e2e-testing/components-api/index.tsx index ac797358e66..9eb2a9b4082 100644 --- a/dev/studio-e2e-testing/components-api/index.tsx +++ b/dev/studio-e2e-testing/components-api/index.tsx @@ -28,7 +28,6 @@ const childComponents = definePlugin({ studio: { components: { layout: (props) => , - logo: (props) => , navbar: (props) => , toolMenu: (props) => ( @@ -58,7 +57,6 @@ export const customComponents = definePlugin({ studio: { components: { layout: (props) => , - logo: (props) => , navbar: (props) => , toolMenu: (props) => , }, diff --git a/dev/studio-e2e-testing/package.json b/dev/studio-e2e-testing/package.json index d0b5995ea38..64340949939 100644 --- a/dev/studio-e2e-testing/package.json +++ b/dev/studio-e2e-testing/package.json @@ -15,8 +15,8 @@ ], "dependencies": { "@sanity/google-maps-input": "^3.0.1", - "@sanity/icons": "^2.4.0", - "@sanity/ui": "^1.9.3", + "@sanity/icons": "^2.8.0", + "@sanity/ui": "2.0.0-beta.13", "@sanity/vision": "3.22.1", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/dev/test-studio/components/Branding.tsx b/dev/test-studio/components/Branding.tsx deleted file mode 100644 index 5180a5ba5e5..00000000000 --- a/dev/test-studio/components/Branding.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import {Box, Text} from '@sanity/ui' -import React from 'react' -import {useTranslation} from 'sanity' - -export function Branding() { - const {t} = useTranslation('testStudio') - return ( - - {t('studio.logo.title')}™ - - ) -} diff --git a/dev/test-studio/components/documentViews/jsonPreview.tsx b/dev/test-studio/components/documentViews/jsonPreview.tsx index 48497f0bbc3..5edc24dc6f3 100644 --- a/dev/test-studio/components/documentViews/jsonPreview.tsx +++ b/dev/test-studio/components/documentViews/jsonPreview.tsx @@ -1,10 +1,14 @@ -import {Card, Code} from '@sanity/ui' +import {Box, Card, Code} from '@sanity/ui' import React from 'react' export function JSONPreviewDocumentView(props: any) { return ( - - {JSON.stringify(props.document.displayed, null, 2)} + + + + {JSON.stringify(props.document.displayed, null, 2)} + + ) } diff --git a/dev/test-studio/components/formComponents.tsx b/dev/test-studio/components/formComponents.tsx index 00a78fce7e5..0b970318189 100644 --- a/dev/test-studio/components/formComponents.tsx +++ b/dev/test-studio/components/formComponents.tsx @@ -78,6 +78,13 @@ export function Preview(props: PreviewProps) { ) } +export function CustomBadge() { + return { + label: 'Hello world', + title: 'Hello I am a custom document badge', + } +} + export const formComponentsPlugin = definePlugin({ name: 'form-components-plugin', form: { diff --git a/dev/test-studio/components/panes/debug/DebugPane.tsx b/dev/test-studio/components/panes/debug/DebugPane.tsx index f25884a3302..769e894a506 100644 --- a/dev/test-studio/components/panes/debug/DebugPane.tsx +++ b/dev/test-studio/components/panes/debug/DebugPane.tsx @@ -51,16 +51,16 @@ export const DebugPane: UserComponent = function DebugPane(props) { return ( - - - + + + Random ID: {randomId} Assigned on pane component mount - + @@ -74,15 +74,17 @@ export const DebugPane: UserComponent = function DebugPane(props) { > - + - ChildLink + + ChildLink + - + @@ -98,15 +100,17 @@ export const DebugPane: UserComponent = function DebugPane(props) { > - + - ParameterizedLink + + ParameterizedLink + - + diff --git a/dev/test-studio/locales/index.ts b/dev/test-studio/locales/index.ts index b3e0a2e3fa4..5d36073f428 100644 --- a/dev/test-studio/locales/index.ts +++ b/dev/test-studio/locales/index.ts @@ -3,7 +3,6 @@ import {defineLocaleResourceBundle} from 'sanity' export const testStudioLocaleNamespace = 'testStudio' as const const enUSStrings = { - 'studio.logo.title': 'English logo', 'structure.root.title': 'Content 🇺🇸', 'translate.example': ' Your search for "{{keyword}}" took {{duration}}ms', @@ -20,7 +19,6 @@ const nbNO = defineLocaleResourceBundle({ locale: 'nb-NO', namespace: testStudioLocaleNamespace, resources: { - 'studio.logo.title': 'Norsk logo', 'structure.root.title': 'Innhold 🇳🇴', 'translate.example': ' Ditt søk pÃ¥ "{{keyword}}" tok {{duration}} millisekunder', diff --git a/dev/test-studio/package.json b/dev/test-studio/package.json index cd3be4a19b5..4d952b693a2 100644 --- a/dev/test-studio/package.json +++ b/dev/test-studio/package.json @@ -23,19 +23,20 @@ "@sanity/assist": "^1.0.8", "@sanity/block-tools": "3.22.1", "@sanity/client": "^6.10.0", - "@sanity/color": "^2.1.20", + "@sanity/color": "3.0.0-beta.9", "@sanity/google-maps-input": "^3.0.1", - "@sanity/icons": "^2.6.0", + "@sanity/icons": "^2.8.0", "@sanity/image-url": "^1.0.2", "@sanity/locale-ko-kr": "^1.0.0", "@sanity/locale-nb-no": "^1.0.0", "@sanity/locale-nn-no": "^1.0.0", "@sanity/locale-pt-pt": "^1.0.0", "@sanity/locale-sv-se": "^1.0.0", + "@sanity/logos": "^2.0.2", "@sanity/portable-text-editor": "3.22.1", "@sanity/tsdoc": "1.0.0-alpha.38", "@sanity/types": "3.22.1", - "@sanity/ui": "^1.9.3", + "@sanity/ui": "2.0.0-beta.13", "@sanity/ui-workshop": "^1.0.0", "@sanity/util": "3.22.1", "@sanity/uuid": "^3.0.1", diff --git a/dev/test-studio/sanity.config.ts b/dev/test-studio/sanity.config.ts index 7b787a31b28..935e9e49b22 100644 --- a/dev/test-studio/sanity.config.ts +++ b/dev/test-studio/sanity.config.ts @@ -1,4 +1,5 @@ import {BookIcon} from '@sanity/icons' +import {SanityMonogram} from '@sanity/logos' import {visionTool} from '@sanity/vision' import {defineConfig, definePlugin} from 'sanity' import {deskTool} from 'sanity/desk' @@ -13,7 +14,6 @@ import {ptPTLocale} from '@sanity/locale-pt-pt' import {svSELocale} from '@sanity/locale-sv-se' import {theme as tailwindTheme} from './sanity.theme.mjs' import {imageAssetSource} from './assetSources' -import {Branding} from './components/Branding' import {resolveDocumentActions as documentActions} from './documentActions' import {resolveInitialValueTemplates} from './initialValueTemplates' import {languageFilter} from './plugins/language-filter' @@ -31,6 +31,7 @@ import { import { Annotation, Block, + CustomBadge, Field, formComponentsPlugin, InlineBlock, @@ -62,11 +63,6 @@ const sharedSettings = definePlugin({ assetSources: [imageAssetSource], }, }, - studio: { - components: { - logo: Branding, - }, - }, i18n: { bundles: testStudioLocaleBundles, @@ -93,6 +89,7 @@ const sharedSettings = definePlugin({ unstable_comments: { enabled: true, }, + badges: (prev, context) => (context.schemaType === 'author' ? [CustomBadge, ...prev] : prev), }, plugins: [ // ...localePlugins, @@ -148,6 +145,7 @@ export default defineConfig([ dataset: 'test', plugins: [sharedSettings()], basePath: '/test', + icon: SanityMonogram, }, { name: 'tsdoc', diff --git a/dev/test-studio/schema/book.ts b/dev/test-studio/schema/book.ts index 738957b4c37..b9d29e24272 100644 --- a/dev/test-studio/schema/book.ts +++ b/dev/test-studio/schema/book.ts @@ -88,6 +88,18 @@ export default { }, ], }, + { + name: 'genre', + title: 'Genre', + type: 'string', + options: { + list: [ + {title: 'Fiction', value: 'fiction'}, + {title: 'Non Fiction', value: 'nonfiction'}, + {title: 'Poetry', value: 'poetry'}, + ], + }, + }, ], orderings: [ { diff --git a/examples/ecommerce-studio/package.json b/examples/ecommerce-studio/package.json index 4b0cc001e2d..b3fa92da9a0 100644 --- a/examples/ecommerce-studio/package.json +++ b/examples/ecommerce-studio/package.json @@ -30,7 +30,7 @@ }, "dependencies": { "@sanity/cli": "3.22.1", - "@sanity/ui": "^1.9.3", + "@sanity/ui": "2.0.0-beta.13", "react": "^18.2.0", "react-barcode": "^1.4.1", "react-dom": "^18.2.0", diff --git a/packages/@sanity/portable-text-editor/package.json b/packages/@sanity/portable-text-editor/package.json index ed9c87b43d5..cdc6045fda3 100644 --- a/packages/@sanity/portable-text-editor/package.json +++ b/packages/@sanity/portable-text-editor/package.json @@ -78,7 +78,7 @@ "@playwright/test": "^1.39.0", "@portabletext/toolkit": "^2.0.10", "@sanity/diff-match-patch": "^3.1.1", - "@sanity/ui": "^1.9.3", + "@sanity/ui": "2.0.0-beta.13", "@testing-library/react": "^13.4.0", "@types/debug": "^4.1.5", "@types/express": "^4.16.1", diff --git a/packages/@sanity/vision/package.json b/packages/@sanity/vision/package.json index 69e4ef9280f..f972dcaf905 100644 --- a/packages/@sanity/vision/package.json +++ b/packages/@sanity/vision/package.json @@ -65,9 +65,9 @@ "@lezer/highlight": "^1.0.0", "@rexxars/react-json-inspector": "^8.0.1", "@rexxars/react-split-pane": "^0.1.93", - "@sanity/color": "^2.1.20", - "@sanity/icons": "^2.6.0", - "@sanity/ui": "^1.9.3", + "@sanity/color": "3.0.0-beta.9", + "@sanity/icons": "^2.8.0", + "@sanity/ui": "2.0.0-beta.13", "@uiw/react-codemirror": "^4.11.4", "hashlru": "^2.3.0", "is-hotkey": "^0.1.6", diff --git a/packages/@sanity/vision/src/components/VisionGui.styled.tsx b/packages/@sanity/vision/src/components/VisionGui.styled.tsx index db48befc52a..617513c1033 100644 --- a/packages/@sanity/vision/src/components/VisionGui.styled.tsx +++ b/packages/@sanity/vision/src/components/VisionGui.styled.tsx @@ -1,5 +1,5 @@ import styled, {css} from 'styled-components' -import {Button, Card, Box, Flex, Label, Theme, rem} from '@sanity/ui' +import {Card, Box, Flex, Label, rem} from '@sanity/ui' export const Root = styled(Flex)` .sidebarPanes .Pane { @@ -154,7 +154,3 @@ export const TimingsTextContainer = styled(Flex)` export const ControlsContainer = styled(Box)` border-top: 1px solid var(--card-border-color); ` - -export const ButtonFullWidth = styled(Button)` - width: 100%; -` diff --git a/packages/@sanity/vision/src/components/VisionGui.tsx b/packages/@sanity/vision/src/components/VisionGui.tsx index cfdc1bb484f..f4b27e46ba6 100644 --- a/packages/@sanity/vision/src/components/VisionGui.tsx +++ b/packages/@sanity/vision/src/components/VisionGui.tsx @@ -50,7 +50,6 @@ import { ResultContainer, Result, ControlsContainer, - ButtonFullWidth, TimingsFooter, TimingsCard, TimingsTextContainer, @@ -765,11 +764,7 @@ export class VisionGui extends React.PureComponent - {t('action.copy-url-to-clipboard')} - - } + content={t('action.copy-url-to-clipboard')} >