diff --git a/apps/hash-frontend/src/pages/index.page/waitlisted/early-access-modal.tsx b/apps/hash-frontend/src/pages/index.page/waitlisted/early-access-modal.tsx index 9d535cbce4a..6ee43ff0292 100644 --- a/apps/hash-frontend/src/pages/index.page/waitlisted/early-access-modal.tsx +++ b/apps/hash-frontend/src/pages/index.page/waitlisted/early-access-modal.tsx @@ -9,6 +9,7 @@ import { Button } from "../../../shared/ui/button"; import { MenuItem } from "../../../shared/ui/menu-item"; import { Modal } from "../../../shared/ui/modal"; import { useAuthenticatedUser } from "../../shared/auth-info-context"; +import { UrlInput } from "../../shared/url-input"; type FormFieldMetadata = { label: string; @@ -93,7 +94,14 @@ const Input = ({ * - {options ? ( + {url ? ( + + ) : options ? ( ) : ( onChange(event.target.value)} placeholder={placeholder} diff --git a/apps/hash-frontend/src/pages/shared/url-input.tsx b/apps/hash-frontend/src/pages/shared/url-input.tsx new file mode 100644 index 00000000000..17b01d9da0f --- /dev/null +++ b/apps/hash-frontend/src/pages/shared/url-input.tsx @@ -0,0 +1,96 @@ +import { Select, TextField } from "@hashintel/design-system"; +import { outlinedInputClasses, Stack } from "@mui/material"; + +import { MenuItem } from "../../shared/ui/menu-item"; + +const protocols = ["https", "http"] as const; + +type Protocol = (typeof protocols)[number]; + +const partsFromUrl = (url: string): { protocol: Protocol; rest: string } => { + if (!url) { + return { protocol: "https", rest: "" }; + } + + const [protocol, rest] = url.split("://"); + + if (!protocol) { + return { protocol: "https", rest: "" }; + } + + return { protocol: protocol as Protocol, rest: rest ?? "" }; +}; + +export const UrlInput = ({ + autoFocus, + onChange, + placeholder, + value, +}: { + autoFocus: boolean; + onChange: (value: string) => void; + placeholder: string; + value: string; +}) => { + const { protocol, rest } = partsFromUrl(value); + + return ( + + + { + /** + * Account for users entering the protocol into the rest field, e.g. by pasting a full URL + */ + const [_, maybeProtocol, maybeRest] = + event.target.value.match("^(https?)://(.*)$") ?? []; + + onChange( + `${maybeProtocol ?? protocol}://${maybeRest?.replace(/\/$/, "") ?? event.target.value}`, + ); + }} + placeholder={placeholder} + sx={{ + width: "100%", + [`.${outlinedInputClasses.notchedOutline}`]: { + borderLeftColor: "transparent", + }, + [`& .${outlinedInputClasses.root}`]: { + borderTopLeftRadius: 0, + borderBottomLeftRadius: 0, + }, + }} + type="text" + value={rest} + /> + + ); +}; diff --git a/libs/@hashintel/design-system/src/theme/components/inputs/mui-select-theme-options.tsx b/libs/@hashintel/design-system/src/theme/components/inputs/mui-select-theme-options.tsx index 9e5cc73eb28..8f06d02f754 100644 --- a/libs/@hashintel/design-system/src/theme/components/inputs/mui-select-theme-options.tsx +++ b/libs/@hashintel/design-system/src/theme/components/inputs/mui-select-theme-options.tsx @@ -70,7 +70,7 @@ export const MuiSelectThemeOptions: Components["MuiSelect"] = { }, [`&:focus ~ .${outlinedInputClasses.notchedOutline}`]: { - border: `1px solid ${theme.palette.blue[60]}`, + border: `2px solid ${theme.palette.blue[60]}`, }, }), icon: ({ theme }) => ({ diff --git a/libs/@hashintel/design-system/src/theme/components/navigation/mui-menu-item-theme-options.ts b/libs/@hashintel/design-system/src/theme/components/navigation/mui-menu-item-theme-options.ts index c9043815ce8..299ce6a9548 100644 --- a/libs/@hashintel/design-system/src/theme/components/navigation/mui-menu-item-theme-options.ts +++ b/libs/@hashintel/design-system/src/theme/components/navigation/mui-menu-item-theme-options.ts @@ -85,8 +85,7 @@ export const MuiMenuItemThemeOptions: Components["MuiMenuItem"] = { }, [`&.${menuItemClasses.focusVisible}, &:focus`]: { - boxShadow: `0px 0px 0px 2px ${theme.palette.white}, 0px 0px 0px 4px ${theme.palette.blue[70]}`, - backgroundColor: "transparent", + backgroundColor: theme.palette.blue[20], }, [`&.${menuItemClasses.selected}, &.${menuItemClasses.selected}:hover, &:active`]: