diff --git a/README.md b/README.md index 8610c63..467d62f 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,10 @@ searchJs.open() async function getFromApi(keyword = '') { let res = await fetch('https://dummyjson.com/products/search?q=' + keyword) let json = await res.json() - return json.products + return json.products.map((p) => { + p.icon = `` + return p + }) } const searchJs = SearchJS({ @@ -145,6 +148,7 @@ const searchJs = SearchJS({ | `data` | YES | data to search | | `data.title` | YES | data title | | `data.description` | NO | data description | +| `data.icon` | NO | data icon (can use html string, svg string etc...) | | `element` | NO | element to append search-js | | `theme` | NO | color code or theme name (`#FF2E1F`, `github-light`, `github-dark`) | | `darkMode` | NO | default `false`. set `true` for dark mode | diff --git a/index.html b/index.html index 2a1c5fe..cddbd8c 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,13 @@ font-family: 'Source Sans Pro', sans-serif; background-color: #424243; } + .product-image { + width: 50px; + height: 50px; + object-fit: contain; + background: #ededed; + border-radius: 5px; + }
@@ -21,7 +28,10 @@ async function getFromApi(keyword = '') { let res = await fetch('https://dummyjson.com/products/search?q='+keyword) let json = await res.json() - return json.products + return json.products.map((p) => { + p.icon = `` + return p + }) } const searchJs = SearchJS({ diff --git a/src/components/Item.ts b/src/components/Item.ts index 41e18b3..49fba71 100644 --- a/src/components/Item.ts +++ b/src/components/Item.ts @@ -55,7 +55,7 @@ export class Item { render({ item, icon, hideRemoveButton = false }: ItemComponentPayload): string { const dataPayload = Encoder.encode(item) return `