Skip to content

Commit

Permalink
[base] Make it possible to hide change indicators through props
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin authored and rexxars committed Oct 6, 2020
1 parent d4d5078 commit 94ff0cf
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export function ChangeIndicatorProvider(props: {

interface CoreProps {
className?: string
hidden?: boolean
fullPath: Path
compareDeep: boolean
value: unknown
Expand All @@ -117,6 +118,7 @@ interface CoreProps {

export const CoreChangeIndicator = ({
className,
hidden,
fullPath,
value,
compareValue,
Expand All @@ -128,7 +130,9 @@ export const CoreChangeIndicator = ({
const isChanged =
(canCompareShallow(value, compareValue) && value !== compareValue) ||
(compareDeep && !deepCompare(value, compareValue))

if (hidden) {
return <>{children}</>
}
return (
<ChangeBarWrapper
className={className}
Expand All @@ -143,6 +147,7 @@ export const CoreChangeIndicator = ({

export const ChangeIndicatorWithProvidedFullPath = ({
className,
hidden,
path,
value,
hasFocus,
Expand All @@ -154,6 +159,7 @@ export const ChangeIndicatorWithProvidedFullPath = ({
const fullPath = parentContext.fullPath.concat(path)
return (
<CoreChangeIndicator
hidden={hidden}
className={className}
value={value}
compareValue={PathUtils.get(parentContext.compareValue, path)}
Expand Down

0 comments on commit 94ff0cf

Please sign in to comment.