review refactor

This commit is contained in:
Sultan committed 2022-11-06 13:05:02 +03:00
1 parent cd2d244d5d
commit 63b9d5a0de
2 files changed
+16 -14

No files matched your search

@@ -266,8 +266,7 @@ export const CssValueInput = ({
});
const shouldHandleEvent = useCallback((node) => {
if (suffixRef.current?.contains?.(node)) return false;
return true;
return !suffixRef.current?.contains?.(node);
}, []);
const [scrubRef, inputRef, isInputActive] = useScrub({
value,
@@ -293,7 +292,7 @@ export const CssValueInput = ({
const isCurrentBreakpoint = useIsFromCurrentBreakpoint(property);
const prefix = icon && (
<TextFieldIconButton state={isCurrentBreakpoint ? "highlight" : undefined}>
<TextFieldIconButton state={isCurrentBreakpoint ? "set" : undefined}>
{icon}
</TextFieldIconButton>
);
@@ -328,7 +327,6 @@ export const CssValueInput = ({
onKeyDown={handleKeyDown}
baseRef={scrubRef}
inputRef={inputRef}
suffixRef={suffixRef}
name={property}
state={
value.type === "invalid"
@@ -55,7 +55,7 @@ export const TextFieldIconButton = styled(
color: "white",
},
},
highlight: {
set: {
backgroundColor: "$blue4",
color: "$blue11",
"&:hover": {
@@ -63,6 +63,14 @@ export const TextFieldIconButton = styled(
color: "$blue11",
},
},
inherited: {
backgroundColor: "$orange4",
color: "$orange11",
"&:hover": {
backgroundColor: "$orange4",
color: "$orange11",
},
},
},
},
},
@@ -250,9 +258,7 @@ export type TextFieldProps = Pick<
"variant" | "state" | "css"
> &
Omit<React.ComponentProps<"input">, "prefix" | "children"> & {
suffixRef?: React.Ref<HTMLDivElement>;
prefixRef?: React.Ref<HTMLDivElement>;
baseRef?: React.Ref<HTMLDivElement>;
fieldRef?: React.Ref<HTMLDivElement>;
inputRef?: React.Ref<HTMLInputElement>;
prefix?: React.ReactNode;
suffix?: React.ReactNode;
@@ -264,9 +270,7 @@ export const TextField = React.forwardRef<HTMLDivElement, TextFieldProps>(
prefix,
css,
disabled,
prefixRef,
suffixRef,
baseRef,
fieldRef,
inputRef,
state,
variant: variantProp,
@@ -311,7 +315,7 @@ export const TextField = React.forwardRef<HTMLDivElement, TextFieldProps>(
<TextFieldBase
{...focusWithinProps}
aria-disabled={disabled}
ref={mergeRefs(forwardedRef, baseRef ?? null)}
ref={mergeRefs(forwardedRef, fieldRef ?? null)}
state={state}
variant={variant}
css={css}
@@ -328,8 +332,8 @@ export const TextField = React.forwardRef<HTMLDivElement, TextFieldProps>(
ref={mergeRefs(internalInputRef, inputRef ?? null)}
/>
{prefix && <PrefixSlot ref={prefixRef}>{prefix}</PrefixSlot>}
{suffix && <SuffixSlot ref={suffixRef}>{suffix}</SuffixSlot>}
{prefix && <PrefixSlot>{prefix}</PrefixSlot>}
{suffix && <SuffixSlot>{suffix}</SuffixSlot>}
</TextFieldBase>
);
}