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(ui): fix styles for subaccount selector #1886

Merged
merged 2 commits into from
Oct 31, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/quiet-cars-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@penumbra-zone/ui': patch
---

Fix and improve UI components to prepare them for sub-account selector
17 changes: 12 additions & 5 deletions packages/ui/src/AddressViewComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ const Root = styled.div`
export interface AddressViewProps {
addressView: AddressView | undefined;
copyable?: boolean;
hideIcon?: boolean;
}

// Renders an address or an address view.
// If the view is given and is "visible", the account information will be displayed instead.
export const AddressViewComponent = ({ addressView, copyable = true }: AddressViewProps) => {
export const AddressViewComponent = ({
addressView,
copyable = true,
hideIcon,
}: AddressViewProps) => {
if (!addressView?.addressView.value?.address) {
return null;
}
Expand All @@ -34,14 +39,16 @@ export const AddressViewComponent = ({ addressView, copyable = true }: AddressVi

return (
<Root>
<Shrink0>
<AddressIcon address={addressView.addressView.value.address} size={24} />
</Shrink0>
{!hideIcon && (
<Shrink0>
<AddressIcon address={addressView.addressView.value.address} size={24} />
</Shrink0>
)}

{addressIndex ? (
<Text strong truncate>
{isRandomized && 'IBC Deposit Address for '}
{`Account #${addressIndex.account}`}
{`Sub-Account #${addressIndex.account}`}
</Text>
) : (
<Text technical truncate>
Expand Down
5 changes: 3 additions & 2 deletions packages/ui/src/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ const iconOnlyAdornment = css<StyledButtonProps>`

const sparse = css<StyledButtonProps>`
border-radius: ${props => props.theme.borderRadius.sm};
padding-left: ${props => props.theme.spacing(4)};
padding-right: ${props => props.theme.spacing(4)};
padding-left: ${props => (props.$iconOnly ? 'none' : props.theme.spacing(4))};
padding-right: ${props => (props.$iconOnly ? 'none' : props.theme.spacing(4))};
height: 48px;
width: ${props => (props.$iconOnly ? '48px' : '100%')};
${props => props.$iconOnly && 'min-width: 48px;'}
`;

const compact = css<StyledButtonProps>`
Expand Down
7 changes: 5 additions & 2 deletions packages/ui/src/DropdownMenu/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReactNode } from 'react';
import { ReactNode } from 'react';
import { Item as RadixDropdownMenuItem } from '@radix-ui/react-dropdown-menu';
import { asTransientProps } from '../utils/asTransientProps.ts';
import { Text } from '../Text';
Expand All @@ -7,17 +7,20 @@ import { DropdownMenuItemBase, MenuItem } from '../utils/menuItem.ts';
export interface DropdownMenuItemProps extends DropdownMenuItemBase {
children?: ReactNode;
onSelect?: (event: Event) => void;
icon?: ReactNode;
}

export const Item = ({
children,
icon,
actionType = 'default',
disabled,
onSelect,
}: DropdownMenuItemProps) => {
return (
<RadixDropdownMenuItem disabled={disabled} asChild onSelect={onSelect}>
<MenuItem {...asTransientProps({ actionType, disabled })}>
<MenuItem data-icon={!!icon} {...asTransientProps({ actionType, disabled })}>
{icon}
<Text small>{children}</Text>
</MenuItem>
</RadixDropdownMenuItem>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/utils/menuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const MenuItem = styled.div<StyledItemProps>`
}

&[aria-checked='false'],
&[role='menuitem'] {
&[role='menuitem'][data-icon='false'] {
padding-left: ${props => props.theme.spacing(9)};
}

Expand Down
Loading