Skip to content

Commit 1ab7066

Browse files
antoinecfmwsliamdebeasi
authored andcommitted
feat(searchbar): add --box-shadow variable to style searchbar input (#19838)
* Updates searchbar.md.scss to expose box-shadow We would like to style the box-shadow property in searchbar and give the parent the ability to control it. * fix(searchbar): add box shadow to main input for both modes
1 parent 48a7662 commit 1ab7066

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

core/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ ion-searchbar,event,ionClear,void,true
965965
ion-searchbar,event,ionFocus,void,true
966966
ion-searchbar,event,ionInput,KeyboardEvent,true
967967
ion-searchbar,css-prop,--background
968+
ion-searchbar,css-prop,--box-shadow
968969
ion-searchbar,css-prop,--cancel-button-color
969970
ion-searchbar,css-prop,--clear-button-color
970971
ion-searchbar,css-prop,--color

core/src/components/searchbar/readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ Type: `Promise<void>`
280280

281281
| Name | Description |
282282
| --------------------------- | ---------------------------------------- |
283-
| `--background` | Background of the searchbar |
283+
| `--background` | Background of the searchbar input |
284+
| `--box-shadow` | Box shadow of the searchbar input |
284285
| `--cancel-button-color` | Color of the searchbar cancel button |
285286
| `--clear-button-color` | Color of the searchbar clear button |
286287
| `--color` | Color of the searchbar text |

core/src/components/searchbar/searchbar.ios.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
// --------------------------------------------------
66

77
:host {
8-
--clear-button-color: #{$searchbar-ios-input-clear-icon-color};
8+
--background: #{$searchbar-ios-input-background-color};
9+
--box-shadow: none;
910
--cancel-button-color: #{$searchbar-ios-cancel-button-color};
11+
--clear-button-color: #{$searchbar-ios-input-clear-icon-color};
1012
--color: #{$searchbar-ios-input-text-color};
1113
--icon-color: #{$searchbar-ios-input-search-icon-color};
12-
--background: #{$searchbar-ios-input-background-color};
1314

1415
@include padding($searchbar-ios-padding-top, $searchbar-ios-padding-end, $searchbar-ios-padding-bottom, $searchbar-ios-padding-start);
1516

@@ -20,8 +21,6 @@
2021

2122
.searchbar-input-container {
2223
height: $searchbar-ios-input-height;
23-
24-
contain: strict;
2524
}
2625

2726

core/src/components/searchbar/searchbar.md.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
// --------------------------------------------------
66

77
:host {
8-
--clear-button-color: initial;
8+
--background: #{$searchbar-md-input-background-color};
9+
--box-shadow: #{$searchbar-md-input-box-shadow};
910
--cancel-button-color: #{$searchbar-md-cancel-button-color};
11+
--clear-button-color: initial;
1012
--color: #{$searchbar-md-input-text-color};
1113
--icon-color: #{$searchbar-md-input-search-icon-color};
12-
--background: #{$searchbar-md-input-background-color};
1314

1415
@include padding($searchbar-md-padding-top, $searchbar-md-padding-end, $searchbar-md-padding-bottom, $searchbar-md-padding-start);
1516

@@ -67,8 +68,6 @@
6768
font-weight: 400;
6869

6970
line-height: $searchbar-md-input-line-height;
70-
71-
box-shadow: $searchbar-md-input-box-shadow;
7271
}
7372

7473

core/src/components/searchbar/searchbar.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
:host {
77
/**
8-
* @prop --background: Background of the searchbar
8+
* @prop --background: Background of the searchbar input
9+
* @prop --box-shadow: Box shadow of the searchbar input
910
* @prop --cancel-button-color: Color of the searchbar cancel button
1011
* @prop --clear-button-color: Color of the searchbar clear button
1112
* @prop --color: Color of the searchbar text
@@ -68,8 +69,6 @@
6869
.searchbar-input {
6970
@include text-inherit();
7071

71-
box-sizing: border-box;
72-
7372
display: block;
7473

7574
width: 100%;
@@ -81,6 +80,10 @@
8180
background: var(--background);
8281

8382
font-family: inherit;
83+
84+
box-shadow: var(--box-shadow);
85+
86+
box-sizing: border-box;
8487
appearance: none;
8588

8689
&::placeholder {

core/src/components/searchbar/test/basic/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h5 class="ion-padding-start ion-padding-top"> Search - Default </h5>
2626
</ion-searchbar>
2727

2828
<h5 class="ion-padding-start ion-padding-top"> Search - No Cancel Button </h5>
29-
<ion-searchbar id="noCancel" value="after view" autocorrect="off" autocomplete="off" spellcheck="true" type="text" show-cancel-button="never">
29+
<ion-searchbar class="red-box" id="noCancel" value="after view" autocorrect="off" autocomplete="off" spellcheck="true" type="text" show-cancel-button="never">
3030
</ion-searchbar>
3131

3232
<h5 class="ion-padding-start ion-padding-top"> Search - Always Show Cancel Button</h5>
@@ -118,6 +118,12 @@ <h5 class="ion-padding-start ion-padding-top"> Search - Animated and No Cancel</
118118
<ion-button expand="block" color="secondary" onClick="toggleDisabled()">Toggle disabled</ion-button>
119119
</div>
120120

121+
<style>
122+
.red-box {
123+
--box-shadow: 0 2px 2px 0 rgba(255, 0, 0, 0.14), 0 3px 1px -2px rgba(255, 0, 0, 0.2), 0 1px 5px 0 rgba(255, 0, 0, 0.12);
124+
}
125+
</style>
126+
121127
<script>
122128
function toggleAttr() {
123129
var dynamicAttr = document.getElementById('dynamicAttr');

0 commit comments

Comments
 (0)