-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split activity cards in account information (#92)
- Loading branch information
1 parent
8afb88c
commit 962ec5f
Showing
6 changed files
with
171 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/features/accounts/components/account-application-tabs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { OverflowAutoTabsContent, Tabs, TabsList, TabsTrigger } from '@/features/common/components/tabs' | ||
import { cn } from '@/features/common/utils' | ||
import { useMemo } from 'react' | ||
import { Account } from '../models' | ||
import { | ||
accountCreatedApplicationsTabId, | ||
accountOptedApplicationsTabId, | ||
accountCreatedApplicationsTabLabel, | ||
accountOptedApplicationsTabLabel, | ||
accountApplicationLabel, | ||
} from './labels' | ||
import { AccountApplications } from './account-applications' | ||
|
||
type Props = { | ||
account: Account | ||
} | ||
|
||
export function AccountApplicationTabs({ account }: Props) { | ||
const tabs = useMemo( | ||
() => [ | ||
{ | ||
id: accountCreatedApplicationsTabId, | ||
label: accountCreatedApplicationsTabLabel, | ||
children: <AccountApplications applications={account.applicationsCreated} />, | ||
}, | ||
{ | ||
id: accountOptedApplicationsTabId, | ||
label: accountOptedApplicationsTabLabel, | ||
children: <AccountApplications applications={account.applicationsOpted} />, | ||
}, | ||
], | ||
[account.applicationsCreated, account.applicationsOpted] | ||
) | ||
return ( | ||
<Tabs defaultValue={accountCreatedApplicationsTabId}> | ||
<TabsList aria-label={accountApplicationLabel}> | ||
{tabs.map((tab) => ( | ||
<TabsTrigger key={tab.id} className={cn('data-[state=active]:border-primary data-[state=active]:border-b-2 w-36')} value={tab.id}> | ||
{tab.label} | ||
</TabsTrigger> | ||
))} | ||
</TabsList> | ||
{tabs.map((tab) => ( | ||
<OverflowAutoTabsContent key={tab.id} value={tab.id} className={cn('border-solid border-2 border-border')}> | ||
<div className="grid"> | ||
<div className="overflow-auto p-4">{tab.children}</div> | ||
</div> | ||
</OverflowAutoTabsContent> | ||
))} | ||
</Tabs> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { OverflowAutoTabsContent, Tabs, TabsList, TabsTrigger } from '@/features/common/components/tabs' | ||
import { cn } from '@/features/common/utils' | ||
import { useMemo } from 'react' | ||
import { AccountAssetsHeld } from './account-assets-held' | ||
import { Account } from '../models' | ||
import { | ||
accountCreatedAssetsTabId, | ||
accountHeldAssetsTabId, | ||
accountHeldAssetsTabLabel, | ||
accountCreatedAssetsTabLabel, | ||
accountOptedAssetsTabId, | ||
accountOptedAssetsTabLabel, | ||
accountAssetLabel, | ||
} from './labels' | ||
import { AccountAssetsCreated } from './account-assets-created' | ||
import { AccountAssetsOpted } from './account-assets-opted' | ||
|
||
type Props = { | ||
account: Account | ||
} | ||
|
||
export function AccountAssetTabs({ account }: Props) { | ||
const tabs = useMemo( | ||
() => [ | ||
{ | ||
id: accountHeldAssetsTabId, | ||
label: accountHeldAssetsTabLabel, | ||
children: <AccountAssetsHeld assetsHeld={account.assetsHeld} />, | ||
}, | ||
{ | ||
id: accountCreatedAssetsTabId, | ||
label: accountCreatedAssetsTabLabel, | ||
children: <AccountAssetsCreated assetsCreated={account.assetsCreated} />, | ||
}, | ||
{ | ||
id: accountOptedAssetsTabId, | ||
label: accountOptedAssetsTabLabel, | ||
children: <AccountAssetsOpted assetsOpted={account.assetsOpted} />, | ||
}, | ||
], | ||
[account.assetsCreated, account.assetsHeld, account.assetsOpted] | ||
) | ||
return ( | ||
<Tabs defaultValue={accountHeldAssetsTabId}> | ||
<TabsList aria-label={accountAssetLabel}> | ||
{tabs.map((tab) => ( | ||
<TabsTrigger key={tab.id} className={cn('data-[state=active]:border-primary data-[state=active]:border-b-2 w-36')} value={tab.id}> | ||
{tab.label} | ||
</TabsTrigger> | ||
))} | ||
</TabsList> | ||
{tabs.map((tab) => ( | ||
<OverflowAutoTabsContent key={tab.id} value={tab.id} className={cn('border-solid border-2 border-border')}> | ||
<div className="grid"> | ||
<div className="overflow-auto p-4">{tab.children}</div> | ||
</div> | ||
</OverflowAutoTabsContent> | ||
))} | ||
</Tabs> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters