From b05fa4f7571c85915d5bf9d533c809edb4b42779 Mon Sep 17 00:00:00 2001 From: Adam Krebs Date: Sun, 21 May 2023 23:02:09 -0400 Subject: [PATCH] Bold changed props --- .../src/propEditors/simpleEditors/ImagePropEditor.tsx | 4 +++- .../src/propEditors/simpleEditors/NumberPropEditor.tsx | 1 + .../src/propEditors/simpleEditors/RgbaPropEditor.tsx | 6 +++++- .../simpleEditors/StringLiteralPropEditor.tsx | 2 ++ .../src/propEditors/simpleEditors/StringPropEditor.tsx | 2 ++ .../studio/src/uiComponents/form/BasicNumberInput.tsx | 6 +++++- theatre/studio/src/uiComponents/form/BasicSelect.tsx | 7 ++++++- .../studio/src/uiComponents/form/BasicStringInput.tsx | 10 +++++++--- theatre/studio/src/uiComponents/form/BasicSwitch.tsx | 7 ++++++- 9 files changed, 37 insertions(+), 8 deletions(-) diff --git a/theatre/studio/src/propEditors/simpleEditors/ImagePropEditor.tsx b/theatre/studio/src/propEditors/simpleEditors/ImagePropEditor.tsx index 7724d11d55..60cbb13a23 100644 --- a/theatre/studio/src/propEditors/simpleEditors/ImagePropEditor.tsx +++ b/theatre/studio/src/propEditors/simpleEditors/ImagePropEditor.tsx @@ -32,7 +32,7 @@ const AddImage = styled.div` background-size: 5px 5px; ` -const InputLabel = styled.label<{empty: boolean}>` +const InputLabel = styled.label<{empty: boolean; changed: boolean}>` position: relative; cursor: default; box-sizing: border-box; @@ -43,6 +43,7 @@ const InputLabel = styled.label<{empty: boolean}>` justify-content: center; align-items: center; font-size: 16px; + font-weight: ${(props) => (props.changed ? 'bold' : 'normal')}; overflow: hidden; color: #ccc; @@ -138,6 +139,7 @@ function ImagePropEditor({ ((props) => ({ border-radius: 99999px; ` -const HexInput = styled(BasicStringInput)` +const HexInput = styled(BasicStringInput)<{defaultValue: string}>` flex: 1; ` @@ -61,6 +61,7 @@ const RgbaPopover = styled.div` ` function RgbaPropEditor({ + propConfig, editingTools, value, autoFocus, @@ -109,6 +110,9 @@ function RgbaPropEditor({ /> ({ return propConfig.as === 'menu' ? ( ({ ) : ( ) diff --git a/theatre/studio/src/uiComponents/form/BasicNumberInput.tsx b/theatre/studio/src/uiComponents/form/BasicNumberInput.tsx index 8398427e12..3c6bfd32b7 100644 --- a/theatre/studio/src/uiComponents/form/BasicNumberInput.tsx +++ b/theatre/studio/src/uiComponents/form/BasicNumberInput.tsx @@ -40,7 +40,7 @@ const Container = styled.div` } ` -const Input = styled.input` +const Input = styled.input<{defaultValue: number}>` background: transparent; border: 1px solid transparent; color: rgba(255, 255, 255, 0.9); @@ -52,6 +52,8 @@ const Input = styled.input` width: 100%; height: calc(100% - 4px); border-radius: 2px; + font-weight: ${(props) => + props.value === props.defaultValue ? 'normal' : 'bold'}; &:focus { cursor: text; @@ -107,6 +109,7 @@ const BasicNumberInput: React.FC<{ discardTemporaryValue: () => void permanentlySetValue: (v: number) => void className?: string + defaultValue: number range?: [min: number, max: number] isValid?: (v: number) => boolean inputRef?: MutableRefObject @@ -308,6 +311,7 @@ const BasicNumberInput: React.FC<{ type="text" onChange={callbacks.inputChange} value={value} + defaultValue={propsA.defaultValue} onBlur={callbacks.onBlur} onKeyDown={callbacks.onInputKeyDown} onClick={callbacks.onClick} diff --git a/theatre/studio/src/uiComponents/form/BasicSelect.tsx b/theatre/studio/src/uiComponents/form/BasicSelect.tsx index abfec78db1..dc6b8f82dd 100644 --- a/theatre/studio/src/uiComponents/form/BasicSelect.tsx +++ b/theatre/studio/src/uiComponents/form/BasicSelect.tsx @@ -20,7 +20,7 @@ const IconContainer = styled.div` pointer-events: none; ` -const Select = styled.select` +const Select = styled.select<{defaultValue: string}>` appearance: none; background-color: transparent; box-sizing: border-box; @@ -37,6 +37,8 @@ const Select = styled.select` So we're hard-coding the height to 26px, unlike all other inputs that use a relative height. */ height: 26px /* calc(100% - 4px); */; + font-weight: ${(props) => + props.value === props.defaultValue ? 'normal' : 'bold'}; @supports (-moz-appearance: none) { /* Ugly hack to remove the extra left padding that shows up only in Firefox */ @@ -52,12 +54,14 @@ const Select = styled.select` function BasicSelect({ value, + defaultValue, onChange, options, className, autoFocus, }: { value: TLiteralOptions + defaultValue: TLiteralOptions onChange: (val: TLiteralOptions) => void options: Record className?: string @@ -75,6 +79,7 @@ function BasicSelect({