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

Rebuilding input container #1355

Merged
merged 162 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
3fe09ea
Breaking stuff to rebuild them later
gretanausedaite Jun 14, 2023
728b5b6
Merge branch 'dev' into greta/input-work
gretanausedaite Jun 15, 2023
8c104a7
Starting to make sense now
gretanausedaite Jun 15, 2023
2f0b7d3
Disabled and size handling
gretanausedaite Jun 15, 2023
f19d4fb
Added required option
gretanausedaite Jun 15, 2023
63324d7
One more wrapper component
gretanausedaite Jun 15, 2023
214cb8c
Merge branch 'dev' into greta/input-work
gretanausedaite Jun 27, 2023
0eab653
With simple input
gretanausedaite Jun 27, 2023
d468354
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Jun 29, 2023
5506d9e
Cleanup naming
gretanausedaite Jun 29, 2023
822da4f
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Jun 30, 2023
e5c1d83
remove subcomponents from inputgrid
gretanausedaite Jun 30, 2023
f1e781f
Undo labeledinput test update
gretanausedaite Jun 30, 2023
174e45c
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Jul 3, 2023
bce6118
move code around
gretanausedaite Jul 3, 2023
89f3ea7
Add status to input
gretanausedaite Jul 4, 2023
079a526
Merge branch 'dev' into greta/input-work
gretanausedaite Jul 4, 2023
2996529
Other labeled components
gretanausedaite Jul 4, 2023
6c909de
Label disabled styling
gretanausedaite Jul 4, 2023
d8aef62
New components stories
gretanausedaite Jul 4, 2023
da61b72
Select and textarea status
gretanausedaite Jul 4, 2023
5639be2
not needed import
gretanausedaite Jul 4, 2023
330bedc
cleanup
gretanausedaite Jul 5, 2023
de4bddb
css test html
gretanausedaite Jul 5, 2023
7cba777
Merge branch 'dev' into greta/input-work
gretanausedaite Jul 7, 2023
1d9928f
fix classname input-grid
gretanausedaite Jul 7, 2023
3b74109
input-grid css tests
gretanausedaite Jul 7, 2023
3580a60
mixin for border color
gretanausedaite Jul 7, 2023
a335819
jsdocs
gretanausedaite Jul 7, 2023
3d6ef29
basic tests
gretanausedaite Jul 7, 2023
77024d6
Maybe now css is ok
gretanausedaite Jul 10, 2023
503927a
Some tests fixed
gretanausedaite Jul 10, 2023
a15401a
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Jul 11, 2023
6ed5861
react image tests fix
gretanausedaite Jul 11, 2023
2e07870
Uni tests fix?
gretanausedaite Jul 11, 2023
3e047b3
css tests fix
gretanausedaite Jul 11, 2023
b218024
Merge branch 'dev' into greta/input-work
gretanausedaite Jul 12, 2023
a564bcf
logical rules
gretanausedaite Jul 12, 2023
14fdee0
status styling update
gretanausedaite Jul 12, 2023
4b1b5d3
Maybe test fix?
gretanausedaite Jul 13, 2023
db37f06
Make label disabled as attr
gretanausedaite Jul 13, 2023
e3a46de
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Jul 14, 2023
1c73f2f
one more tests fix
gretanausedaite Jul 14, 2023
75c833e
Merge branch 'dev' into greta/input-work
gretanausedaite Jul 17, 2023
0a647f3
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Jul 18, 2023
21157b5
fix storybook tests
gretanausedaite Jul 18, 2023
3b6c37f
Label comment update
gretanausedaite Jul 18, 2023
d90cc7f
Merge branch 'dev' into greta/input-work
gretanausedaite Jul 20, 2023
6cf82a4
Some visuals fixed
gretanausedaite Jul 20, 2023
6d35bc9
InputGroup redo
gretanausedaite Jul 20, 2023
f56b698
color input redo
gretanausedaite Jul 20, 2023
2cc8b55
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Jul 24, 2023
7769c4f
breaking combobox to use InputGrid
gretanausedaite Jul 24, 2023
0e5fe34
Remove InputContainer
gretanausedaite Jul 24, 2023
3faa616
Forgot to remove one import of InputContainer
gretanausedaite Jul 24, 2023
4bfe187
Merge branch 'dev' into greta/input-work
gretanausedaite Jul 24, 2023
7feab2e
React image tests
gretanausedaite Jul 24, 2023
41c3890
Undo searchbox change
gretanausedaite Jul 24, 2023
ad2bb02
Undo more disabled prop name changes
gretanausedaite Jul 24, 2023
61199d4
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Jul 26, 2023
a349ac2
Undo combobox stuff
gretanausedaite Jul 27, 2023
c13d519
Input with decor disabled fix
gretanausedaite Jul 27, 2023
e27c3f1
InputWithDecor subcomponents disabled fix
gretanausedaite Jul 27, 2023
c0cff35
Maybe fix?
gretanausedaite Jul 27, 2023
81c2dfd
status message fix
gretanausedaite Jul 27, 2023
096ed28
Merge branch 'dev' into greta/input-work
gretanausedaite Jul 27, 2023
e4763cc
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Jul 28, 2023
a802936
status message order fix
gretanausedaite Jul 28, 2023
16ab206
Merge branch 'dev' into greta/input-work
gretanausedaite Jul 28, 2023
fc8a07b
Some tests fixed
gretanausedaite Jul 28, 2023
66db553
Merge branch 'dev' into greta/input-work
gretanausedaite Jul 31, 2023
7146d20
Fix InputGroup
gretanausedaite Jul 31, 2023
38079c8
InputGroup fix pt.2
gretanausedaite Jul 31, 2023
0669b3b
InputGroup customization
gretanausedaite Jul 31, 2023
c6f8249
fix types
gretanausedaite Jul 31, 2023
18892db
LabeledInput customization props
gretanausedaite Jul 31, 2023
7d50199
LabeledSelect custom props
gretanausedaite Aug 1, 2023
cd99d90
textarea custom props
gretanausedaite Aug 1, 2023
5f2a05f
Update images
gretanausedaite Aug 1, 2023
cdf51cc
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 1, 2023
8b8d2e1
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 2, 2023
17179a5
Fix react tests
gretanausedaite Aug 2, 2023
8215f48
Fix inline button?
gretanausedaite Aug 2, 2023
a3a5a20
Test is back
gretanausedaite Aug 2, 2023
3f9ee2d
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 2, 2023
a9e22e5
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 3, 2023
532997d
react tests fix
gretanausedaite Aug 3, 2023
b8211e7
Some fixes to html pages
gretanausedaite Aug 3, 2023
338fe5f
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 4, 2023
0fbef65
Fixing html test
gretanausedaite Aug 4, 2023
ab62b0c
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 7, 2023
a6196a5
Move margin to icon
gretanausedaite Aug 8, 2023
35a25c6
remove input decorator icon
gretanausedaite Aug 8, 2023
ed1d8ca
input-grid class to input-container
gretanausedaite Aug 8, 2023
39e92c2
image react approve
gretanausedaite Aug 8, 2023
1953299
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 9, 2023
d69b4f4
unit tests fix
gretanausedaite Aug 9, 2023
3fab879
icon padding fixes
gretanausedaite Aug 9, 2023
2ba02d1
Some css fixes
gretanausedaite Aug 9, 2023
bb5558b
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 9, 2023
75accff
Moving stuff around
gretanausedaite Aug 9, 2023
5eaaf23
End icon code delete
gretanausedaite Aug 9, 2023
af21022
fix combobox status
gretanausedaite Aug 9, 2023
34522c1
tests update
gretanausedaite Aug 10, 2023
4032f72
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 10, 2023
2e35ee4
tests update v456
gretanausedaite Aug 10, 2023
4f713e2
update arrow again
gretanausedaite Aug 10, 2023
32ef563
Story fixes
gretanausedaite Aug 10, 2023
67efa8e
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 11, 2023
d40e452
StatusMessage rework
gretanausedaite Aug 11, 2023
da28b71
remove inputwithdeco ref nonsense
gretanausedaite Aug 11, 2023
abd22d6
Add a check for custom message
gretanausedaite Aug 11, 2023
cec1e2f
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 11, 2023
efa3a87
Added changeset
gretanausedaite Aug 11, 2023
ed35d38
Merge remote-tracking branch 'origin/dev' into greta/input-work
gretanausedaite Aug 22, 2023
2cb5a4f
fix button group css file
gretanausedaite Aug 22, 2023
0267498
add back message
gretanausedaite Aug 22, 2023
e2f1a13
css image approve
gretanausedaite Aug 22, 2023
5b5a787
Fix unit tests
gretanausedaite Aug 22, 2023
056e99a
more react images
gretanausedaite Aug 22, 2023
d3aeb46
remove wrapper props
gretanausedaite Aug 22, 2023
4ccc973
test fix
gretanausedaite Aug 22, 2023
0e53c56
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 22, 2023
2088e23
inner props for input group
gretanausedaite Aug 23, 2023
2415e16
react images
gretanausedaite Aug 23, 2023
5d32ed0
placeholder css
gretanausedaite Aug 23, 2023
e359577
unify labels
gretanausedaite Aug 23, 2023
10c6c3b
css image update
gretanausedaite Aug 23, 2023
5e54003
Update packages/itwinui-css/src/input/input.scss
gretanausedaite Aug 23, 2023
9a96731
rename local focus variable
gretanausedaite Aug 23, 2023
fc30c66
Update textarea to reuse input
gretanausedaite Aug 23, 2023
3d3b11b
slider mess
gretanausedaite Aug 23, 2023
522fb9d
React changeset improvements
gretanausedaite Aug 23, 2023
2e8b782
css changeset update
gretanausedaite Aug 23, 2023
3539cc6
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 24, 2023
ea1f11f
Padded icon tests added
gretanausedaite Aug 24, 2023
30991a2
missed textarea image?
gretanausedaite Aug 24, 2023
9d0d01c
icon image update again ??
gretanausedaite Aug 24, 2023
3ee8b66
icon unit tests
gretanausedaite Aug 24, 2023
5bb2e61
Remove labeledinput icon check nonsense
gretanausedaite Aug 25, 2023
8bc6334
Update couple of images
gretanausedaite Aug 25, 2023
593d568
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 25, 2023
bcde31c
add textarea padding block back
gretanausedaite Aug 28, 2023
31aba97
Fix input story
gretanausedaite Aug 28, 2023
c3e5621
Changeset small update
gretanausedaite Aug 28, 2023
5f45e53
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 28, 2023
54df01e
Remove single icon in labeledselect
gretanausedaite Aug 28, 2023
95cd02e
Merge textarea into input code
gretanausedaite Aug 28, 2023
beea3fe
Co-authored-by: Mayank <mayank99@users.noreply.github.com>
gretanausedaite Aug 28, 2023
4a31f59
changeset fix
gretanausedaite Aug 28, 2023
7d14c7d
React images update
gretanausedaite Aug 28, 2023
09911d2
fix focus styling
gretanausedaite Aug 28, 2023
56a7816
css image update
gretanausedaite Aug 28, 2023
47de663
Move back to margin.
gretanausedaite Aug 29, 2023
86be72d
react images
gretanausedaite Aug 29, 2023
6e7682a
React image update 3000
gretanausedaite Aug 29, 2023
394fbac
css images
gretanausedaite Aug 29, 2023
fbdc50e
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 29, 2023
5889071
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 30, 2023
f472b13
Linked label with input in example
gretanausedaite Aug 30, 2023
9d6f78c
Small updates
gretanausedaite Aug 30, 2023
93b6a26
Merge branch 'dev' into greta/input-work
gretanausedaite Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 20 additions & 7 deletions apps/storybook/src/LabeledInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { SvgCloseSmall, SvgPlaceholder } from '@itwin/itwinui-icons-react';
import SvgCamera from '@itwin/itwinui-icons-react/cjs/icons/Camera';
import { Meta, Story } from '@storybook/react';
import React from 'react';
import { LabeledInput, Tooltip, IconButton } from '@itwin/itwinui-react';
import {
LabeledInput,
Tooltip,
IconButton,
FancyInput,
InputWrapper,
} from '@itwin/itwinui-react';

type LabeledInputProps = React.ComponentProps<typeof LabeledInput>;

Expand All @@ -27,13 +33,20 @@ export default {
},
} as Meta<LabeledInputProps>;

export const Basic: Story<LabeledInputProps> = (args) => {
export const Basic: Story<LabeledInputProps> = () => {
return (
<LabeledInput
placeholder='Enter text here...'
label='This is a label'
{...args}
/>
<FancyInput>
<FancyInput.Label>Label</FancyInput.Label>
<FancyInput.MiddlePart>
<InputWrapper>
<InputWrapper.Input />
<InputWrapper.Button>
<SvgCloseSmall />
</InputWrapper.Button>
</InputWrapper>
</FancyInput.MiddlePart>
<FancyInput.Message startIcon={<SvgCamera />}>Message</FancyInput.Message>
</FancyInput>
);
};

Expand Down
2 changes: 2 additions & 0 deletions packages/itwinui-css/src/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
@forward 'information-panel/information-panel';
@forward 'input/input';
@forward 'input-container/input-container';
@forward 'input-container/fancy-input';
@forward 'keyboard/keyboard';
@forward 'location-marker/location-marker';
@forward 'menu/menu';
@forward 'message/message';
@forward 'non-ideal-state/non-ideal-state';
@forward 'progress-indicator/progress-indicator';
@forward 'radio/radio';
Expand Down
93 changes: 93 additions & 0 deletions packages/itwinui-css/src/input-container/fancy-input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright (c) Bentley Systems, Incorporated. All rights reserved.
// See LICENSE.md in the project root for license terms and full copyright notice.
@use '../mixins';

.iui-fancy-input {
display: grid;
grid-template:
'label label'
'inputs inputs'
'message message' / auto 1fr;

&.iui-inline-label {
grid-template:
'label inputs inputs'
'. message message' / auto auto 1fr;
}

.iui-input-label {
font-weight: var(--iui-font-weight-semibold);
margin-bottom: var(--iui-size-2xs);
color: var(--_iui-input-label-color);

grid-area: label;
display: block;
align-self: center;

&.iui-required {
&::after {
content: '*';
margin-left: var(--iui-size-2xs);
color: var(--iui-color-text-negative);
}
}

&.iui-disabled {
--_iui-input-label-color: var(--iui-color-text-disabled);
cursor: not-allowed;
}

cursor: default;

&:is(label) {
cursor: pointer;

&.iui-disabled {
cursor: not-allowed;
}
}
}

.iui-input-message {
grid-area: message;
}

.iui-input-icon {
margin: 0 var(--iui-size-s);

&.iui-actionable {
align-items: center;
height: calc(100% - 4px); // subtract 2px on both sides to avoid overlapping with border/outline
margin-right: 2px; // shift 2px from the right to avoid overlapping with border/outline
border-radius: var(--iui-border-radius-1);
padding-inline: calc(var(--iui-size-xs) + 1px);
cursor: pointer;
box-sizing: content-box;

@include mixins.iui-ripple(var(--iui-color-background), var(--iui-color-background-backdrop));

svg {
fill: var(--iui-color-icon);
transition: transform var(--iui-duration-1) ease-out;
}

&.iui-open svg {
transform: rotate(180deg); // transform for arrow icon (e.g. svg-caret-down), used in combobox
}
}
}

&.iui-inline-label {
.iui-input-label {
margin: 0 var(--iui-size-m) 0 0;

&.iui-required {
margin-right: calc(var(--iui-size-2xs) * 1.5 - 1px);
}
}
}

.iui-fancy-input-wrapper {
grid-area: inputs;
}
}
56 changes: 56 additions & 0 deletions packages/itwinui-css/src/message/message.scss
mayank99 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) Bentley Systems, Incorporated. All rights reserved.
// See LICENSE.md in the project root for license terms and full copyright notice.
@use '../mixins';

.iui-message-content {
font-size: var(--iui-font-size-0);
margin-top: var(--iui-size-2xs);
color: var(--iui-color-text-muted);

a {
user-select: none;
mayank99 marked this conversation as resolved.
Show resolved Hide resolved
}
}

.iui-message-icon {
@include mixins.iui-icon-style('m');
mayank99 marked this conversation as resolved.
Show resolved Hide resolved
grid-area: icon;
align-self: center;

&:not(:last-child) {
margin-right: var(--iui-size-2xs);
}

svg:where(:not(.iui-button svg)) {
@include mixins.iui-icon-color;
}
}

.iui-message {
display: flex;

@each $status in positive, warning, negative {
&[data-iui-status='#{$status}'] {
.iui-message-content {
color: var(--iui-color-text-#{$status});

a {
text-decoration: underline;
color: var(--iui-color-text-#{$status});
}

a:hover {
text-decoration: none;
color: var(--iui-color-text-#{$status}-hover);
}
}

.iui-message-icon {
&,
svg {
fill: var(--iui-color-icon-#{$status});
}
}
}
}
}
170 changes: 170 additions & 0 deletions packages/itwinui-react/src/core/LabeledInput/FancyInput.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { render } from '@testing-library/react';
import * as React from 'react';

import { LabeledInput } from './LabeledInput.js';

const assertBaseElement = (container: HTMLElement) => {
const inputContainer = container.querySelector('.iui-input-container');
expect(inputContainer).toBeTruthy();
expect(container.querySelector('.iui-input')).toBeTruthy();
return inputContainer;
};

it('should render correctly in its most basic state', () => {
const { container, getByText } = render(<LabeledInput label='some label' />);
assertBaseElement(container);
const label = getByText('some label') as HTMLElement;
expect(label.className).toBe('iui-label');
});

it('should render disabled component', () => {
const { container, getByText } = render(
<LabeledInput label='some label' disabled />,
);
assertBaseElement(container);
expect(
container.querySelector('.iui-input-container.iui-disabled'),
).toBeTruthy();
getByText('some label');
expect((container.querySelector('input') as HTMLInputElement).disabled).toBe(
true,
);
});

it('should handle required attribute', () => {
const { container } = render(<LabeledInput label='some label' required />);
assertBaseElement(container);
expect(container.querySelector('.iui-label.iui-required')).toBeTruthy();
expect(
(container.querySelector('input') as HTMLInputElement).required,
).toBeTruthy();
});

it('should render message', () => {
const { container, getByText } = render(
<LabeledInput
label='some label'
message={<div className='my-message'>Message</div>}
/>,
);
const inputContainer = assertBaseElement(container);
expect(inputContainer).toHaveClass('iui-with-message');
getByText('some label');
const message = container.querySelector(
'.iui-message > .my-message',
) as HTMLElement;
expect(message).toBeTruthy();
expect(message.textContent).toBe('Message');
});

it.each(['positive', 'negative', 'warning'] as const)(
'should render %s component',
(status) => {
const { container, getByText } = render(
<LabeledInput label='some label' status={status} />,
);
const inputContainer = assertBaseElement(container);
expect(inputContainer).toHaveClass(`iui-${status}`);
getByText('some label');
expect(container.querySelector('.iui-input-icon')).toBeTruthy();
},
);

it('should set focus', () => {
let element: HTMLInputElement | null = null;
const onRef = (ref: HTMLInputElement) => {
element = ref;
};
const { container, getByText } = render(
<LabeledInput label='some label' ref={onRef} setFocus />,
);
assertBaseElement(container);
getByText('some label');
expect(element).toBeTruthy();
expect(document.activeElement).toEqual(element);
});

it('should take class and style on container', () => {
const { container, getByText } = render(
<LabeledInput
label='some label'
className='my-class'
style={{ width: 80 }}
/>,
);
assertBaseElement(container);
getByText('some label');
const inputContainer = container.querySelector(
'.iui-input-container.my-class',
) as HTMLElement;
expect(inputContainer).toBeTruthy();
expect(inputContainer.style.width).toBe('80px');
});

it('should take class and style on input', () => {
const { container, getByText } = render(
<LabeledInput
label='some label'
inputClassName='my-class'
inputStyle={{ width: 80 }}
/>,
);
assertBaseElement(container);
getByText('some label');
const input = container.querySelector('.iui-input.my-class') as HTMLElement;
expect(input).toBeTruthy();
expect(input.style.width).toBe('80px');
});

it('should render inline input', () => {
const { container, getByText, queryByText } = render(
<LabeledInput
label='some label'
displayStyle='inline'
message='My message'
status='positive'
/>,
);
const inputContainer = assertBaseElement(container);
expect(inputContainer).toHaveClass('iui-inline-label', 'iui-inline-icon');
getByText('some label');
expect(queryByText('My message')).toBeNull();
expect(container.querySelector('.iui-input-icon')).toBeTruthy();
});

it('should take custom icon', () => {
const { container, getByText } = render(
<LabeledInput
label='some label'
displayStyle='inline'
svgIcon={<svg className='my-icon' />}
/>,
);
assertBaseElement(container);
getByText('some label');
expect(
container.querySelector('.iui-input-container.iui-inline-label'),
).toBeTruthy();
expect(container.querySelector('.iui-input-icon .my-icon')).toBeTruthy();
});

it('should render inline icon', () => {
const { container, queryByText } = render(
<LabeledInput
label='some label'
iconDisplayStyle='inline'
svgIcon={<svg className='my-icon' />}
message='My message'
/>,
);
const inputContainer = assertBaseElement(container);
expect(inputContainer).toHaveClass('iui-inline-icon', 'iui-with-message');
expect(inputContainer).not.toHaveClass('iui-inline-label');
expect(queryByText('some label')).toHaveClass('iui-label');
expect(queryByText('My message')).toHaveClass('iui-message');
expect(container.querySelector('.iui-input-icon .my-icon')).toBeTruthy();
});