Skip to content

Commit

Permalink
Support types for typescript (#2)
Browse files Browse the repository at this point in the history
* enable types for typescript

* added build workflow

* fixed build workflow

* move css to assets folder
  • Loading branch information
necessarylion authored Mar 26, 2023
1 parent 995b2e0 commit 1f8a050
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 310 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build

on:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install
- name: Compile and build
run: npm run build
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
run: npm install
- name: Compile and build
run: npm run build
- name: Compile and build for cdn
run: npm run build:cdn
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
5 changes: 1 addition & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
src
dist/index.html
!dist/search-js.js
!dist/index.js
!dist/types/index.ts
!dist
index.html
webpack.config.js
webpack.cdn.config.js
Expand Down
50 changes: 45 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Search JS

![build status](https://github.com/necessarylion/search-js/actions/workflows/release.yml/badge.svg) [![npm version](https://badge.fury.io/js/@bilions%2Fsearch-js.svg)](https://badge.fury.io/js/@bilions%2Fsearch-js) [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
![build status](https://github.com/necessarylion/search-js/actions/workflows/build.yml/badge.svg) [![npm version](https://badge.fury.io/js/@bilions%2Fsearch-js.svg)](https://badge.fury.io/js/@bilions%2Fsearch-js) [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)

Instance search UI component for any Javascript framework.

Expand All @@ -11,16 +11,20 @@ Compatible with

<img width="350" src="https://raw.githubusercontent.com/necessarylion/search-js/main/demo/demo1.png" />

#### Usage via cdn
#### Install via cdn

```html
<script src="https://cdn.jsdelivr.net/npm/@bilions/search-js/dist/search-js.js"></script>
```

#### Usage via npm
#### Install via npm

`npm install @bilions/search-js`

#### Usage

###### Javascript

```js
import SearchJS from '@bilions/search-js'

Expand Down Expand Up @@ -53,6 +57,41 @@ const searchJs = SearchJS({
searchJs.open()
```

###### Typescript

```ts

import SearchJS, { SearchJSConfig, SearchJSItem } from '@bilions/search-js'

const config : SearchJSConfig = {
data: [
{
title: 'Validation',
description: 'Create validation easily using validator',
route: '/validation',
},
{
title: 'Request',
description: 'Http request',
route: '/request',
},
],
theme: '#FF2E1F',
width: '600px',
positionTop: '85px',
search: {
placeholder: 'Search docs'
},
onSelected: (value : SearchJSItem) => {
console.log(value)
}
}

const searchJs = SearchJS(config)
searchJs.open()

```

#### Available Options

| **Name** | **Required** | **Description** |
Expand All @@ -71,8 +110,9 @@ searchJs.open()

#### Available functions

- `open()` open function will trigger to open search menu
- Alternatively press `cmd + k` or `ctrl + k` to open search menu
- `open()` function will trigger to open search menu
- `close()` function will trigger to close search menu
- Alternatively press `cmd + k` or `ctrl + k` to open search menu and `ESC` to close menu

#### Custom theme color

Expand Down
Loading

0 comments on commit 1f8a050

Please sign in to comment.