Skip to content

Commit

Permalink
Merge pull request #75 from input-output-hk/fix/lw-12272-simple-asset…
Browse files Browse the repository at this point in the history
…-input

fix: expand simple asset input to occupy 100% width
  • Loading branch information
greatertomi authored Feb 13, 2025
2 parents 6c6cdad + c8bd477 commit 472f498
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
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' });

0 comments on commit 472f498

Please sign in to comment.