Skip to content

Commit

Permalink
[field] Update diff layout
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent db508af commit f42f395
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 48 deletions.
2 changes: 1 addition & 1 deletion packages/@sanity/field/src/diff/components/DiffFromTo.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.card {
display: block;
/* display: block; */
}
4 changes: 4 additions & 0 deletions packages/@sanity/field/src/diff/components/FromTo.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
.root {
display: flex;
align-items: center;

@nest &[data-from-to-layout='inline'] {
display: inline-flex;
}

@nest &[data-from-to-layout='grid'] {
Expand All @@ -14,6 +16,8 @@

.from,
.to {
max-width: calc(50% - 13px);

@nest .root[data-from-to-layout='grid'] & {
flex: 1;
min-width: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import 'part:@sanity/base/theme/variables-style';

.card {
display: inline-block;
padding: calc(var(--small-padding) - 2px) var(--small-padding) calc(var(--small-padding) - 1px);
word-break: break-all;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import React from 'react'
import {DiffComponent, DiffFromTo, NumberDiff} from '../../../diff'
import {NumberPreview} from '../preview/NumberPreview'

import styles from './NumberFieldDiff.css'

export const NumberFieldDiff: DiffComponent<NumberDiff> = ({diff, schemaType}) => {
return (
<DiffFromTo
cardClassName={styles.card}
diff={diff}
schemaType={schemaType}
previewComponent={NumberPreview}
Expand Down
11 changes: 0 additions & 11 deletions packages/@sanity/field/src/types/number/preview/NumberPreview.css

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react'
import {PreviewComponent} from '../../../preview/types'

import styles from './NumberPreview.css'

export const NumberPreview: PreviewComponent<string> = props => {
const {value} = props

return <span className={styles.root}>{value}</span>
return <>{value}</>
}
7 changes: 7 additions & 0 deletions packages/@sanity/field/src/types/slug/diff/SlugFieldDiff.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import 'part:@sanity/base/theme/variables-style';

.card {
display: inline-block;
padding: calc(var(--small-padding) - 2px) var(--small-padding) calc(var(--small-padding) - 1px);
word-break: break-all;
}
10 changes: 9 additions & 1 deletion packages/@sanity/field/src/types/slug/diff/SlugFieldDiff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import React from 'react'
import {DiffComponent, DiffFromTo, ObjectDiff} from '../../../diff'
import {SlugPreview} from '../preview'

import styles from './SlugFieldDiff.css'

interface Slug {
current?: string
}

export const SlugFieldDiff: DiffComponent<ObjectDiff<Slug>> = ({diff, schemaType}) => {
return (
<DiffFromTo layout="grid" diff={diff} schemaType={schemaType} previewComponent={SlugPreview} />
<DiffFromTo
cardClassName={styles.card}
layout="inline"
diff={diff}
schemaType={schemaType}
previewComponent={SlugPreview}
/>
)
}
12 changes: 0 additions & 12 deletions packages/@sanity/field/src/types/slug/preview/SlugPreview.css

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import React from 'react'
import {PreviewComponent} from '../../../preview/types'
import {Slug} from '../types'

import styles from './SlugPreview.css'

export const SlugPreview: PreviewComponent<Slug> = props => {
const {value} = props

return <span className={styles.root}>{value.current}</span>
return <>{value.current}</>
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
@import 'part:@sanity/base/theme/variables-style';

.root {
word-break: break-all;
}

.card {
display: inline-block;
padding: calc(var(--small-padding) - 2px) var(--small-padding) calc(var(--small-padding) - 1px);
word-break: break-all;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ export const StringFieldDiff: DiffComponent<StringDiff> = ({diff, schemaType}) =
if (options?.list) {
// When the string is considered to be an "enum", don't show individual
// string segment changes, rather treat is as a "from -> to" diff
return <DiffFromTo diff={diff} previewComponent={StringPreview} schemaType={schemaType} />
return (
<DiffFromTo
cardClassName={styles.card}
diff={diff}
previewComponent={StringPreview}
schemaType={schemaType}
/>
)
}

return (
Expand Down
12 changes: 0 additions & 12 deletions packages/@sanity/field/src/types/string/preview/StringPreview.css

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react'
import {PreviewComponent} from '../../../preview/types'

import styles from './StringPreview.css'

export const StringPreview: PreviewComponent<string> = props => {
const {value} = props

return <span className={styles.root}>{value}</span>
return <>{value}</>
}
7 changes: 7 additions & 0 deletions packages/@sanity/field/src/types/url/diff/UrlFieldDiff.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import 'part:@sanity/base/theme/variables-style';

.card {
display: inline-block;
padding: calc(var(--small-padding) - 2px) var(--small-padding) calc(var(--small-padding) - 1px);
word-break: break-all;
}
11 changes: 10 additions & 1 deletion packages/@sanity/field/src/types/url/diff/UrlFieldDiff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import React from 'react'
import {DiffComponent, DiffFromTo, StringDiff} from '../../../diff'
import {StringPreview} from '../../string/preview'

import styles from './UrlFieldDiff.css'

export const UrlFieldDiff: DiffComponent<StringDiff> = ({diff, schemaType}) => {
return <DiffFromTo diff={diff} schemaType={schemaType} previewComponent={StringPreview} />
return (
<DiffFromTo
cardClassName={styles.card}
diff={diff}
schemaType={schemaType}
previewComponent={StringPreview}
/>
)
}

0 comments on commit f42f395

Please sign in to comment.