Skip to content

Commit 60c3a44

Browse files
feat: fluid state for search (#3007)
Co-authored-by: Akshat Patel <[email protected]>
1 parent 1ffde64 commit 60c3a44

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

src/search/search.component.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,28 @@
55
'cds--search--md': size === 'md',
66
'cds--search--lg': size === 'lg',
77
'cds--search--light': theme === 'light',
8-
'cds--skeleton': skeleton,
8+
'cds--skeleton': skeleton && !fluid,
99
'cds--search--expandable': expandable && !tableSearch,
1010
'cds--search--expanded': expandable && !tableSearch && active,
1111
'cds--toolbar-search': toolbar && !expandable,
1212
'cds--toolbar-search--active': toolbar && !expandable && active,
1313
'cds--toolbar-search-container-persistent': tableSearch && !expandable,
1414
'cds--toolbar-search-container-expandable': tableSearch && expandable,
15-
'cds--toolbar-search-container-active': tableSearch && expandable && active
15+
'cds--toolbar-search-container-active': tableSearch && expandable && active,
16+
'cds--search--fluid': fluid,
17+
'cds--search--disabled': disabled
1618
}"
1719
role="search"
1820
[attr.aria-label]="ariaLabel"
1921
(click)="openSearch()">
20-
<label class="cds--label" [for]="id">{{label}}</label>
22+
<label
23+
class="cds--label"
24+
[for]="id"
25+
[ngClass]="{ 'cds--skeleton': skeleton && fluid }">
26+
{{ !skeleton ? label : ''}}
27+
</label>
2128

22-
<div *ngIf="skeleton; else enableInput" class="cds--search-input"></div>
29+
<div *ngIf="skeleton; else enableInput" class="cds--text-input cds--skeleton"></div>
2330
<ng-template #enableInput>
2431
<input
2532
#input

src/search/search.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export class Search implements ControlValueAccessor {
4141
return !(this.toolbar || this.expandable);
4242
}
4343

44+
@HostBinding("class.cds--text-input--fluid__skeleton") get fluidSkeletonClass() {
45+
return this.skeleton && this.fluid;
46+
}
47+
4448
/**
4549
* @deprecated since v5 - Use `cdsLayer` directive instead
4650
* `light` or `dark` search theme.
@@ -118,6 +122,10 @@ export class Search implements ControlValueAccessor {
118122
* Sets the aria label on the `div` element with the `search` role.
119123
*/
120124
@Input() ariaLabel: string;
125+
/**
126+
* Experimental: enable fluid state
127+
*/
128+
@Input() fluid = false;
121129
/**
122130
* Emits an event when value is changed.
123131
*/

src/search/search.stories.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export default {
1717
skeleton: false,
1818
size: "md",
1919
theme: "dark",
20-
autocomplete: "on"
20+
autocomplete: "on",
21+
fluid: false
2122
},
2223
argTypes: {
2324
expandable: {
@@ -57,8 +58,15 @@ const Template = (args) => ({
5758
[size]="size"
5859
(valueChange)="valueChange($event)"
5960
(clear)="clear()"
61+
[fluid]="fluid"
62+
[skeleton]="skeleton"
6063
[expandable]="expandable">
6164
</cds-search>
6265
`
6366
});
6467
export const Basic = Template.bind({});
68+
69+
export const Fluid = Template.bind({});
70+
Fluid.args = {
71+
fluid: true
72+
};

0 commit comments

Comments
 (0)