You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An Angular module that exports a component that can enable users to search over configured models using the search microservice provided in the sourceloop microservice catalog.
4
4
5
-
### Deprecation Notice
6
-
7
-
Search-client now supports angular v14, we will provide support for the older version that is based on angular v13 till 30th June 2024.
5
+
### Angular Version Compatibility
6
+
7
+
To ensure smooth integration, install the Search Library version that corresponds to your Angular version:
@@ -16,33 +39,21 @@ npm i @sourceloop/search-client
16
39
17
40
### Usage
18
41
19
-
Create a new Application using Angular CLI and import the SearchLibModule and add it to the imports array of the module. 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
-
Your module will then look something like this
42
+
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 }
`Configuration to show only result overlay without search input box`
154
-
There are other parameters which you can configure to use only the search result overlay without search input box
155
-
156
-
```html
157
-
<sourceloop-search
158
-
[config]="config"
159
-
[(ngModel)]="value"
160
-
[showOnlySearchResultOverlay]="true"
161
-
[customAllLabel]="customAllLabel"
162
-
[customSearchEvent]="customSearchEvent"
163
-
></sourceloop-search>
164
-
````
165
-
166
-
You can pass `showOnlySearchResultOverlay` to true to use only search result overlay. You can also pass `customAllLabel` in case you have different model name configuration for performing search in All categories
167
-
168
-
**Manadatory parameter when you configure `showOnlySearchResultOverlay` to true**
169
-
You should pass `customSearchEvent`
170
-
171
-
```ts
172
-
interfaceCustomSearchEvent {
173
-
searchValue:string;
174
-
modelName:string;
175
-
}
176
-
```
177
-
178
162
### Icons
179
163
180
164
To use the default icons you will have to import the following in your styles.scss:
@@ -185,6 +169,45 @@ To use the default icons you will have to import the following in your styles.sc
185
169
186
170
You can also choose to use your own icons by providing classes for icons in the configuration.
187
171
172
+
### Required Global Styles
173
+
174
+
The search component uses Angular CDK overlays for the dropdown, which require global styles to function properly.
175
+
176
+
### Styling and Theming
177
+
178
+
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.
179
+
180
+
#### Available CSS Variables
181
+
182
+
````scss
183
+
sourceloop-search {
184
+
--search-background: #f7f7f7; /* Background of the search container */
185
+
--search-input-background: #f1f3f4; /* Background of the input field */
186
+
--search-input-text-color: #6b6b6b; /* Text color in the input field */
187
+
--search-border-hover: #a53159; /* Border color on hover */
188
+
--search-border-focus: #90003b; /* Border color when focused */
189
+
--search-dropdown-background: #90003b; /* Background of the category dropdown (on hover/focus) */
190
+
--search-dropdown-text-color: #ffffff; /* Text color in the category dropdown (on hover/focus) */
191
+
--search-highlight-bg: #fee8e8; /* Background color for highlighted suggestions */
192
+
--search-heading-color: #9c9c9c; /* Color of category headings */
193
+
--search-text-color: #333; /* General text color */
194
+
--search-icon-color: #33333380; /* Color of icons */
195
+
}
196
+
197
+
####Example: Custom Theming To customize the search component, add the following
198
+
to your `component.scss` ```scss
199
+
200
+
// Customize component colors
201
+
202
+
:host ::ng-deepsourceloop-search {
203
+
--search-border-hover: #5c26f1!important;
204
+
--search-border-focus: #5c26f1!important;
205
+
--search-dropdown-background: #5c26f2!important;
206
+
}
207
+
````
208
+
209
+
This allows you to match the search component's appearance with your application's design system.
210
+
188
211
## Web Component
189
212
190
213
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.
@@ -218,44 +241,44 @@ The web component accepts all the same inputs and services as the regular Angula
This facilitates the use of the `Web Component` without relying on [rxjs](https://rxjs.dev/). You can still use the `Observable` based service if you want by importing the rxjs library manually.
304
+
This facilitates the use of the `Web Component` without relying on [rxjs](https://rxjs.dev/). You can still use the `Observable` based service if you want by importing the rxjs library manually.
0 commit comments