-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add a `darkMode` option, user can also change it at any time dynamically via `refreshOptions()`
- Loading branch information
1 parent
1f712f1
commit d0f20e2
Showing
12 changed files
with
353 additions
and
17 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
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,136 @@ | ||
<div class="example15-container"> | ||
<div class="row mb-2"> | ||
<div class="col-md-12 title-desc"> | ||
<h2 class="bd-title"> | ||
Dark Mode | ||
<span class="float-end links"> | ||
Code <span class="fa fa-link"></span> | ||
<span class="small"> | ||
<a | ||
target="_blank" | ||
href="https://github.com/ghiscoding/multiple-select-vanilla/blob/main/packages/demo/src/examples/example15.html" | ||
>html</a | ||
> | ||
| | ||
<a target="_blank" href="https://github.com/ghiscoding/multiple-select-vanilla/blob/main/packages/demo/src/examples/example15.ts" | ||
>ts</a | ||
> | ||
</span> | ||
</span> | ||
</h2> | ||
<div class="demo-subtitle"> | ||
Dark Mode requires <code>darkMode</code> option to be enabled, when that happens it will add <code>.ms-dark-mode</code> to the parent and drop elements. | ||
The dark theme is configured through CSS variables which you can also customize yourself. | ||
You can also toggle Dark Mode at any time dynamically via <code>refreshOptions()</code> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<div class="mb-3 row"> | ||
<label class="col-sm-2">Single Select</label> | ||
|
||
<div class="col-sm-10"> | ||
<select id="single" class="select full-width ms-dark-mode" data-test="single"> | ||
<option value="1">January</option> | ||
<option value="2">February</option> | ||
<option value="3">March</option> | ||
<option value="4">April</option> | ||
<option data-divider="true"></option> | ||
<option value="5">May</option> | ||
<option value="6">June</option> | ||
<option value="7">July</option> | ||
<option value="8">August</option> | ||
<option data-divider="true"></option> | ||
<option value="9">September</option> | ||
<option value="10">October</option> | ||
<option value="11">November</option> | ||
<option value="12">December</option> | ||
</select> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3 row"> | ||
<label class="col-sm-2">Single Radio</label> | ||
|
||
<div class="col-sm-10"> | ||
<select id="single" class="radio full-width ms-dark-mode" data-test="radio"> | ||
<option value="1">January</option> | ||
<option value="2" selected>February</option> | ||
<option value="3">March</option> | ||
<option value="4">April</option> | ||
<option data-divider="true"></option> | ||
<option value="5">May</option> | ||
<option value="6">June</option> | ||
<option value="7">July</option> | ||
<option value="8">August</option> | ||
<option data-divider="true"></option> | ||
<option value="9">September</option> | ||
<option value="10">October</option> | ||
<option value="11">November</option> | ||
<option value="12">December</option> | ||
</select> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3 row"> | ||
<label class="col-sm-2">Multiple Select</label> | ||
|
||
<div class="col-sm-10"> | ||
<select id="multiple" class="select full-width" data-test="multiple" multiple> | ||
<option value="1">January</option> | ||
<option value="2">February</option> | ||
<option value="3">March</option> | ||
<option value="4">April</option> | ||
<option data-divider="true"></option> | ||
<option value="5">May</option> | ||
<option value="6">June</option> | ||
<option value="7">July</option> | ||
<option value="8">August</option> | ||
<option data-divider="true"></option> | ||
<option value="9">September</option> | ||
<option value="10">October</option> | ||
<option value="11">November</option> | ||
<option value="12">December</option> | ||
</select> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3 row"> | ||
<label class="col-sm-2">Group Select</label> | ||
|
||
<div class="col-sm-10"> | ||
<select id="group" class="select full-width" data-test="group" multiple> | ||
<option data-divider="true"></option> | ||
<optgroup label="Group 1"> | ||
<option value="1">January</option> | ||
<option value="2">February</option> | ||
<option value="3">March</option> | ||
<option data-divider="true"></option> | ||
<option value="4">April</option> | ||
<option value="5">May</option> | ||
<option value="6">June</option> | ||
</optgroup> | ||
<option data-divider="true"></option> | ||
<optgroup label="Group 2"> | ||
<option value="7">July</option> | ||
<option value="8">August</option> | ||
<option value="9">September</option> | ||
<option data-divider="true"></option> | ||
<option value="10">October</option> | ||
<option value="11">November</option> | ||
<option value="12">December</option> | ||
</optgroup> | ||
</select> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3 row"> | ||
<label class="col-sm-2">Data Select 1</label> | ||
|
||
<div class="col-sm-10"> | ||
<select id="data-select1" class="data-select full-width" data-test="data1" multiple></select> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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,7 @@ | ||
.panel-wm-content.dark-mode { | ||
background-color: #33393e; | ||
h2.bd-title, | ||
label { | ||
color: #dddddd; | ||
} | ||
} |
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,59 @@ | ||
import { type MultipleSelectInstance, multipleSelect } from 'multiple-select-vanilla'; | ||
|
||
import './example15.scss'; | ||
|
||
export default class Example { | ||
ms1: MultipleSelectInstance[] = []; | ||
ms2?: MultipleSelectInstance; | ||
ms3?: MultipleSelectInstance; | ||
|
||
mount() { | ||
document.querySelector('.panel-wm-content')?.classList.add('dark-mode'); | ||
|
||
this.ms1 = multipleSelect('.select', { darkMode: true }) as MultipleSelectInstance[]; | ||
this.ms2 = multipleSelect('.radio', { darkMode: true, singleRadio: true }) as MultipleSelectInstance; | ||
this.ms3 = multipleSelect('.data-select', { | ||
darkMode: true, | ||
dataTest: 'select1', | ||
showOkButton: true, | ||
data: [ | ||
{ | ||
value: 1, | ||
text: 'Option 1', | ||
}, | ||
{ | ||
value: 2, | ||
text: 'Option 2', | ||
}, | ||
{ | ||
value: 3, | ||
text: 'Option 3', | ||
}, | ||
{ | ||
divider: true, | ||
}, | ||
{ | ||
value: 4, | ||
text: 'Option 4', | ||
}, | ||
{ | ||
value: 5, | ||
text: 'Option 5', | ||
}, | ||
{ | ||
value: 6, | ||
text: 'Option 6', | ||
}, | ||
], | ||
}) as MultipleSelectInstance; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms1.forEach(m => m.destroy()); | ||
this.ms2?.destroy(); | ||
this.ms3?.destroy(); | ||
this.ms1 = []; | ||
document.querySelector('.panel-wm-content')?.classList.remove('dark-mode'); | ||
} | ||
} |
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
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
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
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
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.