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

Allow borderless SearchBox.ExpandButton #2238

Merged
merged 20 commits into from
Sep 19, 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
20 changes: 20 additions & 0 deletions .changeset/stale-parents-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@itwin/itwinui-react': minor
---

Passing `styleType="borderless"` to `SearchBox.ExpandButton` now works as expected. This is because collapsed `SearchBox` will now hide its border and background in favor of the ones from `SearchBox.ExpandButton`.

<details>
<summary>Example</summary>

```diff
<SearchBox expandable>
<SearchBox.CollapsedState>
- <SearchBox.ExpandButton/>
+ <SearchBox.ExpandButton styleType="borderless"/>
</SearchBox.CollapsedState>
<SearchBox.ExpandedState>…</SearchBox.ExpandedState>
</SearchBox>
```

</details>
5 changes: 5 additions & 0 deletions .changeset/three-pillows-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-css': minor
---

Collapsed `.iui-expandable-searchbox` will now hide its border and background in favor of the ones from the expand button.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions apps/react-workshop/src/SearchBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ export const Expandable = () => {
);
};

export const BorderlessExpandButton = () => {
return (
<SearchBox expandable>
<SearchBox.CollapsedState>
<SearchBox.ExpandButton styleType='borderless' />
</SearchBox.CollapsedState>
<SearchBox.ExpandedState>
<SearchBox.Icon />
<SearchBox.Input placeholder='Expandable search with borderless ExpandButton' />
<SearchBox.CollapseButton />
</SearchBox.ExpandedState>
</SearchBox>
);
};

export const ExpandableWithCustomItems = () => {
return (
<SearchBox expandable>
Expand Down
1 change: 1 addition & 0 deletions apps/react-workshop/src/SearchBox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('SearchBox', () => {
'Basic With Status',
'Basic With Custom Items',
'Expandable',
'Borderless Expand Button',
'Expandable With Custom Items',
'With Custom Action',
'Small',
Expand Down
8 changes: 8 additions & 0 deletions apps/website/src/content/docs/searchbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ Expandable SearchBox can be customized by using `ExpandedState` and `CollapsedSt
<AllExamples.SearchBoxCustomExample client:load />
</LiveExample>

### Borderless ExpandButton

Useful for having a borderless `ExpandButton` [subcomponent](#subcomponents) similar to a borderless [`IconButton`](button#iconbutton).

<LiveExample src='SearchBox.borderlessexpandbutton.jsx'>
<AllExamples.SearchBoxBorderlessExpandButtonExample client:load />
</LiveExample>

### Size

SearchBox can be changed to have small or large size. By default it's "medium".
Expand Down
6 changes: 6 additions & 0 deletions examples/SearchBox.borderlessexpandbutton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.demo-container {
width: 70%;
display: flex;
justify-content: center;
gap: var(--iui-size-xs);
}
23 changes: 23 additions & 0 deletions examples/SearchBox.borderlessexpandbutton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { SearchBox } from '@itwin/itwinui-react';

export default () => {
return (
<div className='demo-container'>
<SearchBox expandable>
<SearchBox.CollapsedState>
<SearchBox.ExpandButton styleType='borderless' />
</SearchBox.CollapsedState>
<SearchBox.ExpandedState>
<SearchBox.Icon />
<SearchBox.Input placeholder='Expandable search with borderless SearchBox.CollapsedState' />
<SearchBox.CollapseButton />
</SearchBox.ExpandedState>
</SearchBox>
</div>
);
};
1 change: 0 additions & 1 deletion examples/SearchBox.custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
width: 70%;
display: flex;
justify-content: center;
flex-direction: column;
gap: var(--iui-size-xs);
}
6 changes: 6 additions & 0 deletions examples/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,12 @@ import { default as SearchBoxSizeExampleRaw } from './SearchBox.size';
const SearchBoxSizeExample = withThemeProvider(SearchBoxSizeExampleRaw);
export { SearchBoxSizeExample };

import { default as SearchBoxBorderlessExpandButtonExampleRaw } from './SearchBox.borderlessexpandbutton.jsx';
const SearchBoxBorderlessExpandButtonExample = withThemeProvider(
SearchBoxBorderlessExpandButtonExampleRaw,
);
export { SearchBoxBorderlessExpandButtonExample };

import { default as SearchBoxExpandableExampleRaw } from './SearchBox.expandable';
const SearchBoxExpandableExample = withThemeProvider(
SearchBoxExpandableExampleRaw,
Expand Down
10 changes: 9 additions & 1 deletion packages/itwinui-css/src/searchbox/searchbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
inline-size: fit-content;
padding-inline: 0; // To remove 1px padding from input-flex-container

// Expanded
&:where([data-iui-expanded='true']) {
inline-size: 100%;
border-color: var(--_iui-input-border-color);
}

&:not([data-iui-expanded='true']) {
background-color: transparent;

&::before {
transition: none;
border: none;
}
}
}

// noop https://github.com/iTwin/iTwinUI/pull/1881#discussion_r1506166537
Expand Down
Loading