Skip to content
Open
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
1 change: 1 addition & 0 deletions cypress/e2e/docs-display.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const getUserProfileResponse: { result: UserProfileDto } = {
githubUrl: null,
twitterUrl: null,
linkedInUrl: null,
isTrusted: null,
},
};

Expand Down
1 change: 1 addition & 0 deletions src/api-4markdown-contracts/dtos/user-profile.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type UserProfileDto = {
twitterUrl: string | null;
fbUrl: string | null;
blogUrl: string | null;
isTrusted: boolean | null;
};

export type { UserProfileDto };
77 changes: 77 additions & 0 deletions src/containers/trusted-user.container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React from 'react';
import type { ReactNode, DetailedHTMLProps, ButtonHTMLAttributes } from 'react';
import { useYourUserProfileState } from 'store/your-user-profile';
import { MdVerified, MdGppBad, MdGppMaybe } from 'react-icons/md';
import c from 'classnames';

interface TooltipProps
extends DetailedHTMLProps<
ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
> {
text: string;
children: ReactNode;
className?: string;
}

const Tooltip = ({ text, children, className }: TooltipProps) => (
<div className={c(`group relative inline-block`, className)}>
<span>{children}</span>
<span
className={c(
`pointer-events-none absolute left-1/2 -translate-x-1/2`,
`whitespace-nowrap rounded bg-black px-2 py-1 text-white`,
`opacity-0 transition group-hover:opacity-100`,
// Mobile: show above
`bottom-full mb-2`,
`before:absolute before:left-1/2 before:-translate-x-1/2`,
`before:border-4 before:border-transparent before:border-t-black`,
`before:bottom-[-8px]`,
// Desktop: show below
`md:bottom-auto md:top-full md:mt-2`,
`md:before:bottom-auto md:before:top-[-8px]`,
`md:before:border-t-transparent md:before:border-b-black`,
)}
>
{text}
</span>
</div>
);

const TrustedUserContainer = () => {
const yourUserProfile = useYourUserProfileState();

if (yourUserProfile.is !== `ok`) {
return (
<Tooltip
title={`Trusted user loading container`}
text={`Loading verification status...`}
>
<span className={`text-gray-400 dark:text-gray-500`}>
<MdGppMaybe size={24} />
</span>
</Tooltip>
);
}

const isVerified = yourUserProfile.user?.isTrusted;

return (
<Tooltip
title={`Trusted user container`}
text={isVerified ? `User is verified` : `User is not verified`}
>
<span
className={
isVerified
? `text-green-700 dark:text-green-400`
: `text-red-500 dark:text-red-400`
}
>
{isVerified ? <MdVerified size={24} /> : <MdGppBad size={24} />}
</span>
</Tooltip>
);
};

export { TrustedUserContainer };
2 changes: 2 additions & 0 deletions src/features/creator/creator.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
isInvalidSelection,
getSelectedText,
} from 'development-kit/textarea-utils';
import { TrustedUserContainer } from 'containers/trusted-user.container';

const CreatorErrorModalContainer = React.lazy(
() => import(`./containers/creator-error-modal.container`),
Expand Down Expand Up @@ -320,6 +321,7 @@ const CreatorView = () => {
</nav>
<div />
<nav className="flex items-center gap-2">
<TrustedUserContainer />
<UserPopover />
<MoreNav />
</nav>
Expand Down