|
1 | | -@use "searchbar.common"; |
2 | 1 | @use "../../themes/ionic/ionic.globals.scss" as globals; |
| 2 | +@use "searchbar.common"; |
3 | 3 |
|
4 | 4 | // Ionic Searchbar |
5 | 5 | // -------------------------------------------------- |
6 | 6 |
|
7 | 7 | :host { |
| 8 | + /** |
| 9 | + * @prop --focus-ring-color: The color of the ring around the focused element. |
| 10 | + * @prop --focus-ring-width: The width of the ring around the focused element. |
| 11 | + */ |
8 | 12 | --background: #{globals.$ionic-color-neutral-100}; |
9 | | - --border-radius: #{globals.$ionic-border-radius-800}; |
| 13 | + --border-radius: #{globals.$ionic-border-radius-400}; |
10 | 14 | --box-shadow: none; |
11 | 15 | --cancel-button-color: #{globals.$ionic-color-neutral-800}; |
12 | | - --clear-button-color: #{globals.$ionic-color-neutral-800}; |
13 | | - --color: #{globals.$ionic-color-neutral-800}; |
| 16 | + --clear-button-color: #{globals.$ionic-color-neutral-1000}; |
| 17 | + --color: #{globals.$ionic-color-neutral-1200}; |
14 | 18 | --icon-color: #{globals.$ionic-color-neutral-800}; |
| 19 | + --placeholder-color: #{globals.$ionic-color-neutral-800}; |
| 20 | + --focus-ring-color: #{globals.$ionic-state-focus-1}; |
| 21 | + --focus-ring-width: #{globals.$ionic-border-size-050}; |
15 | 22 |
|
| 23 | + @include globals.typography(globals.$ionic-body-md-regular); |
16 | 24 | @include globals.padding(0); |
17 | | - |
18 | | - min-height: globals.$ionic-scale-1000; |
19 | | - |
20 | | - contain: content; |
21 | | -} |
22 | | - |
23 | | -.searchbar-input-container { |
24 | | - min-height: globals.$ionic-scale-1000; |
25 | 25 | } |
26 | 26 |
|
27 | 27 | // Searchbar Search Icon |
28 | 28 | // ----------------------------------------- |
29 | 29 |
|
30 | 30 | .searchbar-search-icon { |
31 | | - display: none; |
| 31 | + // Position is based on the size of the search icon. |
| 32 | + @include globals.position(globals.$ionic-scale-400, null, null, globals.$ionic-scale-400); |
| 33 | + |
| 34 | + width: globals.$ionic-scale-400; |
| 35 | + height: globals.$ionic-scale-400; |
32 | 36 | } |
33 | 37 |
|
34 | 38 | // Searchbar Input Field |
35 | 39 | // ----------------------------------------- |
36 | 40 |
|
37 | 41 | .searchbar-input { |
38 | | - @include globals.padding(globals.$ionic-space-300); |
39 | | - |
40 | | - height: 100%; |
41 | | - |
42 | | - font-size: globals.$ionic-font-size-350; |
43 | | - font-weight: globals.$ionic-font-weight-regular; |
| 42 | + /** |
| 43 | + * Padding start is based on |
| 44 | + * desired padding from design, |
| 45 | + * the size of the search icon, |
| 46 | + * and the gap between the icon and the input. |
| 47 | + * |
| 48 | + * Padding end is based on |
| 49 | + * desired padding from design, |
| 50 | + * the size of the clear icon, |
| 51 | + * and the gap between the icon and the input. |
| 52 | + */ |
| 53 | + @include globals.padding( |
| 54 | + globals.$ionic-space-300, |
| 55 | + calc(globals.$ionic-space-400 + globals.$ionic-scale-400 + globals.$ionic-space-200), |
| 56 | + globals.$ionic-space-300, |
| 57 | + calc(globals.$ionic-space-400 + globals.$ionic-scale-400 + globals.$ionic-space-200) |
| 58 | + ); |
| 59 | + |
| 60 | + min-height: globals.$ionic-scale-1200; |
44 | 61 |
|
45 | 62 | contain: strict; |
46 | 63 | } |
|
49 | 66 | // ----------------------------------------- |
50 | 67 |
|
51 | 68 | .searchbar-clear-button { |
52 | | - @include globals.position(50%, globals.$ionic-space-200, null, null); |
| 69 | + // Position is based on the size of the clear icon. |
| 70 | + @include globals.position(globals.$ionic-scale-400, globals.$ionic-scale-400, null, null); |
53 | 71 |
|
54 | | - position: absolute; |
| 72 | + width: globals.$ionic-scale-400; |
| 73 | + height: globals.$ionic-scale-400; |
55 | 74 |
|
56 | | - width: globals.$ionic-scale-600; |
57 | | - height: globals.$ionic-scale-600; |
| 75 | + background-color: transparent; |
| 76 | + |
| 77 | + font-size: globals.$ionic-scale-400; |
| 78 | + |
| 79 | + contain: strict; |
| 80 | +} |
58 | 81 |
|
59 | | - transform: translateY(-50%); |
| 82 | +// Searchbar Cancel Icon |
| 83 | +// ----------------------------------------- |
| 84 | + |
| 85 | +.searchbar-cancel-button { |
| 86 | + /** |
| 87 | + * The left edge of the cancel button |
| 88 | + * should align with the left edge |
| 89 | + * of the back button if the searchbar |
| 90 | + * is used in a toolbar. |
| 91 | + */ |
| 92 | + @include globals.position(0, null, null, 9px); |
60 | 93 |
|
61 | 94 | background-color: transparent; |
62 | 95 |
|
63 | 96 | font-size: globals.$ionic-font-size-400; |
| 97 | +} |
64 | 98 |
|
65 | | - contain: strict; |
| 99 | +// Searchbar Search & Clear Icon & Cancel Icon |
| 100 | +// ----------------------------------------- |
| 101 | + |
| 102 | +.searchbar-search-icon, |
| 103 | +.searchbar-clear-button, |
| 104 | +.searchbar-cancel-button { |
| 105 | + position: absolute; |
| 106 | +} |
| 107 | + |
| 108 | +// Clear Icon & Cancel Icon |
| 109 | +// ----------------------------------------- |
| 110 | + |
| 111 | +.searchbar-clear-button:focus-visible, |
| 112 | +.searchbar-cancel-button:focus-visible ion-icon { |
| 113 | + @include globals.border-radius(globals.$ionic-border-radius-100); |
| 114 | + |
| 115 | + outline: globals.$ionic-border-size-050 globals.$ionic-border-style-solid globals.$ionic-state-focus-1; |
| 116 | + |
| 117 | + opacity: 1; |
66 | 118 | } |
67 | 119 |
|
68 | 120 | // Searchbar in Toolbar |
69 | 121 | // ----------------------------------------- |
70 | 122 |
|
71 | 123 | :host-context(ion-toolbar) { |
72 | | - min-height: globals.$ionic-scale-1000; |
| 124 | + min-height: globals.$ionic-scale-1200; |
| 125 | +} |
| 126 | + |
| 127 | +// Searchbar States |
| 128 | +// -------------------------------------------------- |
| 129 | + |
| 130 | +/* Hover */ |
| 131 | +:host(:hover) { |
| 132 | + --background: #{globals.$ionic-color-neutral-200}; |
| 133 | +} |
| 134 | + |
| 135 | +/* Focus */ |
| 136 | +:host(.searchbar-has-focus) .searchbar-input { |
| 137 | + outline: var(--focus-ring-width) globals.$ionic-border-style-solid var(--focus-ring-color); |
| 138 | +} |
| 139 | + |
| 140 | +:host(.searchbar-has-focus) .searchbar-search-icon, |
| 141 | +:host(.searchbar-has-focus) .searchbar-cancel-button, |
| 142 | +:host(.searchbar-should-show-cancel) .searchbar-cancel-button { |
| 143 | + display: block; |
| 144 | +} |
| 145 | + |
| 146 | +:host(.searchbar-has-focus) .searchbar-cancel-button + .searchbar-search-icon, |
| 147 | +:host(.searchbar-should-show-cancel) .searchbar-cancel-button + .searchbar-search-icon { |
| 148 | + display: none; |
| 149 | +} |
| 150 | + |
| 151 | +/* Disabled */ |
| 152 | +:host(.searchbar-disabled) { |
| 153 | + --color: #{globals.$ionic-color-neutral-500}; |
| 154 | + --icon-color: #{globals.$ionic-color-neutral-500}; |
| 155 | + --placeholder-color: #{globals.$ionic-color-neutral-500}; |
| 156 | + |
| 157 | + cursor: default; |
| 158 | + pointer-events: none; |
73 | 159 | } |
0 commit comments