Skip to content

Commit

Permalink
[field] Move components to "components" directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent d564445 commit 11b005f
Show file tree
Hide file tree
Showing 35 changed files with 38 additions and 33 deletions.
5 changes: 0 additions & 5 deletions packages/@sanity/field/src/diff/annotations/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
export * from './hooks'
export * from './helpers'
export * from './DiffAnnotation'
export * from './DiffAnnotationCard'
export * from './DiffAnnotationTooltip'
export * from './DiffAnnotationTooltipContent'
export * from './AnnotatedStringDiff'
3 changes: 0 additions & 3 deletions packages/@sanity/field/src/diff/changes/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import {StringDiffSegment, StringDiff} from '../../types'
import {DiffAnnotation} from '../annotations'
import {DiffAnnotation} from './DiffAnnotation'
import styles from './AnnotatedStringDiff.css'

function FormattedPreviewText({
Expand Down
3 changes: 2 additions & 1 deletion packages/@sanity/field/src/diff/components/Change.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react'
import {Path} from '../../paths'
import {PreviewComponent as IPreviewComponent} from '../../preview/types'
import {DiffAnnotationTooltip, getAnnotationAtPath, useAnnotationColor} from '../annotations'
import {getAnnotationAtPath, useAnnotationColor} from '../annotations'
import {Diff, SchemaType} from '../../types'
import {getChangeVerb} from '../helpers'
import {ChangeLayout} from './ChangeLayout'
import {DiffAnnotationTooltip} from './DiffAnnotationTooltip'

import styles from './Change.css'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {Fragment} from 'react'
import {ChangeTitlePath, FieldChangeNode} from '../../types'
import {ChangeTitleSegment} from './ChangeTitleSegment'

import styles from './ChangeBreadcrumb.css'

export function ChangeBreadcrumb({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import ArrowIcon from 'part:@sanity/base/arrow-right'

import styles from './ChangeLayout.css'

export interface ChangeLayoutProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'
import {ObjectDiff, ObjectSchemaType, ChangeNode} from '../../types'
import {Path} from '../../paths'
import {DiffContext} from '../context/DiffContext'
import {buildObjectChangeList} from './buildChangeList'
import {buildObjectChangeList} from '../changes/buildChangeList'
import {ChangeResolver} from './ChangeResolver'

interface Props {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as React from 'react'
import {FromToIndex, Annotation, FieldChangeNode} from '../../types'
import {DiffAnnotation, DiffAnnotationCard} from '../annotations'
import {DiffAnnotation} from './DiffAnnotation'
import {DiffAnnotationCard} from './DiffAnnotationCard'

import styles from './ChangeTitleSegment.css'

export function ChangeTitleSegment({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {useUserColorManager} from '@sanity/base/user-color'
import * as React from 'react'
import {getAnnotationAtPath, getAnnotationColor} from '../annotations'
import {Annotation, Diff, Path} from '../../types'
import {DiffAnnotationTooltip} from './DiffAnnotationTooltip'
import {getAnnotationAtPath, getAnnotationColor} from './helpers'

export interface AnnotationProps {
annotation: Annotation | undefined | null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, {createElement} from 'react'
import {Diff, Annotation} from '../../types'
import {getAnnotationAtPath, useAnnotationColor} from '../annotations'
import {Path} from '../../paths'
import {useAnnotationColor} from './hooks'
import {Diff, Annotation} from '../../types'
import {AnnotationProps, AnnotatedDiffProps} from './DiffAnnotation'
import {getAnnotationAtPath} from './helpers'

interface BaseDiffAnnotationCardProps {
as?: React.ElementType | keyof JSX.IntrinsicElements
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Tooltip} from 'part:@sanity/components/tooltip'
import React, {createElement} from 'react'
import {getAnnotationAtPath} from '../annotations'
import {DiffAnnotationTooltipContent} from './DiffAnnotationTooltipContent'
import {AnnotationProps, AnnotatedDiffProps} from './DiffAnnotation'
import {getAnnotationAtPath} from './helpers'

interface BaseAnnotationProps {
as?: React.ElementType | keyof JSX.IntrinsicElements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import {useUser, useTimeAgo} from '@sanity/base/hooks'
import {UserAvatar} from '@sanity/base/components'
import {useUserColorManager} from '@sanity/base/user-color'
import {AnnotationDetails} from '../../types'
import {getAnnotationColor} from '../annotations'

import styles from './DiffAnnotationTooltipContent.css'
import {getAnnotationColor} from './helpers'

export function DiffAnnotationTooltipContent({
annotations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import Preview from 'part:@sanity/base/preview'
import {PreviewComponent} from '../../preview/types'
import {DiffComponent} from '../../types'
import {Change} from '../components'
import {Change} from './Change'

import styles from './FallbackDiff.css'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {useDocumentOperation} from '@sanity/react-hooks'
import classNames from 'classnames'
import React, {useCallback, useContext, useState} from 'react'
import {FieldChangeNode, OperationsAPI} from '../../types'
import {undoChange} from '../changes/undoChange'
import {DiffContext} from '../context/DiffContext'
import {FallbackDiff} from '../fallback/FallbackDiff'
import {ValueError} from './ValueError'
import {FieldChangeNode, OperationsAPI} from '../../types'
import {ChangeBreadcrumb} from './ChangeBreadcrumb'
import {DiffErrorBoundary} from './DiffErrorBoundary'
import {DiffInspectWrapper} from './DiffInspectWrapper'
import {DocumentChangeContext} from './DocumentChangeContext'
import {FallbackDiff} from './FallbackDiff'
import {RevertChangesButton} from './RevertChangesButton'
import {undoChange} from './undoChange'
import {ValueError} from './ValueError'

import styles from './FieldChange.css'
import {DiffInspectWrapper} from './DiffInspectWrapper'
import {ChangeBreadcrumb} from './ChangeBreadcrumb'

export function FieldChange({change}: {change: FieldChangeNode}) {
const DiffComponent = change.diffComponent || FallbackDiff
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import * as React from 'react'
import classNames from 'classnames'
import {useDocumentOperation} from '@sanity/react-hooks'
import {undoChange} from '../changes/undoChange'
import {isFieldChange} from '../helpers'
import {isPTSchemaType} from '../../types/portableText/diff'
import {useHover} from '../../utils/useHover'
import {GroupChangeNode, OperationsAPI} from '../../types'
import {isFieldChange} from '../helpers'
import {useHover} from '../../utils/useHover'
import {ChangeBreadcrumb} from './ChangeBreadcrumb'
import {ChangeResolver} from './ChangeResolver'
import {DocumentChangeContext} from './DocumentChangeContext'
import {RevertChangesButton} from './RevertChangesButton'
import {undoChange} from './undoChange'

import styles from './GroupChange.css'

export function GroupChange({change: group}: {change: GroupChangeNode}): React.ReactElement {
Expand Down
10 changes: 9 additions & 1 deletion packages/@sanity/field/src/diff/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export * from './AnnotatedStringDiff'
export * from './Change'
export * from './ChangeLayout'
export * from './ChangeList'
export * from './ChangeResolver'
export * from './DiffAnnotation'
export * from './DiffAnnotationCard'
export * from './DiffAnnotationTooltip'
export * from './DiffAnnotationTooltipContent'
export * from './DocumentChangeContext'
export * from './MetaInfo'
export * from './Change'
3 changes: 1 addition & 2 deletions packages/@sanity/field/src/diff/hooks/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {useState, useEffect} from 'react'
import client from 'part:@sanity/base/client'
import {observeForPreview} from 'part:@sanity/base/preview'
import {Reference, SchemaType} from '../../types'
import {noop} from '../helpers'

interface PreviewSnapshot {
title: string
Expand All @@ -12,7 +11,7 @@ export function useRefValue<T = unknown>(refId: string | undefined | null): T |
const [value, setValue] = useState<T | undefined>(undefined)
useEffect(() => {
if (!refId) {
return noop
return undefined
}

const subscription = client.observable.getDocument(refId).subscribe(setValue)
Expand Down
4 changes: 2 additions & 2 deletions packages/@sanity/field/src/diff/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from '../types'

export * from './annotations'
export * from './changes'
export * from './resolve'
export * from './components'
export * from './helpers'
export * from './resolve'

0 comments on commit 11b005f

Please sign in to comment.