Skip to content

Commit

Permalink
[field] Fix FromTo showing arrow regardless of "from" value
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 6, 2020
1 parent 6434a6a commit c1ea634
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions packages/@sanity/field/src/diff/components/FromTo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,29 @@ import {FromToArrow} from './FromToArrow'

import styles from './FromTo.css'

export interface FromToProps {
export type FromToProps = {
align?: 'top' | 'center' | 'bottom'
layout?: 'grid' | 'inline'
from?: React.ReactNode
to?: React.ReactNode
}
} & Omit<React.HTMLProps<HTMLDivElement>, 'children'>

export const FromTo = forwardRef(
(
{
align = 'top',
className,
layout = 'inline',
from,
to,
...restProps
}: FromToProps & Omit<React.HTMLProps<HTMLDivElement>, 'children'>,
ref
) => {
export const FromTo = forwardRef<HTMLDivElement, FromToProps>(
({align = 'top', className, layout = 'inline', from, to, ...restProps}, ref) => {
return (
<div
{...restProps}
className={classNames(styles.root, className)}
data-from-to-align={align}
data-from-to-layout={layout}
ref={ref as any}
ref={ref}
>
<div className={styles.column}>{from}</div>
<FromToArrow className={styles.arrow} />
{from && (
<>
<div className={styles.column}>{from}</div>
<FromToArrow className={styles.arrow} />
</>
)}
<div className={styles.column}>{to}</div>
</div>
)
Expand Down

0 comments on commit c1ea634

Please sign in to comment.