diff --git a/packages/ui/src/components/Flex.tsx b/packages/ui/src/components/Flex.tsx index f70c36ec..78106054 100644 --- a/packages/ui/src/components/Flex.tsx +++ b/packages/ui/src/components/Flex.tsx @@ -19,8 +19,10 @@ type FlexProps = { | undefined; children?: ReactNode; as?: ElementType | undefined; + asButtonType?: "button" | "submit" | undefined; column?: boolean | undefined; onClick?: (() => void) | undefined; + disabled?: boolean | undefined; overflow?: "hidden" | "visible" | "scroll" | "auto" | undefined; whiteSpace?: | "nowrap" @@ -43,8 +45,10 @@ export function Flex({ column = false, children, onClick, + disabled = false, gap, as = "div", + asButtonType, overflow, whiteSpace, mt, @@ -55,14 +59,16 @@ export function Flex({ const justify = justifyProp ? justifyProp : center ? "center" : "stretch"; const align = alignProp ? alignProp : center ? "center" : "stretch"; + const asButtonProps = asButtonType ? { type: asButtonType, disabled } : {}; + return ( {children} @@ -80,7 +87,7 @@ type StyledFlexProps = { justify: NonNullable; align: NonNullable; column: boolean; - cursorProp: "pointer" | "initial" | "unset"; + cursorProp: "pointer" | "not-allowed" | "initial" | "unset"; overflowProp: FlexProps["overflow"]; whiteSpace: FlexProps["whiteSpace"]; mt: FlexProps["mt"]; @@ -88,12 +95,27 @@ type StyledFlexProps = { mb: FlexProps["mb"]; ml: FlexProps["ml"]; gap: number | undefined; + as?: ElementType | undefined; }; export const StyledFlex = styled.div` display: flex; text-overflow: ellipsis; + ${({ as }) => + /* reset button styles */ + as === "button" && + ` + border: 0; + appearance: none; + background: transparent; + padding: 0; + /* needed in Safari for some reason */ + font-size: 1rem; + color: inherit; + font-weight: inherit; + `} + ${({ column }) => column && `flex-direction: column;`} ${({ justify }) => `justify-content: ${justify};`} ${({ align }) => `align-items: ${align};`} diff --git a/packages/ui/src/components/IconWithCircleBackground.tsx b/packages/ui/src/components/IconWithCircleBackground.tsx index 8d116448..134fd4b1 100644 --- a/packages/ui/src/components/IconWithCircleBackground.tsx +++ b/packages/ui/src/components/IconWithCircleBackground.tsx @@ -16,6 +16,7 @@ type IconWithCircleBackgroundProps = { noBg?: boolean; shouldRotate?: boolean; onClick?: () => void; + disabled?: boolean; }; export function IconWithCircleBackground({ @@ -26,9 +27,16 @@ export function IconWithCircleBackground({ darkBg = false, shouldRotate = false, noBg = false, + disabled = false, }: IconWithCircleBackgroundProps) { const content = ( - + ); - return to ? {content} : content; + return to ? ( +
+ + {content} + +
+ ) : ( + content + ); } type StyledIconWithCircleBackgroundProps = { diff --git a/packages/ui/src/router.tsx b/packages/ui/src/router.tsx index 51e4d9d2..759c6758 100644 --- a/packages/ui/src/router.tsx +++ b/packages/ui/src/router.tsx @@ -54,6 +54,7 @@ export type LinkProps = { newTab?: boolean | undefined; hash?: RouteHash | undefined; typography?: SimpleTypographyProps | undefined; + disabled?: boolean | undefined; }; export function replaceParams( @@ -158,7 +159,9 @@ function LinkBase({ ); } -export const Link = styled(LinkBase)``; +export const Link = styled(LinkBase)` + ${({ disabled }) => disabled && `pointer-events: none;`} +`; type NavigateProps = Omit & { to: NewRoutesType;