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

fix: update dapp "Connect Page" #465

Merged
merged 16 commits into from
Sep 12, 2023
Merged
78 changes: 48 additions & 30 deletions packages/dapp/src/components/AppBottomBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,43 @@ import { EllipsisHorizontalIcon } from '@heroicons/react/24/solid';
import clsx from 'clsx';
import { useTranslations } from 'next-intl';

import { useGeneralStore } from '@/stores/generalStore';

const MAIN_LINKS = [
{
name: 'dashboard',
href: '/app',
requiresConnection: false,
},
{
name: 'settings',
href: '/app/settings',
requiresConnection: true,
},
];

const OTHER_LINKS = [
// {
// name: 'get-credential',
// href: '/app/get-credential',
// },
// {
// name: 'authorization-request',
// href: '/app/authorization-request',
// },
{
name: 'qr-code-session',
name: 'create-credential',
href: '/app/create-credential',
requiresConnection: true,
},
{
name: 'verify-data',
href: '/app/verify-data',
requiresConnection: true,
},
{
name: 'qr-scanner',
href: '/app/qr-code-session',
requiresConnection: false,
},
];

const AppBottomBar = () => {
const t = useTranslations('AppBottomBar');
const [isMenuOpen, setIsMenuOpen] = useState(false);
const isConnected = useGeneralStore((state) => state.isConnected);

const toggleMenu = () => {
setIsMenuOpen((currVal) => !currVal);
Expand All @@ -45,17 +53,22 @@ const AppBottomBar = () => {
<div className="dark:border-navy-blue-600/50 dark:bg-navy-blue-800 fixed bottom-0 left-0 right-0 z-20 flex h-14 w-screen items-center border-t-2 border-pink-200/50 bg-pink-50 md:hidden">
<div className="flex flex-1 items-center p-1 px-4">
<div className="flex flex-1 items-center space-x-2">
{MAIN_LINKS.map(({ name, href }) => (
// Link styled as button for mobile bottom navbar with tailwind
<Link
onClick={() => setIsMenuOpen(false)}
className="animated-transition dark:bg-navy-blue-700 dark:hover:bg-navy-blue-600 rounded-lg bg-pink-100 p-2 text-pink-600 hover:bg-pink-50 dark:text-white"
key={name}
href={href}
>
{t(name)}
</Link>
))}
{MAIN_LINKS.map(({ name, href, requiresConnection }) => {
if ((requiresConnection && isConnected) || !requiresConnection) {
return (
// Link styled as button for mobile bottom navbar with tailwind
<Link
onClick={() => setIsMenuOpen(false)}
className="animated-transition dark:bg-navy-blue-700 dark:hover:bg-navy-blue-600 rounded-lg bg-pink-100 p-2 text-pink-600 hover:bg-pink-50 dark:text-white"
key={name}
href={href}
>
{t(name)}
</Link>
);
}
return <div className="hidden" key={href}></div>;
})}
</div>
<button
onClick={toggleMenu}
Expand All @@ -72,16 +85,21 @@ const AppBottomBar = () => {
)}
>
<div className="dark:border-navy-blue-600/50 dark:bg-navy-blue-800 flex h-full w-full flex-col space-y-1 rounded-t-lg border-2 border-pink-200/50 bg-pink-50 p-2">
{OTHER_LINKS.map(({ name, href }) => (
<Link
onClick={() => setIsMenuOpen(false)}
className="animated-transition dark:bg-navy-blue-700 dark:hover:bg-navy-blue-600 rounded-lg bg-pink-100 p-2 text-pink-600 outline-none hover:bg-pink-50 focus:outline-none dark:text-white"
key={name}
href={href}
>
{t(name)}
</Link>
))}
{OTHER_LINKS.map(({ name, href, requiresConnection }) => {
if ((requiresConnection && isConnected) || !requiresConnection) {
return (
<Link
onClick={() => setIsMenuOpen(false)}
className="animated-transition dark:bg-navy-blue-700 dark:hover:bg-navy-blue-600 rounded-lg bg-pink-100 p-2 text-pink-600 outline-none hover:bg-pink-50 focus:outline-none dark:text-white"
key={name}
href={href}
>
{t(name)}
</Link>
);
}
return <div className="hidden" key={href}></div>;
})}
</div>
</div>
</>
Expand Down
37 changes: 23 additions & 14 deletions packages/dapp/src/components/AppNavbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,26 @@ import { useTranslations } from 'next-intl';
import MascaLogo from '@/components/MascaLogo';
import MenuPopover from '@/components/MenuPopover';
import ToggleTheme from '@/components/ToggleTheme';
import { useGeneralStore } from '@/stores';
import { NavConnection } from './NavConnection';

const MAIN_LINKS = [
{
name: 'dashboard',
href: '/app',
requiresConnection: false,
},
{
name: 'settings',
href: '/app/settings',
requiresConnection: true,
},
];

export default function AppNavbar() {
const t = useTranslations('AppNavbar');
const pathname = usePathname() ?? '/';
const isConnected = useGeneralStore((state) => state.isConnected);

return (
<div className="main-bg fixed left-0 right-0 top-0 z-50 m-0 flex h-24 w-screen items-center">
Expand All @@ -37,20 +41,25 @@ export default function AppNavbar() {
</div>
</Link>
<div className="mx-2 hidden flex-1 items-center justify-center md:flex">
{MAIN_LINKS.map(({ name, href }) => (
<Link
className={clsx(
'nav-btn',
pathname === href
? 'dark:text-orange-accent-dark text-pink-500'
: 'dark:text-navy-blue-400 text-gray-600'
)}
key={name}
href={href}
>
{t(`menu.${name}`)}
</Link>
))}
{MAIN_LINKS.map(({ name, href, requiresConnection }) => {
if ((requiresConnection && isConnected) || !requiresConnection) {
return (
<Link
className={clsx(
'nav-btn',
pathname === href
? 'dark:text-orange-accent-dark text-pink-500'
: 'dark:text-navy-blue-400 text-gray-600'
)}
key={name}
href={href}
>
{t(`menu.${name}`)}
</Link>
);
}
return <div className="hidden" key={href}></div>;
})}
<MenuPopover />
</div>
<div className="flex-1 md:flex-none">
Expand Down
26 changes: 13 additions & 13 deletions packages/dapp/src/components/ConnectedProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ const ConnectedProvider = ({ children }: ConnectedProviderProps) => {

return (
<div className="dark:bg-navy-blue-800 dark:text-navy-blue-400 flex-1 rounded-3xl bg-white shadow-lg">
<div className="flex flex-col items-center p-12">
<div className="text-h3 dark:text-navy-blue-50 text-gray-900">
<div className="flex flex-col items-center justify-center px-6 py-12 sm:px-12">
<div className="text-h4 sm:text-h3 dark:text-navy-blue-50 text-center text-gray-900">
{t('connect')}
</div>
<div className="dark:border-navy-blue-500 mt-8 rounded-3xl border border-gray-500 px-12 py-8 md:min-w-[40em]">
<div className="dark:border-navy-blue-500 mt-8 rounded-3xl border border-gray-500 px-6 py-8 sm:px-12 md:min-w-[40em]">
<div className="flex items-center gap-x-6">
<div className="hidden sm:block">
<MascaLogo />
</div>
<div>
<div className="text-h3 dark:text-navy-blue-50 font-ubuntu text-gray-900">
<div className="text-h4 sm:text-h3 dark:text-navy-blue-50 font-ubuntu text-gray-900">
{t('masca')}
</div>
<div className="text-h4 dark:text-navy-blue-300 font-ubuntu mt-2 text-gray-600">
<div className="text-h5 sm:text-h4 dark:text-navy-blue-300 font-ubuntu mt-2 text-gray-600">
{t('masca-desc')}
</div>
</div>
</div>
<hr className="mt-4" />
<div className="flex justify-center">
<ul className="flex flex-col items-start text-justify text-xl tracking-normal">
<ul className="text-md flex flex-col items-start text-justify tracking-normal sm:text-xl">
<li className="mt-12">
<div className=" flex items-center gap-x-4">
<LockClosedIcon className="dark:text-orange-accent-dark h-8 w-8 text-pink-500" />
<div className="dark:text-navy-blue-50 font-ubuntu text-2xl font-medium text-gray-900 ">
<div className=" just flex items-center gap-x-4">
<LockClosedIcon className="dark:text-orange-accent-dark h-6 w-6 text-pink-500 sm:h-8 sm:w-8" />
<div className="dark:text-navy-blue-50 font-ubuntu text-md text-start font-medium text-gray-900 sm:text-2xl ">
{t('features.feat-1')}
</div>
</div>
Expand All @@ -67,8 +67,8 @@ const ConnectedProvider = ({ children }: ConnectedProviderProps) => {
</li>
<li className="mt-12">
<div className=" flex items-center gap-x-4">
<CreditCardIcon className="dark:text-orange-accent-dark h-8 w-8 text-pink-500" />
<div className="dark:text-navy-blue-50 font-ubuntu text-2xl font-medium text-gray-900 ">
<CreditCardIcon className="dark:text-orange-accent-dark h-6 w-6 text-pink-500 sm:h-8 sm:w-8" />
<div className="dark:text-navy-blue-50 font-ubuntu text-md text-start font-medium text-gray-900 sm:text-2xl ">
{t('features.feat-2')}
</div>
</div>
Expand All @@ -86,8 +86,8 @@ const ConnectedProvider = ({ children }: ConnectedProviderProps) => {
</li>
<li className="mt-12">
<div className=" flex items-center gap-x-4">
<GlobeAltIcon className="dark:text-orange-accent-dark h-8 w-8 text-pink-500" />
<div className="dark:text-navy-blue-50 font-ubuntu max-w-[15em] text-start text-2xl font-medium text-gray-900 ">
<GlobeAltIcon className="dark:text-orange-accent-dark h-8 w-8 text-pink-500 sm:h-8 sm:w-8" />
<div className="dark:text-navy-blue-50 font-ubuntu text-md max-w-[15em] text-start font-medium text-gray-900 sm:text-2xl ">
{t('features.feat-3')}
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/dapp/src/messages/en.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AppBottomBar": {
"authorization-request": "Authorization Request",
"dashboard": "Dashboard",
"get-credential": "Get Credential",
"qr-code-session": "QR Scanner",
"get-credential": "Get Credentials",
andyv09 marked this conversation as resolved.
Show resolved Hide resolved
"qr-scanner": "QR Code Scanner",
"verify-data": "Verify Data",
"settings": "Settings"
},
"AppNavbar": {
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"registry": "https://registry.npmjs.org"
}
},
"shasum": "nVKFpAn6RCNMM8UOH344F+tQUP6pxGjzisRXGBYf550="
"shasum": "WDdq5nRYRTf6/tY3A81reueTXmE5YrMsSE3LVh631QA="
},
"initialPermissions": {
"endowment:ethereum-provider": {},
Expand Down