Skip to content

Commit a977490

Browse files
handymathis@gmail..comhandymathis@gmail..com
authored andcommitted
added documentation
1 parent c98fea2 commit a977490

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

documentation/dropdown.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Dropdown documentation
2+
3+
This part of the documentation will show you how to use the<br>
4+
included dropdown menus of ChocolateCSS.
5+
6+
# Basic usage
7+
8+
Using single page dropdown menus with ChocolateCSS is very easy.
9+
10+
```html
11+
<div class="dropdown dropdown-dark active">
12+
<div class="dropdown-menu">
13+
<div class="dropdown-menu-item">Item 1</div>
14+
<div class="dropdown-menu-item">Item 2</div>
15+
</div>
16+
</div>
17+
```
18+
19+
The other `div` tag contains three classes. The `dropdown` class defines the general structure of the dropdown.<br>
20+
The `dropdown-dark` class defines the theme of the dropdown.
21+
There are three different themes available.
22+
23+
- `dropdown-light`
24+
- `dropdown-grey`
25+
- `dropdown-dark`
26+
27+
The `active` class sets the visibility of the dropdown. `active` means, that the dropdown fades in from the top.
28+
29+
Into the other `div` you will have to put a div with the class `dropdown-menu`. Into this you can put your menu elements.<br>
30+
To define a menu element, you need to put a div into your menu `div` and add another `div` with the class `dropdown-menu-item`.
31+
32+
# Multiple menus
33+
34+
Multiple menus in one dropdown menu are also possible.
35+
36+
```html
37+
<div class="dropdown dropdown-dark active">
38+
<div class="dropdown-menu" id="main-menu">
39+
<div class="dropdown-menu-item" onclick="DropdownForwardMenu('main-menu', 'sec-menu');">Item 1</div>
40+
<div class="dropdown-menu-item">Item 2</div>
41+
</div>
42+
<div class="dropdown-submenu" id="sec-menu">
43+
<div class="dropdown-menu-item" onclick="DropdownBackwardMenu('sec-menu', 'main-menu');">Item 3</div>
44+
<div class="dropdown-menu-item">Item 4</div>
45+
</div>
46+
</div>
47+
```
48+
49+
To get multiple menus in one dropdown to work, you will have to add the `dropdown-toggler.js` script to your html body.
50+
51+
```html
52+
<script src="js/dropdown-toggler.js"></script>
53+
```
54+
55+
After that you can go on with adding a submenu.<br>
56+
The structure of the submenu is equal to the structure of
57+
default dropdown menu. Just change the class to `dropdown-submenu`.
58+
59+
```html
60+
<div class="dropdown-submenu">
61+
<div class="dropdown-menu-item">Item 3</div>
62+
<div class="dropdown-menu-item">Item 4</div>
63+
</div>
64+
```
65+
66+
Your submenu is hidden now.<br>
67+
To make them callable, you will need to add an id to every menu (Look main example).
68+
69+
Check out the <a href="./scripts.md">script documentation</a> to learn how to toggle between the different menus of the dropdown.

documentation/scripts.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,30 @@ Just add this to the bottom of your HTML body.
2323
<script src="<pathToJsFolder>/sidebar-toggler.js"></script>
2424
```
2525

26+
# Dropdown script
2627

28+
Use the `dropdown-toggler.js` script if you want to switch between different menus in your dropdown.
29+
30+
```html
31+
<script src="<pathToJsFolder>/dropdown-toggler.js"></script>
32+
```
33+
34+
Now you can use the script to switch between the menus.
35+
36+
There are two different functions you can use.
37+
38+
`DropdownForwardMenu`
39+
You can use this function to switch to a new sub menu.
40+
Its syntax is quite easy.
41+
```js
42+
DropdownForwardMenu('from', 'to');
43+
```
44+
Just call the function and replace the string parameters with the ids of the menus, you want to switch.
45+
46+
Same with the `DropdownBackwardMenu` function.
47+
48+
```js
49+
DropdownBackwardMenu('from', 'to');
50+
```
51+
52+
Its usage is the same as the usage of the `DropdownForwardMenu` function.

main.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,6 @@
7171
@include cardTheme(card-dark, #161616, rgba(0,0,0,0.6), #fff);
7272

7373
// Dropdown
74+
@include dropdownTheme(dropdown-light, rgb(221, 221, 221), #000);
75+
@include dropdownTheme(dropdown-grey, rgb(153, 153, 153), #fff);
7476
@include dropdownTheme(dropdown-dark, #232323, #fff);

0 commit comments

Comments
 (0)