@sourceloop/search-element 9.0.1 → 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -5
- package/package.json +3 -3
- package/search-element.js +2 -2
package/README.md
CHANGED
|
@@ -19,16 +19,16 @@ npm i @sourceloop/search-client
|
|
|
19
19
|
Create a new Application using Angular CLI and import the `SearchComponent` in your application.SearchComponent is now a standalone component, so no NgModule is required.Also create a new service that implements the ISearchService interface exported by the search library. This service will be used by the exported component to make API calls whenever needed. You will have to update the providers section of your module with { provide: SEARCH_SERVICE_TOKEN, useExisting: Your_Service_Name }
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
22
|
+
import {Component} from '@angular/core';
|
|
23
|
+
import {SearchComponent, SEARCH_SERVICE_TOKEN} from '@sourceloop/search-client';
|
|
24
|
+
import {SearchService} from './search.service';
|
|
25
25
|
|
|
26
26
|
@Component({
|
|
27
27
|
selector: 'app-root',
|
|
28
28
|
standalone: true,
|
|
29
29
|
imports: [SearchComponent],
|
|
30
30
|
templateUrl: './app.component.html',
|
|
31
|
-
providers: [{
|
|
31
|
+
providers: [{provide: SEARCH_SERVICE_TOKEN, useClass: SearchService}],
|
|
32
32
|
})
|
|
33
33
|
export class AppComponent {}
|
|
34
34
|
```
|
|
@@ -74,7 +74,6 @@ Apart from these there are some optional properties that you can give:
|
|
|
74
74
|
- **noResultMessage (string) :** Message to display in dropdown incase no matching result found.
|
|
75
75
|
- **searchIconClass (string) :** Can be used to give custom icon for search in search bar.
|
|
76
76
|
- **crossIconClass (string) :** Can be used to give custom icon for clearing text input in search bar.
|
|
77
|
-
- **dropDownButtonIconClass (string) :** Can be used to give custom icon for category drop down button.
|
|
78
77
|
- **recentSearchIconClass (string) :** Can be used to give custom icon for recent searches displayed in the search dropdown.
|
|
79
78
|
|
|
80
79
|
Your component might look something like
|
|
@@ -147,6 +146,64 @@ To use the default icons you will have to import the following in your styles.sc
|
|
|
147
146
|
|
|
148
147
|
You can also choose to use your own icons by providing classes for icons in the configuration.
|
|
149
148
|
|
|
149
|
+
### Required Global Styles
|
|
150
|
+
|
|
151
|
+
The search component uses Angular CDK overlays for the dropdown, which require global styles to function properly. **You must import the library's stylesheet in your application:**
|
|
152
|
+
|
|
153
|
+
#### Option 1: Import in your `styles.scss`
|
|
154
|
+
|
|
155
|
+
```scss
|
|
156
|
+
@import '@sourceloop/search-client/styles';
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### Option 2: Add to `angular.json`
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
"styles": [
|
|
163
|
+
"node_modules/@sourceloop/search-client/styles.scss",
|
|
164
|
+
"src/styles.scss"
|
|
165
|
+
]
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Styling and Theming
|
|
169
|
+
|
|
170
|
+
The search component uses CSS custom properties (CSS variables) for theming, allowing you to customize colors without modifying the library code. You can override these variables in your application's global styles or in a component-specific stylesheet.
|
|
171
|
+
|
|
172
|
+
#### Available CSS Variables
|
|
173
|
+
|
|
174
|
+
````scss
|
|
175
|
+
sourceloop-search {
|
|
176
|
+
--search-background: #f7f7f7; /* Background of the search container */
|
|
177
|
+
--search-input-background: #f1f3f4; /* Background of the input field */
|
|
178
|
+
--search-input-text-color: #6b6b6b; /* Text color in the input field */
|
|
179
|
+
--search-border-hover: #a53159; /* Border color on hover */
|
|
180
|
+
--search-border-focus: #90003b; /* Border color when focused */
|
|
181
|
+
--search-dropdown-background: #90003b; /* Background of the category dropdown (on hover/focus) */
|
|
182
|
+
--search-dropdown-text-color: #ffffff; /* Text color in the category dropdown (on hover/focus) */
|
|
183
|
+
--search-highlight-bg: #fee8e8; /* Background color for highlighted suggestions */
|
|
184
|
+
--search-heading-color: #9c9c9c; /* Color of category headings */
|
|
185
|
+
--search-text-color: #333; /* General text color */
|
|
186
|
+
--search-icon-color: #33333380; /* Color of icons */
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
#### Example: Custom Theming
|
|
190
|
+
|
|
191
|
+
To customize the search component, add the following to your `styles.scss` (after importing the library styles):
|
|
192
|
+
|
|
193
|
+
```scss
|
|
194
|
+
@import '@sourceloop/search-client/styles';
|
|
195
|
+
|
|
196
|
+
// Customize component colors
|
|
197
|
+
sourceloop-search {
|
|
198
|
+
--search-dropdown-background: #0056b3;
|
|
199
|
+
--search-dropdown-text-color: #ffffff;
|
|
200
|
+
--search-border-hover: #0056b3;
|
|
201
|
+
--search-border-focus: #003d82;
|
|
202
|
+
}
|
|
203
|
+
````
|
|
204
|
+
|
|
205
|
+
This allows you to match the search component's appearance with your application's design system.
|
|
206
|
+
|
|
150
207
|
## Web Component
|
|
151
208
|
|
|
152
209
|
This library is also available as a [Web Component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) so users of frameworks like React and Vue can also integrate this search element in their application with minimal effort.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sourceloop/search-element",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.3",
|
|
4
4
|
"description": "A global search element for search microservice. ",
|
|
5
5
|
"main": "./search-element.js",
|
|
6
6
|
"private": false,
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
},
|
|
20
20
|
"author": "Sourcefuse",
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"hash": "
|
|
23
|
-
"gitHead": "
|
|
22
|
+
"hash": "aaf134d1e02bc76d8e7158110c231c475142d2c8f091f831e43bcca14942a1cb",
|
|
23
|
+
"gitHead": "83f068c4ac6a36c7b71a89543b75beb5f3a6a17d"
|
|
24
24
|
}
|