Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E 1678 feature support v1 contactform #3

Merged
merged 5 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,63 @@ import { ItemNavPort } from "@/design-system/molecules/item-nav/item-nav.types";
import { BaseLink } from "@/shared/components/base-link/base-link";
import { cn } from "@/shared/helpers/cn";

export function ItemNavDefaultAdapter({ classNames, children, translate, ...props }: ItemNavPort) {
const { isDisabled, isFolded, icon, labelProps = {}, ...linkProps } = props;
function Content({
classNames,
children,
translate,
icon,
labelProps = {},
isExternal,
isDisabled,
isFolded,
}: ItemNavPort & { isExternal: boolean }) {
const slots = ItemNavDefaultVariants({
isDisabled,
});

const showChildren = !!children || !!translate;
return (
<div className={"flex w-full items-center justify-start gap-2 overflow-hidden"}>
<Icon size={18} {...icon} />
<div className="flex flex-1 justify-start">
<Typo
size={"m"}
as={"span"}
{...labelProps}
translate={translate}
classNames={{ base: cn(slots.label(), classNames?.label) }}
>
{children}
</Typo>
{isExternal ? (
<Icon
name="ri-external-link-line"
classNames={{
base: cn("invisible ml-1 text-inherit group-hover/link:visible", { "!invisible": isFolded }),
}}
/>
) : null}
</div>
</div>
);
}

export function ItemNavDefaultAdapter({ ...props }: ItemNavPort) {
const { isDisabled, classNames, onClick, ...linkProps } = props;
const slots = ItemNavDefaultVariants({
isDisabled,
});

if (onClick) {
return (
<button className={cn(slots.base(), classNames?.base)} onClick={onClick} disabled={isDisabled}>
<Content {...props} isExternal={false} />
</button>
);
}

return (
<BaseLink className={cn(slots.base(), classNames?.base)} {...linkProps}>
{({ isExternal }) => (
<div className={"flex w-full items-center justify-start gap-2 overflow-hidden"}>
<Icon size={18} {...icon} />
<div className="flex-1">
{showChildren && (
<Typo
size={"m"}
as={"span"}
{...labelProps}
translate={translate}
classNames={{ base: cn(slots.label(), classNames?.label) }}
>
{children}
</Typo>
)}
{isExternal ? (
<Icon
name="ri-external-link-line"
classNames={{
base: cn("invisible ml-1 text-inherit group-hover/link:visible", { "!invisible": isFolded }),
}}
/>
) : null}
</div>
</div>
)}
{({ isExternal }) => <Content {...props} isExternal={isExternal} />}
</BaseLink>
);
}
1 change: 1 addition & 0 deletions design-system/molecules/item-nav/item-nav.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export interface ItemNavPort extends _BaseLinkProps, PropsWithChildren {
translate?: TranslateProps;
isDisabled?: boolean;
isFolded?: boolean;
onClick?: () => void;
}
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"dependencies": {
"@auth0/auth0-react": "^2.2.4",
"@fillout/react": "^1.1.2",
"@nextui-org/react": "^2.4.6",
"@tanstack/react-query": "^5.51.21",
"clsx": "^2.1.1",
Expand Down
5 changes: 5 additions & 0 deletions shared/features/feedback-drawer/feedback-drawer.hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { useState } from "react";

export function useFeedbackDrawerState() {
return useState<boolean>(false);
}
36 changes: 36 additions & 0 deletions shared/features/feedback-drawer/feedback-drawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { FilloutStandardEmbed } from "@fillout/react";

import { Drawer } from "@/design-system/molecules/drawer";

import { useFeedbackDrawerState } from "@/shared/features/feedback-drawer/feedback-drawer.hooks";
import { useAuthUser } from "@/shared/hooks/auth/use-auth-user";

export function FeedbackDrawer({ state }: { state: ReturnType<typeof useFeedbackDrawerState> }) {
const [isOpen, setIsOpen] = state;

const { user } = useAuthUser();

return (
<Drawer
isOpen={isOpen}
onOpenChange={setIsOpen}
hideHeader
classNames={{
body: "p-0 h-full",
}}
>
<FilloutStandardEmbed
filloutId="uUS6ESXXcjus"
inheritParameters
parameters={{
user_id: user?.id,
first_name: user?.firstName || undefined,
last_name: user?.lastName || undefined,
email: user?.email || undefined,
github_id: `${user?.githubUserId}` || undefined,
github_login: user?.login || undefined,
}}
/>
</Drawer>
);
}
4 changes: 2 additions & 2 deletions shared/features/navigation/menu/primary-menu/primary-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PrimaryMenuProps } from "shared/features/navigation/menu/primary-menu/primary-menu.types";

import { ItemNav } from "@/design-system/molecules/item-nav";

import { PrimaryMenuProps } from "./primary-menu.types";

export function PrimaryMenu({ isFolded }: PrimaryMenuProps) {
return (
<>
Expand Down
17 changes: 12 additions & 5 deletions shared/features/navigation/menu/secondary-menu/secondary-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import { SecondaryMenuProps } from "shared/features/navigation/menu/secondary-menu/secondary-menu.types";

import { ItemNav } from "@/design-system/molecules/item-nav";

import { FeedbackDrawer } from "@/shared/features/feedback-drawer/feedback-drawer";
import { useFeedbackDrawerState } from "@/shared/features/feedback-drawer/feedback-drawer.hooks";

import { SecondaryMenuProps } from "./secondary-menu.types";

export function SecondaryMenu({ isFolded }: SecondaryMenuProps) {
const feedbackDrawerState = useFeedbackDrawerState();
const [, setIsOpen] = feedbackDrawerState;
return (
<>
<ItemNav
isFolded={isFolded}
icon={{ name: "ri-settings-line" }}
icon={{ name: "ri-chat-4-line" }}
href={"/test"}
translate={{ token: "primaryNavigation:secondaryMenu.support" }}
onClick={() => setIsOpen(true)}
/>
<ItemNav
isFolded={isFolded}
icon={{ name: "ri-chat-4-line" }}
href={"/test2"}
icon={{ name: "ri-settings-line" }}
href={"/test"}
translate={{ token: "primaryNavigation:secondaryMenu.settings" }}
isDisabled={true}
/>
<FeedbackDrawer state={feedbackDrawerState} />
</>
);
}
4 changes: 2 additions & 2 deletions shared/features/navigation/menu/user-menu/user-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { UserMenuProps } from "shared/features/navigation/menu/user-menu/user-menu.types";

import { useClientBootstrapContext } from "@/core/bootstrap/client-bootstrap-context";

import { Avatar } from "@/design-system/atoms/avatar";
Expand All @@ -10,6 +8,8 @@ import { Typo } from "@/design-system/atoms/typo";
import { cn } from "@/shared/helpers/cn";
import { useAuthUser } from "@/shared/hooks/auth/use-auth-user";

import { UserMenuProps } from "./user-menu.types";

export function UserMenu({ isFolded }: UserMenuProps) {
const { user, isLoading } = useAuthUser();
const login = user?.login;
Expand Down