diff --git a/site/src/components/Filter/filter.tsx b/site/src/components/Filter/filter.tsx index 91d8d78ee1cf4..29fb34ee4c251 100644 --- a/site/src/components/Filter/filter.tsx +++ b/site/src/components/Filter/filter.tsx @@ -22,6 +22,7 @@ import { hasError, isApiValidationError, } from "api/errors"; +import { InputGroup } from "components/InputGroup/InputGroup"; import { Loader } from "components/Loader/Loader"; import { Search, @@ -212,7 +213,7 @@ export const Filter: FC = ({ skeleton ) : ( <> -
+ filter.update(query)} presets={presets} @@ -221,7 +222,7 @@ export const Filter: FC = ({ learnMoreLink2={learnMoreLink2} /> = ({ setQueryCopy(filter.query); } }, - sx: { - borderRadius: "6px", - borderTopLeftRadius: 0, - borderBottomLeftRadius: 0, - marginLeft: "-1px", - "&:hover": { - zIndex: 2, - }, - "&.Mui-error": { - zIndex: 3, - }, - }, }} /> -
+ {options} )} @@ -288,12 +277,6 @@ const PresetMenu: FC = ({ + + + ), + }, +}; + +export const FocusedTextField: Story = { + args: { + children: ( + <> + + + + ), + }, +}; + +export const ErroredTextField: Story = { + args: { + children: ( + <> + + + + ), + }, +}; + +export const FocusedErroredTextField: Story = { + args: { + children: ( + <> + + + + ), + }, +}; + +export const WithThreeElements: Story = { + args: { + children: ( + <> + + + + + ), + }, +}; diff --git a/site/src/components/InputGroup/InputGroup.tsx b/site/src/components/InputGroup/InputGroup.tsx new file mode 100644 index 0000000000000..d6965442ee96a --- /dev/null +++ b/site/src/components/InputGroup/InputGroup.tsx @@ -0,0 +1,58 @@ +import type { FC, HTMLProps } from "react"; + +export const InputGroup: FC> = (props) => { + return ( +
*:not(:last-child)": { + marginRight: -1, + }, + + // Ensure the border of the hovered element is visible when borders + // overlap. + "& > *:hover": { + zIndex: 1, + }, + + // Display border elements when focused or in an error state, both of + // which take priority over hover. + "& .Mui-focused, & .Mui-error": { + zIndex: 2, + }, + + "& > *:first-child": { + borderTopRightRadius: 0, + borderBottomRightRadius: 0, + + "&.MuiFormControl-root .MuiInputBase-root": { + borderTopRightRadius: 0, + borderBottomRightRadius: 0, + }, + }, + + "& > *:last-child": { + borderTopLeftRadius: 0, + borderBottomLeftRadius: 0, + + "&.MuiFormControl-root .MuiInputBase-root": { + borderTopLeftRadius: 0, + borderBottomLeftRadius: 0, + }, + }, + + "& > *:not(:first-child):not(:last-child)": { + borderRadius: 0, + + "&.MuiFormControl-root .MuiInputBase-root": { + borderRadius: 0, + }, + }, + }} + /> + ); +};