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: expand simple asset input to occupy 100% width #75

Merged
merged 1 commit into from
Feb 13, 2025
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
10 changes: 8 additions & 2 deletions src/design-system/asset-input/amount-input.component.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';

import cn from 'classnames';

import { Box } from '../box';

import * as cx from './amount-input.css';
Expand All @@ -11,6 +13,8 @@ interface Props {
value?: string;
id: string;
testId?: string;
className?: string;
inputClassName?: string;
}

export const AmountInput = ({
Expand All @@ -19,11 +23,13 @@ export const AmountInput = ({
value,
id,
testId,
className,
inputClassName,
}: Readonly<Props>): JSX.Element => {
return (
<Box className={cx.amountInputSizer} data-value={value}>
<Box className={cn(cx.amountInputSizer, className)} data-value={value}>
<input
className={cx.amountInput[alignment]}
className={cn(cx.amountInput[alignment], inputClassName)}
value={value}
size={1}
onChange={({ target }): void => onChange?.(target.value)}
Expand Down
16 changes: 15 additions & 1 deletion src/design-system/asset-input/asset-input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ const AssetInputMainComponents = (): JSX.Element => (
</Variants.Row>
);

const SimpleAssetInputMainComponents = (): JSX.Element => (
<Variants.Row>
<Variants.Cell>
<SimpleAssetInput
state={validState('1')}
balanceLabel="Balance Available"
/>
</Variants.Cell>
</Variants.Row>
);

const AssetInputUIStates = (): JSX.Element => (
<>
<Variants.Row>
Expand Down Expand Up @@ -94,9 +105,12 @@ export const Overview = (): JSX.Element => (
<Divider my="$64" />

<Section title="Main components">
<ColorSchemaTable headers={['Rest']}>
<ColorSchemaTable headers={['Asset Input']}>
<AssetInputMainComponents />
</ColorSchemaTable>
<ColorSchemaTable headers={['Simple Asset Input']}>
<SimpleAssetInputMainComponents />
</ColorSchemaTable>
</Section>

<Divider my="$64" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const SimpleAssetInput = ({
onAmountChange?.(state.asset, value);
}}
testId={testId}
className={cx.amountInputContainer}
inputClassName={cx.amountInput}
/>
</Box>
<Box className={cx.balance}>
Expand Down
4 changes: 4 additions & 0 deletions src/design-system/asset-input/simple-asset-input.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const root = style([

export const amountBox = style({ gridArea: 'amount' });

export const amountInputContainer = style({ display: 'flex' });

export const amountInput = style({ width: '100%' });

export const balance = style({ gridArea: 'balance' });

export const error = style({ gridArea: 'error' });