Added code example

This commit is contained in:
MaxOvs 2022-12-19 22:48:05 +03:00
parent 4561d50fa0
commit 5c0f244eb1
3 changed files with 214 additions and 27 deletions

View File

@ -26,9 +26,9 @@
<div class="container content"> <div class="container content">
<div class="example-select"> <div class="example-select">
<form method="get" class="form">
<div>
<h2 class="example-select_title">Дефолтный селект</h2> <h2 class="example-select_title">Дефолтный селект</h2>
<form method="get" class="form">
<div class="layout-select">
<button class="cg-dropdown cg-dropdown_one"></button> <button class="cg-dropdown cg-dropdown_one"></button>
</div> </div>
@ -36,62 +36,218 @@
<code> <code>
<pre> <pre>
const dropdown = new DropDown({ <span class="code__keyword">const</span> <span class="code__var">dropdown</span> = <span class="code__keyword">new</span> <span class="code__class">DropDown</span>({
selector: '.cg-dropdown_one', selector: <span class="code__string">'.cg-dropdown_one',</span>
placeholder: 'Выберите авто', placeholder: <span class="code__string">'Выберите авто',</span>
lable: 'EXAMPLE', lable: <span class="code__string">'EXAMPLE',</span>
span.code__string
items: [ items: [
'BMW', <span class="code__string">'BMW',</span>
{ {
id: '213sade', id: <span class="code__string">'213sade',</span>
title: 'Opel', title: <span class="code__string">'Opel',</span>
value: 1, value: 1,
}, },
'Mersedes', <span class="code__string">'Mersedes',</span>
'MAN', <span class="code__string">'MAN',</span>
'Ferari', <span class="code__string">'Ferari',</span>
], ],
styles: { styles: {
head: { head: {
width: '830px', width: <span class="code__string">'830px',</span>
}, },
list: { list: {
width: '824px', width: <span class="code__string">'824px',</span>
}, },
}, },
}); });
</pre> </pre>
</code> </code>
</form> </form>
</div> </div>
<div class="example-select"> <div class="example-select">
<h1 class="example-select_title">Селект с данными с URL</h1> <h1 class="example-select_title">Селект с данными с URL</h1>
<div class="layout-select">
<button class="cg-dropdown cg-dropdown_three"></button> <button class="cg-dropdown cg-dropdown_three"></button>
</div> </div>
<code>
<pre>
<span class="code__keyword">const</span> <span class="code__var">dropdown</span> = <span class="code__keyword">new</span> <span class="code__class">DropDown</span>({
selector: <span class="code__string">'.cg-dropdown_three',</span>
placeholder: <span class="code__string">'URL',</span>
url: <span class="code__string">'https://jsonplaceholder.typicode.com/users',</span>
searchMode: <span class="code__keyword">true,</span>
darkTheme: <span class="code__keyword">false,</span>
language: <span class="code__string">'ru',</span>
styles: {
head: {
width: <span class="code__string">'830px',</span>
},
list: {
width: <span class="code__string">'824px',</span>
},
},
});
</pre>
</code>
</div>
<div class="example-select"> <div class="example-select">
<h1 class="example-select_title">Категории</h1> <h1 class="example-select_title">Категории</h1>
<div class="layout-select">
<button class="cg-dropdown cg-dropdown_categories"></button> <button class="cg-dropdown cg-dropdown_categories"></button>
</div> </div>
<code>
<pre>
<span class="code__keyword">const</span> <span class="code__var">dropdown</span> = <span class="code__keyword">new</span> <span class="code__class">DropDown</span>({
selector: <span class="code__string">'.cg-dropdown_categories',</span>
placeholder: <span class="code__string">'Выберите регион',</span>
searchMode: <span class="code__keyword">true,</span>
items: [
{
category: <span class="code__string">'Russia',</span>
categoryItems: [
{
id: <span class="code__string">'28qwds',</span>
title: <span class="code__string">'Москва',</span>
value: 0,
},
<span class="code__string">'Ростов-на-дону',</span>
<span class="code__string">'Саратов',</span>
<span class="code__string">'Волгоград',</span>
<span class="code__string">'Донецк',</span>
],
},
{
category: <span class="code__string">'USA',</span>
categoryItems: <span class="code__string">['Alabama', 'Texas', 'Colorado', 'Klirens', 'Los-Angeles'],</span>
},
{
category: <span class="code__string">'France',</span>
categoryItems: <span class="code__string">['Paris'],</span>
},
],
styles: {
head: {
width: <span class="code__string">'830px',</span>
},
list: {
width: <span class="code__string">'824px',</span>
},
placeholder: {
maxWidth: <span class="code__string">'500px ',</span>
},
},
multiselect: <span class="code__keyword">true,</span>
multiselectTag: <span class="code__keyword">true,</span>
});
</pre>
</code>
</div>
<div class="example-select"> <div class="example-select">
<h1 class="example-select_title">Управление с помошью кнопок</h1> <h1 class="example-select_title">Управление с помошью кнопок</h1>
<div style="margin-bottom: 15px"> <div style="margin-bottom: 15px">
<button class="button__open example-select_submit">Open</button> <button class="button__open example-select_submit">Open</button>
<button class="button__close example-select_submit">Close</button> <button class="button__close example-select_submit">Close</button>
</div> </div>
<div class="layout-select">
<button class="cg-dropdown cg-dropdown_usedBtn"></button> <button class="cg-dropdown cg-dropdown_usedBtn"></button>
</div> </div>
<code>
<pre>
<span class="code__keyword">const</span> <span class="code__var">dropdown</span> = <span class="code__keyword">new</span> <span class="code__class">DropDown</span>({
selector: <span class="code__string">'.cg-dropdown_usedBtn',</span>
placeholder: <span class="code__string">'Выберите авто',</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">'max',</span>
],
styles: {
head: {
width: <span class="code__string">'830px',</span>
color: <span class="code__string">'black',</span>
backgroundColor: <span class="code__string">'rgb(176 223 167)',</span>
},
list: {
width: <span class="code__string">'824px',</span>
color: <span class="code__string">'black',</span>
backgroundColor: <span class="code__string">'rgb(176 223 167)',</span>
},
caret: {
borderTop: <span class="code__string">'6px solid black',</span>
},
search: {
backgroundColor: <span class="code__string">'#d7ffff',</span>
borderRadius: <span class="code__string">'5px',</span>
borderBottom: <span class="code__string">'none',</span>
width: <span class="code__string">'95%',</span>
color: <span class="code__string">'black',</span>
},
},
multiselect: <span class="code__keyword">true,</span>
});
</pre>
</code>
</div>
<div class="example-select"> <div class="example-select">
<h1 class="example-select_title">Функция disabled</h1> <h1 class="example-select_title">Функция disabled</h1>
<input type="checkbox" name="chbx" id="checkboxDisable" style="margin-bottom: 16px" /> <input type="checkbox" name="chbx" id="checkboxDisable" style="margin-bottom: 16px" />
<label for="checkboxDisable">Вы согласны на обработку данных</label> <label for="checkboxDisable">Вы согласны на обработку данных</label>
<div class="layout-select">
<button class="cg-dropdown cg-dropdown_checkboxDisable"></button> <button class="cg-dropdown cg-dropdown_checkboxDisable"></button>
</div> </div>
<code>
<pre>
<span class="code__keyword">const</span> <span class="code__var">dropdown</span> = <span class="code__keyword">new</span> <span class="code__class">DropDown</span>({
selector: <span class="code__string">'.cg-dropdown_checkboxDisable',</span>
placeholder: <span class="code__string">'Выберите авто',</span>
lable: <span class="code__string">'EXAMPLE',</span>
span.code__string
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>
},
placeholder: {
maxWidth: <span class="code__string">'500px ',</span>
},
},
});
</pre>
</code>
</div>
</div> </div>
</body> </body>
<script type="module" src="/src/index.js"></script> <script type="module" src="/src/index.js"></script>

View File

@ -49,8 +49,6 @@ const dropdown3 = new DropDown({
width: '824px', width: '824px',
}, },
}, },
// multiselect: true,
// multiselectTag: true,
}); });
// --------------------------------Категории-------------------------- // --------------------------------Категории--------------------------
@ -103,7 +101,6 @@ const dropdownBtn = new DropDown({
selector: '.cg-dropdown_usedBtn', selector: '.cg-dropdown_usedBtn',
placeholder: 'Выберите авто', placeholder: 'Выберите авто',
searchMode: true, searchMode: true,
items: [ items: [
'BMW', 'BMW',
{ {

View File

@ -69,7 +69,6 @@
background-color: #5c5c5c; background-color: #5c5c5c;
border-radius: 5px; border-radius: 5px;
margin: 15px 0 0 0; margin: 15px 0 0 0;
//padding: 0 13px 13px 13px;
&_title { &_title {
height: 45px; height: 45px;
@ -83,11 +82,13 @@
} }
&_submit { &_submit {
//background-color: #2a2f3b;
width: 200px; width: 200px;
height: 35px; height: 35px;
border-radius: 10px; border-radius: 10px;
border: none; border: none;
margin-top: 20px; margin-top: 20px;
margin: 20px 15px;
cursor: pointer; cursor: pointer;
transition: 1s; transition: 1s;
-webkit-transition: 1s; -webkit-transition: 1s;
@ -104,10 +105,43 @@
-o-transition: 1s; -o-transition: 1s;
} }
} }
.layout-select {
margin: 15px;
}
} }
pre { pre {
background: #1e1e1e;
margin: 15px;
padding: 15px;
color: #88d0f7;
border-radius: 15px;
font-size: 16px;
line-height: 20px;
}
.code {
&__class,
&__var,
&__string,
&__keyword {
font-size: 16px;
line-height: 20px;
}
&__class {
color: #4ec9b0;
}
&__var {
color: #34a7ff;
}
&__string {
color: #ce9178;
}
&__keyword {
color: #5090ca;
}
} }