Skip to content

Commit

Permalink
release v0.5.2 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
necessarylion authored Mar 28, 2023
1 parent e8846db commit b3035ab
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 28 deletions.
70 changes: 43 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ Compatible with
- Vue
- Angular

### Contents

- [Installation](#installation)
- [Via cdn](#install-via-cdn)
- [Via npm](#install-via-npm)
- [Usage](#usage)
- [Javascript](#javascript)
- [Typescript](#typescript)
- [Usage with API](#usage-with-api-call)
- [Options](#available-options)
- [Functions](#available-functions)
- [Theme](#theme)
- [Custom Theme](#custom-theme-color)

### Installation

#### Install via cdn

```html
Expand Down Expand Up @@ -95,6 +111,33 @@ const searchJs = SearchJS(config)
searchJs.open()
```

#### Usage with API call

```js
async function getFromApi(keyword = '') {
let res = await fetch('https://dummyjson.com/products/search?q=' + keyword)
let json = await res.json()
return json.products
}

const searchJs = SearchJS({
theme: '#FF2E1F',
width: '600px',
darkMode: false,
positionTop: '50px',
data: [],
search: {
placeholder: 'Search products',
},
onSelected: (route) => {
console.log(route)
},
onSearch: (keyword) => {
return getFromApi(keyword)
},
})
```

#### Available Options

| **Name** | **Required** | **Description** |
Expand Down Expand Up @@ -138,33 +181,6 @@ searchJs.open()
##### Dark Theme with color code
<img width="350" src="https://raw.githubusercontent.com/necessarylion/search-js/main/demo/light-theme.png" />

#### Sample code with API call

```js
async function getFromApi(keyword = '') {
let res = await fetch('https://dummyjson.com/products/search?q=' + keyword)
let json = await res.json()
return json.products
}

const searchJs = SearchJS({
theme: '#FF2E1F',
width: '600px',
darkMode: false,
positionTop: '50px',
data: [],
search: {
placeholder: 'Search products',
},
onSelected: (route) => {
console.log(route)
},
onSearch: (keyword) => {
return getFromApi(keyword)
},
})
```

#### Custom theme color

Override below css variables for custom theme color.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bilions/search-js",
"version": "0.5.1",
"version": "0.5.2",
"description": "Instance search UI component",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit b3035ab

Please sign in to comment.