Fixed description and layout
This commit is contained in:
parent
5fc17c7c2d
commit
45df42825f
46
index.html
46
index.html
@ -420,6 +420,52 @@
|
||||
</code>
|
||||
</div>
|
||||
|
||||
<div class="example-select">
|
||||
<h1 class="example-select_title">Use callbacks</h1>
|
||||
|
||||
<div class="layout-select">
|
||||
<div class="col">
|
||||
<p style="color: white;">When using a callback, you can pass in the first parameter such values as: <span class="code__string">open, close, select, clear</span>.
|
||||
<br>The second parameter is a function in which there are two parameters: <span class="code__string">state</span> and <span class="code__string">value</span>.
|
||||
<br>The output of the value can be seen in the browser console.
|
||||
</p>
|
||||
</div>
|
||||
<button class="cg-dropdown cg-dropdown_callback"></button>
|
||||
</div>
|
||||
<button type="button" class="check-code" id="callback">View code</button>
|
||||
|
||||
<code id="codeCallback">
|
||||
<pre>
|
||||
<span class="code__keyword">const</span> <span class="code__var">dropdown</span> = <span class="code__keyword">new</span> <span class="code__class">CGSelect</span>({
|
||||
selector: <span class="code__string">'.cg-dropdown_categories',</span>
|
||||
placeholder: <span class="code__string">'Choose a car',</span>
|
||||
searchMode: <span class="code__keyword">true,</span>
|
||||
items: [
|
||||
<span class="code__string">'BMW',</span>
|
||||
{
|
||||
id: <span class="code__string">'213sade',</span>
|
||||
title: <span class="code__string">'Opel',</span>
|
||||
value: 1,
|
||||
},
|
||||
<span class="code__string">'Mersedes',</span>
|
||||
<span class="code__string">'MAN',</span>
|
||||
<span class="code__string">'Ferari',</span>
|
||||
],
|
||||
styles: {
|
||||
head: {
|
||||
width: <span class="code__string">'830px',</span>
|
||||
},
|
||||
list: {
|
||||
width: <span class="code__string">'824px',</span>
|
||||
},
|
||||
},
|
||||
multiselect: <span class="code__keyword">true,</span>
|
||||
multiselectTag: <span class="code__keyword">true,</span>
|
||||
});
|
||||
</pre>
|
||||
</code>
|
||||
</div>
|
||||
|
||||
<div class="example-select">
|
||||
<h1 class="example-select_title">Button control</h1>
|
||||
<div style="margin-bottom: 15px">
|
||||
|
242
index.js
242
index.js
@ -1,31 +1,31 @@
|
||||
import CGSelect from 'cg-select';
|
||||
import CGSelect from "cg-select";
|
||||
// import { newCustomTheme } from './src/themeTest';
|
||||
|
||||
import './src/example';
|
||||
import './src/constructor/constructor';
|
||||
import "./src/example";
|
||||
import "./src/constructor/constructor";
|
||||
|
||||
// ------------------------------Обычный селект--------------------
|
||||
const dropdown = new CGSelect({
|
||||
selector: '.cg-dropdown_one',
|
||||
placeholder: 'Choose a car',
|
||||
label: 'EXAMPLE',
|
||||
selector: ".cg-dropdown_one",
|
||||
placeholder: "Choose a car",
|
||||
label: "EXAMPLE",
|
||||
items: [
|
||||
'BMW',
|
||||
"BMW",
|
||||
{
|
||||
id: '213sade',
|
||||
title: 'Opel',
|
||||
id: "213sade",
|
||||
title: "Opel",
|
||||
value: 1,
|
||||
},
|
||||
'Mersedes',
|
||||
'MAN',
|
||||
'Ferari',
|
||||
"Mersedes",
|
||||
"MAN",
|
||||
"Ferari",
|
||||
],
|
||||
styles: {
|
||||
head: {
|
||||
width: '830px',
|
||||
width: "830px",
|
||||
},
|
||||
list: {
|
||||
width: '824px',
|
||||
width: "824px",
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -35,123 +35,123 @@ const dropdown = new CGSelect({
|
||||
// });
|
||||
|
||||
const droptheme = new CGSelect({
|
||||
selector: '.cg-dropdown_theme',
|
||||
placeholder: 'Choose a car',
|
||||
selector: ".cg-dropdown_theme",
|
||||
placeholder: "Choose a car",
|
||||
items: [
|
||||
'BMW',
|
||||
"BMW",
|
||||
{
|
||||
id: '213sade',
|
||||
title: 'Opel',
|
||||
id: "213sade",
|
||||
title: "Opel",
|
||||
value: 1,
|
||||
},
|
||||
'Mersedes',
|
||||
'MAN',
|
||||
'Ferari',
|
||||
"Mersedes",
|
||||
"MAN",
|
||||
"Ferari",
|
||||
],
|
||||
styles: {
|
||||
head: {
|
||||
width: '830px',
|
||||
width: "830px",
|
||||
},
|
||||
list: {
|
||||
width: '824px',
|
||||
width: "824px",
|
||||
},
|
||||
},
|
||||
theme: 'dark',
|
||||
theme: "dark",
|
||||
});
|
||||
// ------------------------------NativeSelect-----------------------
|
||||
const dropdownNativeSelect = new CGSelect({
|
||||
selector: '.cg-dropdown_selectNative',
|
||||
placeholder: 'Choose a car',
|
||||
selector: ".cg-dropdown_selectNative",
|
||||
placeholder: "Choose a car",
|
||||
nativeSelectMode: true,
|
||||
items: [
|
||||
'BMW',
|
||||
"BMW",
|
||||
{
|
||||
id: '213sade',
|
||||
title: 'Opel',
|
||||
id: "213sade",
|
||||
title: "Opel",
|
||||
value: 1,
|
||||
},
|
||||
'Mersedes',
|
||||
'MAN',
|
||||
'Ferari',
|
||||
'Kamaz',
|
||||
'Ural',
|
||||
"Mersedes",
|
||||
"MAN",
|
||||
"Ferari",
|
||||
"Kamaz",
|
||||
"Ural",
|
||||
],
|
||||
styles: {
|
||||
head: {
|
||||
width: '830px',
|
||||
width: "830px",
|
||||
},
|
||||
list: {
|
||||
width: '824px',
|
||||
width: "824px",
|
||||
},
|
||||
},
|
||||
theme: 'dark',
|
||||
theme: "dark",
|
||||
});
|
||||
|
||||
// ------------------------------listDisplayMode--------------------
|
||||
const dropdownlistDisplayMode = new CGSelect({
|
||||
selector: '.cg-dropdown_listDisplayMode',
|
||||
placeholder: 'Choose a car',
|
||||
selector: ".cg-dropdown_listDisplayMode",
|
||||
placeholder: "Choose a car",
|
||||
listDisplayMode: true,
|
||||
items: [
|
||||
'BMW',
|
||||
"BMW",
|
||||
{
|
||||
id: '213sade',
|
||||
title: 'Opel',
|
||||
id: "213sade",
|
||||
title: "Opel",
|
||||
value: 1,
|
||||
},
|
||||
'Mersedes',
|
||||
'MAN',
|
||||
'Ferari',
|
||||
"Mersedes",
|
||||
"MAN",
|
||||
"Ferari",
|
||||
],
|
||||
styles: {
|
||||
head: {
|
||||
width: '830px',
|
||||
width: "830px",
|
||||
},
|
||||
list: {
|
||||
width: '824px',
|
||||
width: "824px",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// --------------------------------Категории--------------------------
|
||||
const dropdown4 = new CGSelect({
|
||||
selector: '.cg-dropdown_categories',
|
||||
placeholder: 'Choose region',
|
||||
selector: ".cg-dropdown_categories",
|
||||
placeholder: "Choose region",
|
||||
searchMode: true,
|
||||
items: [
|
||||
{
|
||||
category: 'Russia',
|
||||
category: "Russia",
|
||||
categoryItems: [
|
||||
{
|
||||
id: '28qwds',
|
||||
title: 'Москва',
|
||||
id: "28qwds",
|
||||
title: "Москва",
|
||||
value: 0,
|
||||
},
|
||||
,
|
||||
'Ростов-на-дону',
|
||||
'Саратов',
|
||||
'Волгоград',
|
||||
'Донецк',
|
||||
"Ростов-на-дону",
|
||||
"Саратов",
|
||||
"Волгоград",
|
||||
"Донецк",
|
||||
],
|
||||
},
|
||||
{
|
||||
category: 'USA',
|
||||
categoryItems: ['Alabama', 'Texas', 'Colorado', 'Klirens', 'Los-Angeles'],
|
||||
category: "USA",
|
||||
categoryItems: ["Alabama", "Texas", "Colorado", "Klirens", "Los-Angeles"],
|
||||
},
|
||||
{
|
||||
category: 'France',
|
||||
categoryItems: ['Paris'],
|
||||
category: "France",
|
||||
categoryItems: ["Paris"],
|
||||
},
|
||||
],
|
||||
styles: {
|
||||
head: {
|
||||
width: '830px',
|
||||
width: "830px",
|
||||
},
|
||||
list: {
|
||||
width: '824px',
|
||||
width: "824px",
|
||||
},
|
||||
placeholder: {
|
||||
maxWidth: '500px ',
|
||||
maxWidth: "500px ",
|
||||
},
|
||||
},
|
||||
multiselect: true,
|
||||
@ -160,84 +160,84 @@ const dropdown4 = new CGSelect({
|
||||
|
||||
//----------------управление с помощью кнопок----------------------------------
|
||||
const dropdownBtn = new CGSelect({
|
||||
selector: '.cg-dropdown_usedBtn',
|
||||
placeholder: 'Choose a car',
|
||||
selector: ".cg-dropdown_usedBtn",
|
||||
placeholder: "Choose a car",
|
||||
searchMode: true,
|
||||
items: [
|
||||
'BMW',
|
||||
"BMW",
|
||||
{
|
||||
id: '213sade',
|
||||
title: 'Opel',
|
||||
id: "213sade",
|
||||
title: "Opel",
|
||||
value: 1,
|
||||
},
|
||||
'Mersedes',
|
||||
'MAN',
|
||||
'max',
|
||||
"Mersedes",
|
||||
"MAN",
|
||||
"max",
|
||||
],
|
||||
styles: {
|
||||
head: {
|
||||
width: '830px',
|
||||
color: 'black',
|
||||
backgroundColor: 'rgb(176 223 167)',
|
||||
width: "830px",
|
||||
color: "black",
|
||||
backgroundColor: "rgb(176 223 167)",
|
||||
},
|
||||
list: {
|
||||
width: '824px',
|
||||
color: 'black',
|
||||
backgroundColor: 'rgb(176 223 167)',
|
||||
width: "824px",
|
||||
color: "black",
|
||||
backgroundColor: "rgb(176 223 167)",
|
||||
},
|
||||
caret: {
|
||||
borderTop: '6px solid black',
|
||||
borderTop: "6px solid black",
|
||||
},
|
||||
search: {
|
||||
backgroundColor: '#d7ffff',
|
||||
borderRadius: '5px',
|
||||
borderBottom: 'none',
|
||||
width: '95%',
|
||||
color: 'black',
|
||||
backgroundColor: "#d7ffff",
|
||||
borderRadius: "5px",
|
||||
borderBottom: "none",
|
||||
width: "95%",
|
||||
color: "black",
|
||||
},
|
||||
},
|
||||
multiselect: true,
|
||||
});
|
||||
|
||||
const buttonOpen = document.querySelector('.button__open');
|
||||
const buttonClose = document.querySelector('.button__close');
|
||||
const buttonOpen = document.querySelector(".button__open");
|
||||
const buttonClose = document.querySelector(".button__close");
|
||||
|
||||
dropdownBtn.buttonControl(buttonOpen, 'open');
|
||||
dropdownBtn.buttonControl(buttonClose, 'close');
|
||||
dropdownBtn.buttonControl(buttonOpen, "open");
|
||||
dropdownBtn.buttonControl(buttonClose, "close");
|
||||
|
||||
//-------------------------Функция Disabled----------------------------------
|
||||
const dropdownDisabled = new CGSelect({
|
||||
selector: '.cg-dropdown_checkboxDisable',
|
||||
placeholder: 'Choose a car',
|
||||
selector: ".cg-dropdown_checkboxDisable",
|
||||
placeholder: "Choose a car",
|
||||
searchMode: true,
|
||||
items: [
|
||||
'BMW',
|
||||
"BMW",
|
||||
{
|
||||
id: '213sade',
|
||||
title: 'Opel',
|
||||
id: "213sade",
|
||||
title: "Opel",
|
||||
value: 1,
|
||||
},
|
||||
'Mersedes',
|
||||
'MAN',
|
||||
'max',
|
||||
"Mersedes",
|
||||
"MAN",
|
||||
"max",
|
||||
],
|
||||
styles: {
|
||||
head: {
|
||||
width: '830px',
|
||||
width: "830px",
|
||||
},
|
||||
list: {
|
||||
width: '824px',
|
||||
width: "824px",
|
||||
},
|
||||
placeholder: {
|
||||
maxWidth: '500px ',
|
||||
maxWidth: "500px ",
|
||||
},
|
||||
},
|
||||
multiselect: true,
|
||||
});
|
||||
dropdownDisabled.disabled(true);
|
||||
let chbox = document.getElementById('checkboxDisable');
|
||||
let chbox = document.getElementById("checkboxDisable");
|
||||
|
||||
chbox.addEventListener('click', () => {
|
||||
chbox.addEventListener("click", () => {
|
||||
if (chbox.checked == true) {
|
||||
dropdownDisabled.disabled(false);
|
||||
} else {
|
||||
@ -247,19 +247,47 @@ chbox.addEventListener('click', () => {
|
||||
|
||||
// ------------------------------URL--------------------
|
||||
const dropdown3 = new CGSelect({
|
||||
selector: '.cg-dropdown_three',
|
||||
placeholder: 'URL',
|
||||
url: 'https://jsonplaceholder.typicode.com/todos',
|
||||
selector: ".cg-dropdown_three",
|
||||
placeholder: "URL",
|
||||
url: "https://jsonplaceholder.typicode.com/todos",
|
||||
searchMode: true,
|
||||
darkTheme: false,
|
||||
language: 'ru',
|
||||
language: "ru",
|
||||
styles: {
|
||||
head: {
|
||||
width: '830px',
|
||||
width: "830px",
|
||||
},
|
||||
list: {
|
||||
width: '824px',
|
||||
width: "824px",
|
||||
},
|
||||
},
|
||||
multiselect: true,
|
||||
});
|
||||
|
||||
const dropCall = new CGSelect({
|
||||
selector: ".cg-dropdown_callback",
|
||||
placeholder: "Choose a car",
|
||||
items: [
|
||||
"BMW",
|
||||
{
|
||||
id: "213sade",
|
||||
title: "Opel",
|
||||
value: 1,
|
||||
},
|
||||
"Mersedes",
|
||||
"MAN",
|
||||
"Ferari",
|
||||
],
|
||||
styles: {
|
||||
head: {
|
||||
width: "830px",
|
||||
},
|
||||
list: {
|
||||
width: "824px",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
dropCall.on("select", (state, value) => {
|
||||
console.log(value);
|
||||
});
|
||||
|
@ -1,48 +1,55 @@
|
||||
const firstBtn = document.getElementById('first');
|
||||
const codeFirst = document.getElementById('codeFirst');
|
||||
const firstBtn = document.getElementById("first");
|
||||
const codeFirst = document.getElementById("codeFirst");
|
||||
|
||||
const secondBtn = document.getElementById('second');
|
||||
const codeSecond = document.getElementById('codeSecond');
|
||||
const secondBtn = document.getElementById("second");
|
||||
const codeSecond = document.getElementById("codeSecond");
|
||||
|
||||
const thirdBtn = document.getElementById('third');
|
||||
const codeThird = document.getElementById('codeThird');
|
||||
const thirdBtn = document.getElementById("third");
|
||||
const codeThird = document.getElementById("codeThird");
|
||||
|
||||
const fourthBtn = document.getElementById('fourth');
|
||||
const codeFourth = document.getElementById('codeFourth');
|
||||
const fourthBtn = document.getElementById("fourth");
|
||||
const codeFourth = document.getElementById("codeFourth");
|
||||
|
||||
const fifthBtn = document.getElementById('fifth');
|
||||
const codeFifth = document.getElementById('codeFifth');
|
||||
const fifthBtn = document.getElementById("fifth");
|
||||
const codeFifth = document.getElementById("codeFifth");
|
||||
|
||||
const six = document.getElementById('six');
|
||||
const codeSix = document.getElementById('codeSix');
|
||||
const six = document.getElementById("six");
|
||||
const codeSix = document.getElementById("codeSix");
|
||||
|
||||
const Native = document.getElementById('Native');
|
||||
const codeNative = document.getElementById('codeNative');
|
||||
const Native = document.getElementById("Native");
|
||||
const codeNative = document.getElementById("codeNative");
|
||||
|
||||
firstBtn.addEventListener('click', () => {
|
||||
codeFirst.classList.toggle('active');
|
||||
const callback = document.getElementById("callback");
|
||||
const codeCallback = document.getElementById("codeCallback");
|
||||
|
||||
firstBtn.addEventListener("click", () => {
|
||||
codeFirst.classList.toggle("active");
|
||||
});
|
||||
|
||||
secondBtn.addEventListener('click', () => {
|
||||
codeSecond.classList.toggle('active');
|
||||
secondBtn.addEventListener("click", () => {
|
||||
codeSecond.classList.toggle("active");
|
||||
});
|
||||
|
||||
thirdBtn.addEventListener('click', () => {
|
||||
codeThird.classList.toggle('active');
|
||||
thirdBtn.addEventListener("click", () => {
|
||||
codeThird.classList.toggle("active");
|
||||
});
|
||||
|
||||
fourthBtn.addEventListener('click', () => {
|
||||
codeFourth.classList.toggle('active');
|
||||
fourthBtn.addEventListener("click", () => {
|
||||
codeFourth.classList.toggle("active");
|
||||
});
|
||||
|
||||
fifthBtn.addEventListener('click', () => {
|
||||
codeFifth.classList.toggle('active');
|
||||
fifthBtn.addEventListener("click", () => {
|
||||
codeFifth.classList.toggle("active");
|
||||
});
|
||||
|
||||
six.addEventListener('click', () => {
|
||||
codeSix.classList.toggle('active');
|
||||
six.addEventListener("click", () => {
|
||||
codeSix.classList.toggle("active");
|
||||
});
|
||||
|
||||
Native.addEventListener('click', () => {
|
||||
codeNative.classList.toggle('active');
|
||||
Native.addEventListener("click", () => {
|
||||
codeNative.classList.toggle("active");
|
||||
});
|
||||
|
||||
callback.addEventListener("click", () => {
|
||||
codeCallback.classList.toggle("active");
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user