-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from sidneywm/dev
Merge Dev into Master v0.3.0
- Loading branch information
Showing
19 changed files
with
805 additions
and
5,362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"liveServer.settings.port": 5533 | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,166 @@ | ||
# Iconic Multiselect | ||
|
||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/github/package-json/v/sidneywm/iconic-multiselect)](https://github.com/sidneywm/iconic-multiselect) | ||
|
||
<p align="center">A multiselect component written in pure JavaScript - Also compatible with IE11</p> | ||
|
||
<p align="center"> | ||
<img src="./assets/iconic-multiselect-screenshot.png"> | ||
<img src="./assets/iconic-multiselect.png"> | ||
</p> | ||
|
||
## Getting Started | ||
|
||
### 1. Link the required files | ||
|
||
Firstly, the script needs to be included in your HTML file. If you would like to personalize the Iconic Multiselect component, you can additionally include a CSS stylesheet with your custom CSS properties which target the Iconic Multiselect component classes. Also, do not forget to set `customCss` to `true`. ([see configuration](#configuration)) | ||
|
||
```html | ||
<head> | ||
|
||
// Optional | ||
<link rel="stylesheet" href="multi-select.css" type="text/css" /> | ||
|
||
</head> | ||
|
||
<script src="multi-select.js" type="text/javascript"></script> | ||
``` | ||
|
||
If you intend to use the Iconic Multiselect component with Internet Explorer 11, it is recommended to use the script with the polyfills included. | ||
|
||
```html | ||
<script src="multi-select-ie11-polyfills.js" type="text/javascript"></script> | ||
``` | ||
|
||
### 2. Create a select tag | ||
|
||
Secondly, within your HTML file, create a `<select>` tag which you want to turn into a multiselect. Do not forget to set an `id` on your `<select>` tag. | ||
|
||
```html | ||
<select id="foods"> | ||
<option value="bread">Bread</option> | ||
<option value="cereal">Cereal</option> | ||
<option value="pasta">Pasta</option> | ||
<option value="rice">Rice</option> | ||
<option value="meat">Meat</option> | ||
<option value="fish">Fish</option> | ||
</select> | ||
``` | ||
|
||
### 3. Initialize the Iconic Multiselect component | ||
|
||
Finally, target the `id` of your `<select>` tag in the options and initialize the component with the `.init()` method. You may also specify further options. ([see configuration](#configuration)) | ||
|
||
```html | ||
<script type="text/javascript"> | ||
const multiSelect = new IconicMultiSelect({ | ||
select: "#foods", | ||
}); | ||
multiSelect.init(); | ||
</script> | ||
``` | ||
## Configuration | ||
|
||
### 1. Overview | ||
|
||
| Option | Default | Type | | ||
| :--- | :---: | :---: | | ||
| customCss | `false` | `boolean` | | ||
| data | `[]` | `Object[]` | | ||
| noData | `No data found.` | `string` | | ||
| noResults | `No results found.` | `string` | | ||
| placeholder | `Select...` | `string` | | ||
| select* | `none` | `string` | | ||
| textField | `null` | `string` | | ||
| valueField | `null` | `string` | | ||
|
||
\* This option is compulsory | ||
|
||
#### `customCss` | ||
If set to `true`, the component will not inject its own CSS in the `<head>` tag. | ||
|
||
#### `data*` | ||
The component can be configured with data set in the configuration fields. It must be an `Array` of `Objects`. | ||
|
||
#### `noData` | ||
Text to display if there is no data found in the `<select>` tag or in the data field. | ||
|
||
#### `noResults` | ||
Text to display if there is no results when the option list is filtered. | ||
|
||
#### `placeholder` | ||
Text to display in the input placeholder. | ||
|
||
#### `select` | ||
The `<select>` tag from which the component is initialized. | ||
|
||
#### `textField` | ||
The field of the data object that provides the text content. | ||
|
||
#### `valueField` | ||
The field of the data object that provides the value. | ||
|
||
\* **IMPORTANT:** When `data` is provided, `valueField` and `textField` should also be set. | ||
|
||
### 2. Example | ||
|
||
```html | ||
<script type="text/javascript"> | ||
const multiSelect = new IconicMultiSelect({ | ||
customCss: true, | ||
data: [ | ||
{ valueName: "bread", itemName: 'Bread'}, | ||
{ valueName: "rice", itemName: 'Rice'}, | ||
{ valueName: "pasta", itemName: 'Pasta'} | ||
], | ||
noData: "No food item found.", | ||
noResults: "No results found in this list.", | ||
placeholder: "Select a food item...", | ||
select: "#foods", | ||
textField: 'itemName', | ||
valueField: 'valueName', | ||
}); | ||
</script> | ||
``` | ||
|
||
## Methods | ||
|
||
#### `.init()` | ||
Initialize the component with all its settings. | ||
|
||
#### `.subscribe()` | ||
Listen for all events. | ||
|
||
Example: | ||
|
||
```javascript | ||
JavaScript: | ||
|
||
multiSelect.subscribe(function(event) { | ||
console.log(event); | ||
}); | ||
|
||
``` | ||
|
||
```console | ||
Console: | ||
|
||
Object : { action: "ADD_OPTION", value: "pasta", selection: (1) [...] } | ||
``` | ||
|
||
|
||
## Contributing | ||
|
||
Iconic Multiselect is an open-source project. Contributions of any kind are welcome and appreciated. Feel free to open an issue or request a feature. Pull requests are also welcome. | ||
|
||
## Author | ||
|
||
- [Sidney Wimart](https://github.com/sidneywm) | ||
|
||
## License | ||
|
||
This project is open source and available under the [MIT License](LICENSE). | ||
This project is open source and available under the [MIT License](LICENSE). |
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.