Test in textArea

This commit is contained in:
MaxOvs19 2023-02-16 19:02:53 +03:00
parent a3c433d328
commit a6b6f020dd
2 changed files with 51 additions and 30 deletions

View File

@ -332,6 +332,8 @@
class="textareaStyle" class="textareaStyle"
placeholder="Enter CSS properties" placeholder="Enter CSS properties"
></textarea> ></textarea>
<button type="button" class="check-code render">Render</button>
<button type="button" class="check-code saveStyle">Save style</button>
</div> </div>
<div class="layout-select constructor"> <div class="layout-select constructor">
<button class="cg-dropdown select"></button> <button class="cg-dropdown select"></button>

View File

@ -6,33 +6,18 @@ const body = new CGSelect({
items: ['head', 'list', 'placeholder', 'caret', 'search', 'chips', 'lable'], items: ['head', 'list', 'placeholder', 'caret', 'search', 'chips', 'lable'],
}); });
const select = new CGSelect({ let head = '';
selector: '.select', let list = '';
placeholder: 'Choose a car', let placeholder = '';
items: [ let caret = '';
'BMW', let chips = '';
{ let lable = '';
id: '213sade',
title: 'Opel',
value: 1,
},
'Mersedes',
'MAN',
'Ferari',
],
styles: {
head: {},
placeholder: {},
list: {},
caret: {},
chips: {},
search: {},
lable: {},
},
});
let valueSelect = ''; let valueSelect = '';
const textarea = document.querySelector('#styles');
const renderBtn = document.querySelector('.render');
const saveStyleBtn = document.querySelector('.saveStyle');
body.on('select', (e, value) => { body.on('select', (e, value) => {
valueSelect = value; valueSelect = value;
getValueSelect(valueSelect); getValueSelect(valueSelect);
@ -41,7 +26,12 @@ body.on('select', (e, value) => {
function getValueSelect(value) { function getValueSelect(value) {
switch (value) { switch (value) {
case 'head': case 'head':
console.log('lol'); // ввод стилей
// background: red;
textarea.onkeyup = function () {
console.log(textarea.value);
head = textarea.value;
};
break; break;
case 'list': case 'list':
break; break;
@ -61,8 +51,37 @@ function getValueSelect(value) {
} }
} }
let textarea = document.querySelector('#styles'); // Рендер селекта со стилями
renderBtn.addEventListener('click', () => {
// debugger;
// let HEAD = {
// key[0]: key[1]
// };
textarea.onkeyup = function () { const select = new CGSelect({
console.log(textarea.value); selector: '.select',
}; placeholder: 'Choose a car',
items: [
'BMW',
{
id: '213sade',
title: 'Opel',
value: 1,
},
'Mersedes',
'MAN',
'Ferari',
],
styles: {
head: {
background: head,
},
placeholder: {},
list: {},
caret: {},
chips: {},
search: {},
lable: {},
},
});
});