Added new theme fn
This commit is contained in:
parent
8baf5554df
commit
102fb5a7b1
@ -25,6 +25,7 @@ const dropdown = new CGSelect({
|
|||||||
width: '824px',
|
width: '824px',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
theme: 'dark'
|
||||||
});
|
});
|
||||||
|
|
||||||
// ------------------------------NativeSelect-----------------------
|
// ------------------------------NativeSelect-----------------------
|
||||||
|
@ -37,6 +37,7 @@ export class CGSelect implements ICgSelect {
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
items?: IItems[] | string[] | any;
|
items?: IItems[] | string[] | any;
|
||||||
darkTheme?: boolean;
|
darkTheme?: boolean;
|
||||||
|
theme?: string;
|
||||||
searchMode?: boolean;
|
searchMode?: boolean;
|
||||||
closeOnSelect?: boolean;
|
closeOnSelect?: boolean;
|
||||||
nativeSelectMode?: boolean;
|
nativeSelectMode?: boolean;
|
||||||
@ -195,7 +196,7 @@ export class CGSelect implements ICgSelect {
|
|||||||
lable,
|
lable,
|
||||||
event,
|
event,
|
||||||
selected,
|
selected,
|
||||||
placeholder,
|
placeholder, theme
|
||||||
} = setting;
|
} = setting;
|
||||||
|
|
||||||
this.options = setting;
|
this.options = setting;
|
||||||
@ -215,6 +216,7 @@ export class CGSelect implements ICgSelect {
|
|||||||
this.event = event;
|
this.event = event;
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
this.placeholder = placeholder;
|
this.placeholder = placeholder;
|
||||||
|
this.theme = theme;
|
||||||
|
|
||||||
const elem = document.querySelector(this.selector!);
|
const elem = document.querySelector(this.selector!);
|
||||||
this.element = elem;
|
this.element = elem;
|
||||||
@ -358,6 +360,7 @@ export class CGSelect implements ICgSelect {
|
|||||||
if (this.darkTheme == false) {
|
if (this.darkTheme == false) {
|
||||||
this.checkTheme();
|
this.checkTheme();
|
||||||
}
|
}
|
||||||
|
this.themeCheck();
|
||||||
|
|
||||||
if (this.nativeSelectMode === true) {
|
if (this.nativeSelectMode === true) {
|
||||||
this.selectMode(this.nativeSelectMode);
|
this.selectMode(this.nativeSelectMode);
|
||||||
@ -680,6 +683,28 @@ export class CGSelect implements ICgSelect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private themeCheck(): void{
|
||||||
|
const select = this.element!.querySelector('.cg-select');
|
||||||
|
const caret = this.element!.querySelector('.caret');
|
||||||
|
const list = this.element!.querySelector('ul.list');
|
||||||
|
const search = this.element!.querySelector('.inputSearch');
|
||||||
|
|
||||||
|
switch (this.theme) {
|
||||||
|
case 'classic':
|
||||||
|
console.log('sss');
|
||||||
|
break;
|
||||||
|
case 'dark':
|
||||||
|
console.log('dark');
|
||||||
|
break;
|
||||||
|
case 'white':
|
||||||
|
console.log('white');
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {boolean} nativeSelectMode parameter responsible for adding native select.
|
* @param {boolean} nativeSelectMode parameter responsible for adding native select.
|
||||||
|
11
src/components/theme/theme.json
Normal file
11
src/components/theme/theme.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "classic"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "dark"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "white"
|
||||||
|
}
|
||||||
|
]
|
@ -30,6 +30,7 @@ export interface ICgSelect {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
darkTheme?: boolean;
|
darkTheme?: boolean;
|
||||||
|
theme?: string;
|
||||||
/**
|
/**
|
||||||
* An optional parameter that adds a live search on the select elements.
|
* An optional parameter that adds a live search on the select elements.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
@import './style/svgStyle.scss';
|
@import './style/svgStyle.scss';
|
||||||
@import './style/whiteTheme.scss';
|
@import './style/whiteTheme.scss';
|
||||||
@import './style/displayMode.scss';
|
@import './style/displayMode.scss';
|
||||||
|
@import './style/classicTheme.scss';
|
||||||
|
@import './style/darkTheme.scss';
|
||||||
|
|
||||||
// ----Layout----
|
// ----Layout----
|
||||||
.cg-dropdown {
|
.cg-dropdown {
|
||||||
@ -26,7 +28,6 @@
|
|||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
color: #fff;
|
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
@ -42,7 +43,6 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
background: #2a2f3b;
|
|
||||||
|
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -70,8 +70,6 @@
|
|||||||
-moz-transition: 0.5s;
|
-moz-transition: 0.5s;
|
||||||
-ms-transition: 0.5s;
|
-ms-transition: 0.5s;
|
||||||
-o-transition: 0.5s;
|
-o-transition: 0.5s;
|
||||||
|
|
||||||
background: #394050;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,10 +112,6 @@
|
|||||||
margin-top: -0.2px;
|
margin-top: -0.2px;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
|
||||||
color: white;
|
|
||||||
background: #2a2f3b;
|
|
||||||
border: 1px #0a0b0e solid;
|
|
||||||
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
-webkit-border-radius: 5px;
|
-webkit-border-radius: 5px;
|
||||||
-moz-border-radius: 5px;
|
-moz-border-radius: 5px;
|
||||||
|
14
src/style/classicTheme.scss
Normal file
14
src/style/classicTheme.scss
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
.cg-select{
|
||||||
|
color: #fff;
|
||||||
|
background: #2a2f3b;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #394050;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.list {
|
||||||
|
color: white;
|
||||||
|
background: #2a2f3b;
|
||||||
|
border: 1px #0a0b0e solid;
|
||||||
|
}
|
32
src/style/darkTheme.scss
Normal file
32
src/style/darkTheme.scss
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
.selectDark {
|
||||||
|
background: rgb(29, 29, 29) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
// .selectDark,
|
||||||
|
// .listDark,
|
||||||
|
// .inputWhite,
|
||||||
|
// .pathBlack,
|
||||||
|
// .selectWhite {
|
||||||
|
// color: black !important;
|
||||||
|
// }
|
||||||
|
|
||||||
|
.caretWhite {
|
||||||
|
border-top: 6px solid black !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.listWhite {
|
||||||
|
background-color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inputWhite {
|
||||||
|
border-bottom: 1px solid black !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pathWhite {
|
||||||
|
color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pathBlack {
|
||||||
|
color: black !important;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user