From 8572c0a5704ae027febe1bdb65318e6854cf38b5 Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Thu, 27 Apr 2023 05:21:05 -0400 Subject: [PATCH] feat(trading): data grid dropdown menu in collateral table and vega icons (#3472) --- .../src/integration/trading-accounts.cy.ts | 11 +-- libs/accounts/src/lib/accounts-table.spec.tsx | 9 +- libs/accounts/src/lib/accounts-table.tsx | 99 ++++++++++++++----- .../network-switcher/network-switcher.tsx | 9 +- .../src/components/dialog/dialog.tsx | 2 +- .../dropdown-menu/dropdown-menu.tsx | 34 ++++--- .../icon/{ => blueprint-icons}/icon.spec.tsx | 0 .../{ => blueprint-icons}/icon.stories.tsx | 0 .../icon/{ => blueprint-icons}/icon.tsx | 0 .../components/icon/blueprint-icons/index.ts | 1 + libs/ui-toolkit/src/components/icon/index.ts | 3 +- .../src/components/icon/vega-icons/index.ts | 3 + .../vega-icons/svg-icons/icon-breakdown.tsx | 29 ++++++ .../icon/vega-icons/svg-icons/icon-copy.tsx | 18 ++++ .../vega-icons/svg-icons/icon-deposit.tsx | 17 ++++ .../icon/vega-icons/svg-icons/icon-edit.tsx | 18 ++++ .../icon/vega-icons/svg-icons/icon-forum.tsx | 18 ++++ .../icon/vega-icons/svg-icons/icon-globe.tsx | 18 ++++ .../vega-icons/svg-icons/icon-linkedin.tsx | 16 +++ .../icon/vega-icons/svg-icons/icon-moon.tsx | 23 +++++ .../svg-icons/icon-open-external.tsx | 16 +++ .../svg-icons/icon-question-mark.tsx | 18 ++++ .../vega-icons/svg-icons/icon-transfer.tsx | 20 ++++ .../vega-icons/svg-icons/icon-twitter.tsx | 16 +++ .../vega-icons/svg-icons/icon-withdraw.tsx | 17 ++++ .../icon/vega-icons/vega-icon-record.ts | 48 +++++++++ .../icon/vega-icons/vega-icon.spec.tsx | 11 +++ .../icon/vega-icons/vega-icon.stories.tsx | 28 ++++++ .../components/icon/vega-icons/vega-icon.tsx | 24 +++++ 29 files changed, 463 insertions(+), 63 deletions(-) rename libs/ui-toolkit/src/components/icon/{ => blueprint-icons}/icon.spec.tsx (100%) rename libs/ui-toolkit/src/components/icon/{ => blueprint-icons}/icon.stories.tsx (100%) rename libs/ui-toolkit/src/components/icon/{ => blueprint-icons}/icon.tsx (100%) create mode 100644 libs/ui-toolkit/src/components/icon/blueprint-icons/index.ts create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/index.ts create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-breakdown.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-copy.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-deposit.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-edit.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-forum.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-globe.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-linkedin.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-moon.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-open-external.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-question-mark.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-transfer.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-twitter.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-withdraw.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/vega-icon-record.ts create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.spec.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.stories.tsx create mode 100644 libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.tsx diff --git a/apps/trading-e2e/src/integration/trading-accounts.cy.ts b/apps/trading-e2e/src/integration/trading-accounts.cy.ts index 0a4ecdc54..16823221f 100644 --- a/apps/trading-e2e/src/integration/trading-accounts.cy.ts +++ b/apps/trading-e2e/src/integration/trading-accounts.cy.ts @@ -25,17 +25,12 @@ describe('accounts', { tags: '@smoke' }, () => { cy.getByTestId('tab-accounts') .get(tradingAccountRowId) .find('[col-id="accounts-actions"]') - .should('have.text', 'DepositWithdraw'); + .should('have.text', ''); cy.getByTestId('tab-accounts') .get(tradingAccountRowId) - .find('[data-testid="deposit"]') - .should('have.text', 'Deposit'); - - cy.getByTestId('tab-accounts') - .get(tradingAccountRowId) - .find('[col-id="accounts-actions"] [data-testid="withdraw"]') - .should('have.text', 'Withdraw'); + .find('[col-id="accounts-actions"]') + .should('have.text', ''); cy.getByTestId('tab-accounts') .get(tradingAccountRowId) diff --git a/libs/accounts/src/lib/accounts-table.spec.tsx b/libs/accounts/src/lib/accounts-table.spec.tsx index 7539a5303..cf3538a1b 100644 --- a/libs/accounts/src/lib/accounts-table.spec.tsx +++ b/libs/accounts/src/lib/accounts-table.spec.tsx @@ -61,14 +61,7 @@ describe('AccountsTable', () => { ); }); const cells = await screen.findAllByRole('gridcell'); - const expectedValues = [ - 'tBTC', - '1,256.00', - '1,256.00', - '2,512.00', - 'Deposit', - 'Withdraw', - ]; + const expectedValues = ['tBTC', '1,256.00', '1,256.00', '2,512.00', '']; cells.forEach((cell, i) => { expect(cell).toHaveTextContent(expectedValues[i]); }); diff --git a/libs/accounts/src/lib/accounts-table.tsx b/libs/accounts/src/lib/accounts-table.tsx index dfd80d8a3..ff820a428 100644 --- a/libs/accounts/src/lib/accounts-table.tsx +++ b/libs/accounts/src/lib/accounts-table.tsx @@ -9,7 +9,17 @@ import type { VegaICellRendererParams, VegaValueFormatterParams, } from '@vegaprotocol/datagrid'; -import { Button, ButtonLink, Dialog } from '@vegaprotocol/ui-toolkit'; +import { + Button, + ButtonLink, + Dialog, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, + VegaIcon, + VegaIconNames, +} from '@vegaprotocol/ui-toolkit'; import { TooltipCellComponent } from '@vegaprotocol/ui-toolkit'; import { AgGridDynamic as AgGrid, @@ -122,7 +132,7 @@ export const AccountTable = forwardRef( params.data.asset.id === pinnedAssetId && new BigNumber(params.data.total).isLessThanOrEqualTo(0) ? 32 - : 22, + : 24, [pinnedAssetId] ); @@ -256,7 +266,7 @@ export const AccountTable = forwardRef( colId="accounts-actions" headerName="" sortable={false} - minWidth={200} + maxWidth={200} type="rightAligned" cellRenderer={({ data, @@ -283,30 +293,65 @@ export const AccountTable = forwardRef( ); } return ( - <> - - {!props.isReadOnly && ( - { - onClickDeposit && onClickDeposit(data.asset.id); - }} - > - {t('Deposit')} - - )} - - {!props.isReadOnly && ( - - onClickWithdraw && onClickWithdraw(data.asset.id) - } - > - {t('Withdraw')} - - )} - + !props.isReadOnly && ( + + } + > + + { + onClickDeposit && onClickDeposit(data.asset.id); + }} + > + + + {t('Deposit')} + + + + onClickWithdraw && onClickWithdraw(data.asset.id) + } + > + + + {t('Withdraw')} + + + { + setOpenBreakdown(!openBreakdown); + setRow(data); + }} + > + + + {t('Breakdown')} + + + + + ) ); } }} diff --git a/libs/environment/src/components/network-switcher/network-switcher.tsx b/libs/environment/src/components/network-switcher/network-switcher.tsx index 8302a384b..4f7392342 100644 --- a/libs/environment/src/components/network-switcher/network-switcher.tsx +++ b/libs/environment/src/components/network-switcher/network-switcher.tsx @@ -70,7 +70,7 @@ const NetworkLabel = ({ isCurrent = false, isAvailable = false, }: NetworkLabelProps) => ( - + {getLabelText({ isCurrent, isAvailable })} ); @@ -111,9 +111,12 @@ export const NetworkSwitcher = ({ trigger={ - {envTriggerMapping[current]} + {envTriggerMapping[current]} } > diff --git a/libs/ui-toolkit/src/components/dialog/dialog.tsx b/libs/ui-toolkit/src/components/dialog/dialog.tsx index 2b886b42a..21918b352 100644 --- a/libs/ui-toolkit/src/components/dialog/dialog.tsx +++ b/libs/ui-toolkit/src/components/dialog/dialog.tsx @@ -62,7 +62,7 @@ export function Dialog({ onChange?.(x)}> , - React.ComponentProps ->(({ className, children, ...props }, forwardedRef) => { - const triggerClasses = classNames( - className, - 'text-sm py-1 px-2 rounded bg-transparent border border-neutral-500 whitespace-nowrap', - 'hover:bg-neutral-500/20 dark:hover:bg-neutral-500/40' - ); + DropdownTriggerProps +>(({ className, children, iconName, ...props }, forwardedRef) => { + const defaultClasses = + 'text-sm py-1 px-2 rounded bg-transparent border border-vega-dark-200 whitespace-nowrap dark:hover:bg-vega-dark-500/20 hover:bg-vega-light-500/40'; + return ( ); @@ -73,7 +77,7 @@ export const DropdownMenuContent = forwardRef< @@ -115,9 +119,9 @@ export const DropdownMenuRadioItem = forwardRef< React.ComponentProps & { inset?: boolean; } ->(({ className, inset = false, ...radioItemprops }, forwardedRef) => ( +>(({ className, inset = false, ...radioItemProps }, forwardedRef) => ( @@ -151,7 +155,7 @@ export const DropdownMenuSeparator = forwardRef< {...separatorProps} ref={forwardedRef} className={classNames( - 'h-px my-1 mx-2 bg-neutral-400 dark:bg-neutral-300', + 'h-px my-1 mx-2 bg-vega-dark-400 dark:bg-vega-dark-300', className )} /> diff --git a/libs/ui-toolkit/src/components/icon/icon.spec.tsx b/libs/ui-toolkit/src/components/icon/blueprint-icons/icon.spec.tsx similarity index 100% rename from libs/ui-toolkit/src/components/icon/icon.spec.tsx rename to libs/ui-toolkit/src/components/icon/blueprint-icons/icon.spec.tsx diff --git a/libs/ui-toolkit/src/components/icon/icon.stories.tsx b/libs/ui-toolkit/src/components/icon/blueprint-icons/icon.stories.tsx similarity index 100% rename from libs/ui-toolkit/src/components/icon/icon.stories.tsx rename to libs/ui-toolkit/src/components/icon/blueprint-icons/icon.stories.tsx diff --git a/libs/ui-toolkit/src/components/icon/icon.tsx b/libs/ui-toolkit/src/components/icon/blueprint-icons/icon.tsx similarity index 100% rename from libs/ui-toolkit/src/components/icon/icon.tsx rename to libs/ui-toolkit/src/components/icon/blueprint-icons/icon.tsx diff --git a/libs/ui-toolkit/src/components/icon/blueprint-icons/index.ts b/libs/ui-toolkit/src/components/icon/blueprint-icons/index.ts new file mode 100644 index 000000000..af77d84ef --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/blueprint-icons/index.ts @@ -0,0 +1 @@ +export * from './icon'; diff --git a/libs/ui-toolkit/src/components/icon/index.ts b/libs/ui-toolkit/src/components/icon/index.ts index af77d84ef..f02899246 100644 --- a/libs/ui-toolkit/src/components/icon/index.ts +++ b/libs/ui-toolkit/src/components/icon/index.ts @@ -1 +1,2 @@ -export * from './icon'; +export * from './blueprint-icons'; +export * from './vega-icons'; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/index.ts b/libs/ui-toolkit/src/components/icon/vega-icons/index.ts new file mode 100644 index 000000000..a84f70849 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/index.ts @@ -0,0 +1,3 @@ +export * from './vega-icon'; +export * from './vega-icon.stories'; +export * from './vega-icon-record'; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-breakdown.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-breakdown.tsx new file mode 100644 index 000000000..43c910f86 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-breakdown.tsx @@ -0,0 +1,29 @@ +export const IconBreakdown = ({ size = 16 }: { size: number }) => { + return ( + + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-copy.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-copy.tsx new file mode 100644 index 000000000..8873fa553 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-copy.tsx @@ -0,0 +1,18 @@ +export const IconCopy = ({ size = 16 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-deposit.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-deposit.tsx new file mode 100644 index 000000000..c0d15dc2d --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-deposit.tsx @@ -0,0 +1,17 @@ +export const IconDeposit = ({ size = 16 }: { size: number }) => { + return ( + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-edit.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-edit.tsx new file mode 100644 index 000000000..fadb9a59f --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-edit.tsx @@ -0,0 +1,18 @@ +export const IconEdit = ({ size = 16 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-forum.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-forum.tsx new file mode 100644 index 000000000..6874233e5 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-forum.tsx @@ -0,0 +1,18 @@ +export const IconForum = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-globe.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-globe.tsx new file mode 100644 index 000000000..64137f532 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-globe.tsx @@ -0,0 +1,18 @@ +export const IconGlobe = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-linkedin.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-linkedin.tsx new file mode 100644 index 000000000..589b59a45 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-linkedin.tsx @@ -0,0 +1,16 @@ +export const IconLinkedIn = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-moon.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-moon.tsx new file mode 100644 index 000000000..038695aa6 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-moon.tsx @@ -0,0 +1,23 @@ +export const IconMoon = ({ size = 16 }: { size: number }) => { + return ( + + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-open-external.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-open-external.tsx new file mode 100644 index 000000000..70ce980ec --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-open-external.tsx @@ -0,0 +1,16 @@ +export const IconOpenExternal = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-question-mark.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-question-mark.tsx new file mode 100644 index 000000000..f329f012c --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-question-mark.tsx @@ -0,0 +1,18 @@ +export const IconQuestionMark = ({ size = 16 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-transfer.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-transfer.tsx new file mode 100644 index 000000000..1542a9633 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-transfer.tsx @@ -0,0 +1,20 @@ +export const IconTransfer = ({ size = 16 }: { size: number }) => { + return ( + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-twitter.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-twitter.tsx new file mode 100644 index 000000000..893025e51 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-twitter.tsx @@ -0,0 +1,16 @@ +export const IconTwitter = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-withdraw.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-withdraw.tsx new file mode 100644 index 000000000..e2d89b1ae --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-withdraw.tsx @@ -0,0 +1,17 @@ +export const IconWithdraw = ({ size = 16 }: { size: number }) => { + return ( + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon-record.ts b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon-record.ts new file mode 100644 index 000000000..2b4723cbb --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon-record.ts @@ -0,0 +1,48 @@ +import { IconBreakdown } from './svg-icons/icon-breakdown'; +import { IconCopy } from './svg-icons/icon-copy'; +import { IconDeposit } from './svg-icons/icon-deposit'; +import { IconWithdraw } from './svg-icons/icon-withdraw'; +import { IconTransfer } from './svg-icons/icon-transfer'; +import { IconEdit } from './svg-icons/icon-edit'; +import { IconMoon } from './svg-icons/icon-moon'; +import { IconGlobe } from './svg-icons/icon-globe'; +import { IconLinkedIn } from './svg-icons/icon-linkedin'; +import { IconTwitter } from './svg-icons/icon-twitter'; +import { IconQuestionMark } from './svg-icons/icon-question-mark'; +import { IconForum } from './svg-icons/icon-forum'; +import { IconOpenExternal } from './svg-icons/icon-open-external'; + +export enum VegaIconNames { + BREAKDOWN = 'breakdown', + COPY = 'copy', + DEPOSIT = 'deposit', + WITHDRAW = 'withdraw', + EDIT = 'edit', + TRANSFER = 'transfer', + FORUM = 'forum', + GLOBE = 'globe', + LINKEDIN = 'linkedin', + TWITTER = 'twitter', + MOON = 'moon', + OPEN_EXTERNAL = 'open-external', + QUESTION_MARK = 'question-mark', +} + +export const VegaIconNameMap: Record< + VegaIconNames, + ({ size }: { size: number }) => JSX.Element +> = { + breakdown: IconBreakdown, + copy: IconCopy, + deposit: IconDeposit, + withdraw: IconWithdraw, + transfer: IconTransfer, + edit: IconEdit, + moon: IconMoon, + globe: IconGlobe, + linkedin: IconLinkedIn, + twitter: IconTwitter, + 'question-mark': IconQuestionMark, + forum: IconForum, + 'open-external': IconOpenExternal, +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.spec.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.spec.tsx new file mode 100644 index 000000000..4faaee577 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.spec.tsx @@ -0,0 +1,11 @@ +import { render } from '@testing-library/react'; + +import { VegaIcon } from './vega-icon'; +import { VegaIconNames } from './vega-icon-record'; + +describe('VegaIcon', () => { + it('should render successfully', () => { + const { baseElement } = render(); + expect(baseElement).toBeTruthy(); + }); +}); diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.stories.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.stories.tsx new file mode 100644 index 000000000..ae42d2676 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.stories.tsx @@ -0,0 +1,28 @@ +import type { Story, Meta } from '@storybook/react'; +import type { VegaIconProps } from './vega-icon'; +import { VegaIcon } from './vega-icon'; +import { VegaIconNames } from './vega-icon-record'; + +export default { + component: VegaIcon, + title: 'VegaIcon', +} as Meta; + +const Template: Story = (args) => ; + +export const Small = Template.bind({}); +Small.args = { + name: VegaIconNames.BREAKDOWN, +}; + +export const Bigger = Template.bind({}); +Bigger.args = { + name: VegaIconNames.DEPOSIT, + size: 24, +}; + +export const EvenBigger = Template.bind({}); +EvenBigger.args = { + name: VegaIconNames.GLOBE, + size: 32, +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.tsx new file mode 100644 index 000000000..a5f497278 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.tsx @@ -0,0 +1,24 @@ +import classNames from 'classnames'; + +import type { VegaIconNames } from './vega-icon-record'; +import { VegaIconNameMap } from './vega-icon-record'; + +export interface VegaIconProps { + name: VegaIconNames; + size?: 16 | 24 | 32; +} + +export const VegaIcon = ({ size = 16, name }: VegaIconProps) => { + const effectiveClassName = classNames( + 'inline-block', + 'align-text-bottom', + 'pr-1', + 'stroke-current' + ); + const Element = VegaIconNameMap[name]; + return ( + + + + ); +};