Skip to content

Commit

Permalink
Rebuilding input container (#1355)
Browse files Browse the repository at this point in the history
Co-authored-by: Mayank <9084735+mayank99@users.noreply.github.com>
  • Loading branch information
gretanausedaite and mayank99 committed Aug 30, 2023
1 parent 962ce09 commit 31fe9c9
Show file tree
Hide file tree
Showing 289 changed files with 3,247 additions and 1,750 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-peas-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': minor
---

Added `status` prop to `Input`, `Textarea` and `Select`.
5 changes: 5 additions & 0 deletions .changeset/clean-buttons-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-css': minor
---

Added `iui-input-group-wrapper` class to allow inline labels for input groups.
9 changes: 9 additions & 0 deletions .changeset/cyan-jars-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@itwin/itwinui-react': minor
---

Added two new components for building complex input layouts.
- `InputGrid` for the "outer" layout (label, inputs and statusMessage)
- `InputWithDecorations` for the "inner" layout (start icon/button, end icon/button)

`LabeledInput`, `LabeledSelect`, `LabeledTextarea` and table `DatePickerInput` have been updated to make use of these new components internally.
5 changes: 5 additions & 0 deletions .changeset/eighty-chefs-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-css': major
---

`iui-transfer-list-listbox-label` and `iui-input-container` classes were removed.
5 changes: 5 additions & 0 deletions .changeset/friendly-pigs-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-css': minor
---

Added `iui-input-grid` class for outer input styling.
5 changes: 5 additions & 0 deletions .changeset/healthy-vans-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': major
---

Removed `inputStyle` and `inputClassName` props from `LabeledInput`; style and className props are being passed down to input. Added `wrapperProps`, `labelProps`, `messageProps`, `messageIconProps`, `inputWrapperProps` to pass props to sub elements.
5 changes: 5 additions & 0 deletions .changeset/hip-comics-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': minor
---

Added new `padded` prop to `Icon`.
5 changes: 5 additions & 0 deletions .changeset/light-buses-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': major
---

Removed `selectStyle` and `selectClassName` props from `LabeledSelect`; style and className props are being passed down to textarea. Added `wrapperProps`, `labelProps`, `messageProps`, `messageIconProps` to pass props to sub elements.
5 changes: 5 additions & 0 deletions .changeset/loud-pants-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-css': minor
---

Added status styling to `input` and `select`.
5 changes: 5 additions & 0 deletions .changeset/nervous-kiwis-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': major
---

Removed `textareaStyle` and `textareaClassName` props from `LabeledTextarea`; style and className props are being passed down to textarea. Added `wrapperProps`, `labelProps`, `messageProps`, `messageIconProps` to pass props to sub elements.
5 changes: 5 additions & 0 deletions .changeset/silly-buttons-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-css': minor
---

Added padded styling to Icon using `data-iui-padded` attribute.
5 changes: 5 additions & 0 deletions .changeset/strong-parrots-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-css': minor
---

Added `iui-status-message` class to wrap StatusMessage icon and content.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...orybook/cypress-visual-screenshots/baseline/TransferList.test.ts-With Label.png
100644 → 100755
5 changes: 3 additions & 2 deletions apps/storybook/src/ComboBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
StatusMessage,
SelectOption,
MenuItemSkeleton,
Flex,
} from '@itwin/itwinui-react';
import { SvgCamera } from '@itwin/itwinui-icons-react';

Expand Down Expand Up @@ -382,7 +383,7 @@ export const WithLabel: StoryFn<Partial<ComboBoxProps>> = (args) => {
const options = React.useMemo(() => countriesList, []);

return (
<>
<Flex flexDirection='column' alignItems='unset' gap='2xs'>
<Label htmlFor='combo-input'>Country</Label>
<ComboBox
options={options}
Expand All @@ -393,7 +394,7 @@ export const WithLabel: StoryFn<Partial<ComboBoxProps>> = (args) => {
}}
{...args}
/>
</>
</Flex>
);
};
WithLabel.args = {
Expand Down
22 changes: 21 additions & 1 deletion apps/storybook/src/Icon.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Story, Meta } from '@storybook/react';
import React from 'react';
import { Icon, Slider } from '@itwin/itwinui-react';
import { Icon, Slider, Flex } from '@itwin/itwinui-react';
import {
SvgInfoCircular,
SvgPlaceholder,
Expand Down Expand Up @@ -42,6 +42,26 @@ Default.args = {
fill: 'default',
};

export const Padded: Story<IconProps> = (args) => {
return (
<Flex
style={{
border: '1px solid red',
width: 'fit-content',
}}
>
<Icon {...args}>
<SvgPlaceholder />
</Icon>
</Flex>
);
};
Padded.args = {
size: 'medium',
fill: 'default',
padded: true,
};

export const Statuses: Story<IconProps> = (args) => {
return (
<>
Expand Down
1 change: 1 addition & 0 deletions apps/storybook/src/Icon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('Icon', () => {
'Default',
'Statuses',
'Sizes',
'Padded',
// 'Autoscale', // exclude Autoscale because it is only an interactive demo for the user
];

Expand Down
9 changes: 9 additions & 0 deletions apps/storybook/src/Input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ Small.args = {
placeholder: 'Small Input',
size: 'small',
};

export const Status: Story<InputProps> = (args) => {
return <Input placeholder='Positive Input' status='positive' {...args} />;
};

Status.args = {
placeholder: 'Positive Input',
status: 'positive',
};
2 changes: 1 addition & 1 deletion apps/storybook/src/Input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
describe('Input', () => {
const storyPath = 'Input/Input';
const tests = ['Basic', 'Disabled', 'Small'];
const tests = ['Basic', 'Disabled', 'Small', 'Status'];

tests.forEach((testName) => {
it(testName, function () {
Expand Down
89 changes: 89 additions & 0 deletions apps/storybook/src/InputGrid.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { Story, Meta } from '@storybook/react';
import React from 'react';
import {
Input,
InputGrid,
InputWithDecorations,
Label,
Icon,
SearchBox,
Select,
StatusMessage,
} from '@itwin/itwinui-react';
import { SvgAdd, SvgAirplane } from '@itwin/itwinui-icons-react';

type InputGridProps = React.ComponentProps<typeof InputGrid>;

export default {
component: InputGrid,
title: 'Utilities/InputGrid',
argTypes: {},
} as Meta<InputGridProps>;

export const WithInput: Story<InputGridProps> = () => {
return (
<InputGrid>
<Label htmlFor='input-id'>This is label</Label>
<Input id='input-id' />
<StatusMessage>This is message</StatusMessage>
</InputGrid>
);
};

export const WithInputWithDecorations: Story<InputGridProps> = () => {
return (
<InputGrid>
<Label htmlFor='input-id'>This is label</Label>
<InputWithDecorations>
<Icon padded>
<SvgAirplane />
</Icon>
<InputWithDecorations.Input
placeholder='Add destination...'
id='input-id'
/>
<InputWithDecorations.Button label='Add new flight'>
<SvgAdd />
</InputWithDecorations.Button>
</InputWithDecorations>
<StatusMessage>This is message</StatusMessage>
</InputGrid>
);
};

export const WithSelect: Story<InputGridProps> = () => {
const options = [
{ value: 1, label: 'Bali' },
{ value: 2, label: 'Hawaii' },
{ value: 3, label: 'Madagascar' },
];
const [value, setValue] = React.useState<number | undefined>(undefined);

return (
<InputGrid>
<Label htmlFor='input-id'>This is label</Label>
<Select
id='input-id'
options={options}
placeholder='Select destination'
value={value}
onChange={(value) => setValue(value)}
/>
<StatusMessage>This is message</StatusMessage>
</InputGrid>
);
};

export const WithSearch: Story<InputGridProps> = () => {
return (
<InputGrid labelPlacement='inline'>
<Label htmlFor='input-id'>This is label</Label>
<SearchBox inputProps={{ id: 'input-id' }} />
<StatusMessage>This is message</StatusMessage>
</InputGrid>
);
};
22 changes: 22 additions & 0 deletions apps/storybook/src/InputGrid.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
describe('InputGrid', () => {
const storyPath = 'Utilities/InputGrid';

const tests = [
'With Input',
'With Input With Decorations',
'With Select',
'With Search',
];

tests.forEach((testName) => {
it(testName, function () {
const id = Cypress.storyId(storyPath, testName);
cy.visit('iframe', { qs: { id } });
cy.compareSnapshot(testName);
});
});
});
73 changes: 73 additions & 0 deletions apps/storybook/src/InputWithDecoration.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { Meta, Story } from '@storybook/react';
import React from 'react';
import { InputWithDecorations, Icon } from '@itwin/itwinui-react';
import { SvgAdd, SvgAirplane } from '@itwin/itwinui-icons-react';

type InputWithDecorationsProps = React.ComponentProps<
typeof InputWithDecorations
>;

export default {
title: 'Input/InputWithDecorations',
component: InputWithDecorations,
} as Meta<InputWithDecorationsProps>;

export const Basic: Story<InputWithDecorationsProps> = () => {
return (
<InputWithDecorations>
<Icon padded>
<SvgAirplane />
</Icon>
<InputWithDecorations.Input placeholder='Input..' />
<InputWithDecorations.Button label='Custom button'>
<SvgAdd />
</InputWithDecorations.Button>
</InputWithDecorations>
);
};

export const Disabled: Story<InputWithDecorationsProps> = () => {
return (
<InputWithDecorations isDisabled>
<Icon padded>
<SvgAirplane />
</Icon>
<InputWithDecorations.Input placeholder='Disabled input' />
<InputWithDecorations.Button label='Custom button'>
<SvgAdd />
</InputWithDecorations.Button>
</InputWithDecorations>
);
};

export const Small: Story<InputWithDecorationsProps> = () => {
return (
<InputWithDecorations size='small'>
<Icon size='s' padded>
<SvgAirplane />
</Icon>
<InputWithDecorations.Input placeholder='Small input' />
<InputWithDecorations.Button label='Custom button'>
<SvgAdd />
</InputWithDecorations.Button>
</InputWithDecorations>
);
};

export const Status: Story<InputWithDecorationsProps> = () => {
return (
<InputWithDecorations status='positive'>
<Icon padded>
<SvgAirplane />
</Icon>
<InputWithDecorations.Input placeholder='Positive input' />
<InputWithDecorations.Button label='Custom button'>
<SvgAdd />
</InputWithDecorations.Button>
</InputWithDecorations>
);
};
16 changes: 16 additions & 0 deletions apps/storybook/src/InputWithDecoration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
describe('InputWithDecorations', () => {
const storyPath = 'Input/InputWithDecorations';
const tests = ['Basic', 'Disabled', 'Small', 'Status'];

tests.forEach((testName) => {
it(testName, function () {
const id = Cypress.storyId(storyPath, testName);
cy.visit('iframe', { qs: { id } });
cy.compareSnapshot(testName);
});
});
});

0 comments on commit 31fe9c9

Please sign in to comment.