Added constructor select(css) and tested his

This commit is contained in:
MaxOvs19 2023-02-17 16:03:37 +03:00
parent a6b6f020dd
commit b206334a8b
8 changed files with 49 additions and 48 deletions

View File

@ -46,3 +46,5 @@ Tested in JS and React. Errors in work in React applications are revealed.
- Fixing bugs related to the cleanup of the select. - Fixing bugs related to the cleanup of the select.
- Documentation navigation update. - Documentation navigation update.
- Added icon for example page and documentation. - Added icon for example page and documentation.
##### 00.02.2023 - update 0.2.34

View File

@ -1,6 +1,6 @@
# CG-SELECT # CG-SELECT
## version ~ 0.2.33 ## version ~ 0.2.34
This component allows you to create a custom select. It offers more flexible customization and use of select. This component allows you to create a custom select. It offers more flexible customization and use of select.
Customization, multi-selection and live search by elements are available. Customization, multi-selection and live search by elements are available.

View File

@ -1,6 +1,6 @@
# CG-SELECT # CG-SELECT
## version ~ 0.2.33 ## version ~ 0.2.34
Этот компонент позволяет вам создать пользовательский Select. Он предлагает более гибкую настройку и использование select. Этот компонент позволяет вам создать пользовательский Select. Он предлагает более гибкую настройку и использование select.
Доступна кастомизация, multi-selection, живой поиск по элементам и многое другое. Доступна кастомизация, multi-selection, живой поиск по элементам и многое другое.

View File

@ -62,7 +62,7 @@
</a> </a>
<a href="#version--0231" id="version--0231" style="color: inherit; text-decoration: none"> <a href="#version--0231" id="version--0231" style="color: inherit; text-decoration: none">
<h2>version ~ 0.2.33</h2> <h2>version ~ 0.2.34</h2>
</a> </a>
<p> <p>
This component allows you to create a custom select. It offers more flexible This component allows you to create a custom select. It offers more flexible

View File

@ -331,6 +331,7 @@
rows="5" rows="5"
class="textareaStyle" class="textareaStyle"
placeholder="Enter CSS properties" placeholder="Enter CSS properties"
disabled="disabled"
></textarea> ></textarea>
<button type="button" class="check-code render">Render</button> <button type="button" class="check-code render">Render</button>
<button type="button" class="check-code saveStyle">Save style</button> <button type="button" class="check-code saveStyle">Save style</button>

View File

@ -3,7 +3,7 @@ import { CGSelect } from '../../../src/cg-select';
const body = new CGSelect({ const body = new CGSelect({
selector: '.body', selector: '.body',
placeholder: 'Select element to style', placeholder: 'Select element to style',
items: ['head', 'list', 'placeholder', 'caret', 'search', 'chips', 'lable'], items: ['head', 'list', 'placeholder', 'caret', 'search', 'chips'],
}); });
let head = ''; let head = '';
@ -11,7 +11,6 @@ let list = '';
let placeholder = ''; let placeholder = '';
let caret = ''; let caret = '';
let chips = ''; let chips = '';
let lable = '';
let valueSelect = ''; let valueSelect = '';
const textarea = document.querySelector('#styles'); const textarea = document.querySelector('#styles');
@ -20,44 +19,41 @@ const saveStyleBtn = document.querySelector('.saveStyle');
body.on('select', (e, value) => { body.on('select', (e, value) => {
valueSelect = value; valueSelect = value;
textarea.value = '';
textarea.removeAttribute('disabled');
getValueSelect(valueSelect); getValueSelect(valueSelect);
}); });
function getValueSelect(value) { function getValueSelect(value) {
switch (value) { textarea.onkeyup = function () {
case 'head': switch (value) {
// ввод стилей case 'head':
// background: red; // ввод стилей
textarea.onkeyup = function () {
console.log(textarea.value);
head = textarea.value; head = textarea.value;
}; break;
break; case 'list':
case 'list': list = textarea.value;
break; break;
case 'placeholder': case 'placeholder':
break; placeholder = textarea.value;
case 'caret': break;
break; case 'caret':
case 'search': caret = textarea.value;
break; break;
case 'chips': case 'search':
break; search = textarea.value;
case 'lable': break;
break; case 'chips':
chips = textarea.value;
break;
default: default:
break; break;
} }
};
} }
// Рендер селекта со стилями
renderBtn.addEventListener('click', () => { renderBtn.addEventListener('click', () => {
// debugger;
// let HEAD = {
// key[0]: key[1]
// };
const select = new CGSelect({ const select = new CGSelect({
selector: '.select', selector: '.select',
placeholder: 'Choose a car', placeholder: 'Choose a car',
@ -72,16 +68,18 @@ renderBtn.addEventListener('click', () => {
'MAN', 'MAN',
'Ferari', 'Ferari',
], ],
styles: { searchMode: true,
head: {
background: head,
},
placeholder: {},
list: {},
caret: {},
chips: {},
search: {},
lable: {},
},
}); });
const drop = document.querySelector('.select');
let headSelect = drop.querySelector('.cg-select');
let listSelect = drop.querySelector('.list');
let placeholderSelect = drop.querySelector('.selected');
let caretSelect = drop.querySelector('.caret');
let searchSelect = drop.querySelector('.inputSearch');
headSelect.setAttribute('style', head);
listSelect.setAttribute('style', list);
placeholderSelect.setAttribute('style', placeholder);
caretSelect.setAttribute('style', caret);
searchSelect.setAttribute('style', search);
}); });

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "cg-select", "name": "cg-select",
"version": "0.2.33", "version": "0.2.34",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cg-select", "name": "cg-select",
"version": "0.2.33", "version": "0.2.34",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@parcel/optimizer-css": "^2.8.0", "@parcel/optimizer-css": "^2.8.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "cg-select", "name": "cg-select",
"version": "0.2.33", "version": "0.2.34",
"description": "Feature rich Select control for React/JS with multiselect, autocomplete and styling", "description": "Feature rich Select control for React/JS with multiselect, autocomplete and styling",
"author": { "author": {
"name": "CraftGroup", "name": "CraftGroup",