Skip to content

Commit

Permalink
Merge branch 'develop' into tooling/fix-kiosk
Browse files Browse the repository at this point in the history
 Conflicts:
	pnpm-lock.yaml
  • Loading branch information
msarcev committed Oct 29, 2024
2 parents a9a1690 + 8882941 commit 93f031c
Show file tree
Hide file tree
Showing 160 changed files with 3,496 additions and 3,054 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/_rust_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ jobs:
check-unused-deps:
name: Check Unused Dependencies (${{ matrix.flags }})
# Temporarily disabled until the nightly build bug is resolved
if: (!cancelled() && false)
if: (!cancelled())
strategy:
matrix:
flags: ["--all-features", "--no-default-features"]
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

74 changes: 48 additions & 26 deletions apps/ui-kit/src/lib/components/organisms/dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import cx from 'classnames';
import * as React from 'react';
import { Close } from '@iota/ui-icons';
import { useEffect, useState } from 'react';
import { DialogPosition } from './dialog.enums';

const Dialog = RadixDialog.Root;
const DialogTrigger = RadixDialog.Trigger;
Expand Down Expand Up @@ -35,34 +36,55 @@ const DialogContent = React.forwardRef<
React.ComponentPropsWithoutRef<typeof RadixDialog.Content> & {
containerId?: string;
showCloseOnOverlay?: boolean;
position?: DialogPosition;
}
>(({ className, containerId, showCloseOnOverlay, children, ...props }, ref) => {
const [containerElement, setContainerElement] = useState<HTMLElement | undefined>(undefined);
>(
(
{
className,
containerId,
showCloseOnOverlay,
children,
position = DialogPosition.Center,
...props
},
ref,
) => {
const [containerElement, setContainerElement] = useState<HTMLElement | undefined>(
undefined,
);

useEffect(() => {
// This ensures document.getElementById is called in the client-side environment only.
// note. containerElement cant be null
const element = containerId ? document.getElementById(containerId) : undefined;
setContainerElement(element ?? undefined);
}, [containerId]);

return (
<RadixDialog.Portal container={containerElement}>
<DialogOverlay showCloseIcon={showCloseOnOverlay} />
<RadixDialog.Content
ref={ref}
className="absolute left-1/2 top-1/2 z-[99999] flex max-h-[60vh] w-80 max-w-[85vw] -translate-x-1/2 -translate-y-1/2 flex-col justify-center overflow-hidden rounded-xl bg-primary-100 dark:bg-neutral-6 md:w-96"
{...props}
>
<VisuallyHidden.Root>
<RadixDialog.Title />
<RadixDialog.Description />
</VisuallyHidden.Root>
{children}
</RadixDialog.Content>
</RadixDialog.Portal>
);
});
useEffect(() => {
// This ensures document.getElementById is called in the client-side environment only.
// note. containerElement cant be null
const element = containerId ? document.getElementById(containerId) : undefined;
setContainerElement(element ?? undefined);
}, [containerId]);
const positionClass =
position === DialogPosition.Right
? 'right-0 h-screen top-0 w-full max-w-[500px]'
: 'max-h-[60vh] left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-xl w-80 max-w-[85vw]';
return (
<RadixDialog.Portal container={containerElement}>
<DialogOverlay showCloseIcon={showCloseOnOverlay} />
<RadixDialog.Content
ref={ref}
className={cx(
'absolute z-[99999] flex flex-col justify-center overflow-hidden bg-primary-100 dark:bg-neutral-6 md:w-96',
positionClass,
)}
{...props}
>
<VisuallyHidden.Root>
<RadixDialog.Title />
<RadixDialog.Description />
</VisuallyHidden.Root>
{children}
</RadixDialog.Content>
</RadixDialog.Portal>
);
},
);
DialogContent.displayName = RadixDialog.Content.displayName;

const DialogTitle = React.forwardRef<
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

export enum DialogPosition {
Center = 'center',
Right = 'right',
}
1 change: 1 addition & 0 deletions apps/ui-kit/src/lib/components/organisms/dialog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
// SPDX-License-Identifier: Apache-2.0

export * from './Dialog';
export * from './dialog.enums';
49 changes: 48 additions & 1 deletion apps/ui-kit/src/storybook/stories/organisms/Dialog.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
import { ButtonSize } from '@/lib/components';
import { ButtonSize, DialogPosition } from '@/lib/components';

import type { Meta, StoryObj } from '@storybook/react';

Expand Down Expand Up @@ -54,3 +54,50 @@ export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {};

export const RightDialog: Story = {
render: () => {
const [open, setOpen] = useState(false);
return (
<div className="flex">
<Button size={ButtonSize.Small} text="Open Dialog" onClick={() => setOpen(true)} />
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent showCloseOnOverlay position={DialogPosition.Right}>
<div className="h-full w-full">
<Header
title="Connect Ledger Wallet"
titleCentered
onClose={() => setOpen(false)}
onBack={() => setOpen(false)}
/>
<div className="flex h-full w-full flex-col items-center justify-center">
<DialogBody>
<div className="flex flex-col items-center gap-2">
<div className="mt-4.5">Logo</div>
<div className="mt-4.5 break-words text-center">
Connect your ledger to your computer, unlock it, and
launch the IOTA app. Click Continue when done.
</div>
<div className="mt-4.5">
{' '}
Need more help? View tutorial.
</div>
</div>
</DialogBody>
<div className="flex w-full flex-row justify-center gap-2 px-md--rs pb-md--rs pt-sm--rs">
<Button
size={ButtonSize.Small}
type={ButtonType.Outlined}
text="Cancel"
onClick={() => setOpen(false)}
/>
<Button size={ButtonSize.Small} text="Connect" />
</div>
</div>
</div>
</DialogContent>
</Dialog>
</div>
);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
'use client';

import { RouteLink } from '@/components/index';
import { ASSETS_ROUTE } from '@/lib/constants/routes.constants';
import React, { type PropsWithChildren } from 'react';

function AssetsLayout({ children }: PropsWithChildren): JSX.Element {
const routes = [
{ title: 'Visual Assets', path: '/dashboard/assets/visual-assets' },
{ title: 'Everything Else', path: '/dashboard/assets/everything-else' },
{ title: 'Visual Assets', path: ASSETS_ROUTE.path + '/visual-assets' },
{ title: 'Everything Else', path: ASSETS_ROUTE.path + '/everything-else' },
];

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AssetCard, Button, RouteLink, SendAssetPopup } from '@/components';
import { isAssetTransferable, useGetObject } from '@iota/core';
import { usePopups } from '@/hooks';
import { useCurrentAccount } from '@iota/dapp-kit';
import { ASSETS_ROUTE } from '@/lib/constants/routes.constants';

const VisualAssetDetailPage = () => {
const params = useParams();
Expand All @@ -28,7 +29,7 @@ const VisualAssetDetailPage = () => {

return (
<div className="flex h-full w-full flex-col space-y-4 px-40">
<RouteLink path="/dashboard/assets/visual-assets" title="Back" />
<RouteLink path={ASSETS_ROUTE.path + '/visual-assets'} title="Back" />
{asset?.data ? (
<AssetCard key={asset.data.objectId} asset={asset.data} />
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AssetCard, VirtualList } from '@/components/index';
import { useCurrentAccount } from '@iota/dapp-kit';
import { hasDisplayData, useGetOwnedObjects } from '@iota/core';
import { useRouter } from 'next/navigation';
import { ASSETS_ROUTE } from '@/lib/constants/routes.constants';

function VisualAssetsPage(): JSX.Element {
const account = useCurrentAccount();
Expand All @@ -29,7 +30,7 @@ function VisualAssetsPage(): JSX.Element {
const virtualItem = (asset: IotaObjectData): JSX.Element => <AssetCard asset={asset} />;

const handleClick = (objectId: string) => {
router.push(`/dashboard/assets/visual-assets/${objectId}`);
router.push(ASSETS_ROUTE.path + `/visual-assets/${objectId}`);
};

return (
Expand Down
4 changes: 4 additions & 0 deletions apps/wallet-dashboard/app/(protected)/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

export * from './sidebar/Sidebar';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { PROTECTED_ROUTES } from '@/lib/constants/routes.constants';
import { IotaLogoMark } from '@iota/ui-icons';
import { SidebarItem } from './SidebarItem';

export function Sidebar() {
return (
<nav className="flex h-screen flex-col items-center gap-y-2xl bg-neutral-100 py-xl dark:bg-neutral-6">
<IotaLogoMark className="h-10 w-10 text-neutral-10 dark:text-neutral-92" />
<div className="flex flex-col gap-y-xs">
{PROTECTED_ROUTES.map((route) => (
<SidebarItem key={route.path} {...route} />
))}
</div>
</nav>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

'use client';

import type { ProtectedRoute } from '@/lib/interfaces';
import { NavbarItem, Tooltip, TooltipPosition } from '@iota/apps-ui-kit';
import { usePathname } from 'next/navigation';
import Link from 'next/link';

export function SidebarItem({ icon, title, path }: ProtectedRoute) {
const pathname = usePathname();
const RouteIcon = icon;
const isActive = pathname === path;
return (
<Tooltip text={title} position={TooltipPosition.Right}>
<Link href={path} className="relative px-sm py-xxs">
<NavbarItem isSelected={isActive} icon={<RouteIcon />} />
</Link>
</Tooltip>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { Badge, BadgeType, Button, ButtonType } from '@iota/apps-ui-kit';
import { ConnectButton } from '@iota/dapp-kit';
import { Settings } from '@iota/ui-icons';

export function TopNav() {
return (
<div className="flex w-full flex-row items-center justify-end gap-md py-xs--rs">
<Badge label="Mainnet" type={BadgeType.PrimarySoft} />
<ConnectButton size="md" />
<Button icon={<Settings />} type={ButtonType.Ghost} />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function HomeDashboardPage(): JSX.Element {
};

return (
<main className="flex min-h-screen flex-col items-center space-y-8 p-24">
<main className="flex flex-1 flex-col items-center space-y-8 p-24">
<p>Connection status: {connectionStatus}</p>
{connectionStatus === 'connected' && account && (
<div className="flex flex-col items-center justify-center space-y-2">
Expand Down
55 changes: 55 additions & 0 deletions apps/wallet-dashboard/app/(protected)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
'use client';

import { Notifications } from '@/components/index';
import React, { useEffect, useState, type PropsWithChildren } from 'react';
import { useCurrentAccount, useCurrentWallet } from '@iota/dapp-kit';
import { Button } from '@iota/apps-ui-kit';
import { redirect } from 'next/navigation';
import { Sidebar } from './components';
import { TopNav } from './components/top-nav/TopNav';

function DashboardLayout({ children }: PropsWithChildren): JSX.Element {
const [isDarkMode, setIsDarkMode] = useState(false);
const { connectionStatus } = useCurrentWallet();
const account = useCurrentAccount();

const toggleDarkMode = () => {
setIsDarkMode(!isDarkMode);
if (isDarkMode) {
document.documentElement.classList.remove('dark');
} else {
document.documentElement.classList.add('dark');
}
};

useEffect(() => {
if (connectionStatus !== 'connected' && !account) {
redirect('/');
}
}, [connectionStatus, account]);

return (
<div className="h-full">
<div className="fixed left-0 top-0 z-50 h-full">
<Sidebar />
</div>

<div className="container relative min-h-screen">
<div className="sticky top-0">
<TopNav />
</div>
<div>{children}</div>
</div>

<div className="fixed bottom-5 right-5">
<Button onClick={toggleDarkMode} text={isDarkMode ? 'Light Mode' : 'Dark Mode'} />
</div>

<Notifications />
</div>
);
}

export default DashboardLayout;
17 changes: 0 additions & 17 deletions apps/wallet-dashboard/app/dashboard/apps/page.tsx

This file was deleted.

Loading

0 comments on commit 93f031c

Please sign in to comment.