Skip to content

Commit 0209880

Browse files
committed
Merge pull request algorithm-visualizer#146 from nem035/side-menu-improvement
Side menu improvement
2 parents 6851227 + 3a62ecc commit 0209880

File tree

8 files changed

+40
-25
lines changed

8 files changed

+40
-25
lines changed

css/stylesheet.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ button.indent {
156156
padding-left: 28px;
157157
}
158158

159-
button.collapse {
159+
.algorithms {
160+
box-shadow: inset 0 2px 2px rgba(0,0,0,0.36),inset 0 -2px 2px rgba(0,0,0,0.24);
161+
}
162+
163+
.algorithms.collapse {
160164
display: none;
161165
}
162166

@@ -577,4 +581,4 @@ button[disabled] {
577581
@-o-keyframes line_highlight {
578582
from { background: rgba(255, 0, 0, .1); }
579583
to { background: rgba(255, 0, 0, .3); }
580-
}
584+
}

js/dom/add_categories.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const {
88
each
99
} = $;
1010

11-
const addAlgorithmToCategoryDOM = (category, subList, algorithm) => {
12-
const $algorithm = $('<button class="indent collapse">')
11+
const getAlgorithmDOM = (category, subList, algorithm) => {
12+
return $('<button class="indent collapse">')
1313
.append(subList[algorithm])
1414
.attr('data-algorithm', algorithm)
1515
.attr('data-category', category)
@@ -35,17 +35,21 @@ const addCategoryToDOM = (category) => {
3535
.attr('data-category', category);
3636

3737
$category.click(function () {
38-
$(`.indent[data-category="${category}"]`).toggleClass('collapse');
39-
$(this).find('i.fa').toggleClass('fa-caret-right fa-caret-down');
38+
const $self = $(this);
39+
$self.toggleClass('open');
40+
$self.next().toggleClass('collapse');
41+
$self.find('i.fa').toggleClass('fa-caret-right fa-caret-down');
4042
});
4143

42-
$('#list').append($category);
44+
const $algorithms = $('<div class="algorithms collapse">');
45+
$('#list').append($category).append($algorithms);
4346

4447
each(categorySubList, (algorithm) => {
45-
addAlgorithmToCategoryDOM(category, categorySubList, algorithm);
48+
const $algorithm = getAlgorithmDOM(category, categorySubList, algorithm);
49+
$algorithms.append($algorithm);
4650
});
4751
};
4852

4953
module.exports = () => {
5054
each(app.getCategories(), addCategoryToDOM);
51-
};
55+
};

public/algorithm_visualizer.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,11 @@ button.indent {
273273
padding-left: 28px;
274274
}
275275

276-
button.collapse {
276+
.algorithms {
277+
box-shadow: inset 0 2px 2px rgba(0,0,0,0.36),inset 0 -2px 2px rgba(0,0,0,0.24);
278+
}
279+
280+
.algorithms.collapse {
277281
display: none;
278282
}
279283

@@ -691,4 +695,4 @@ button[disabled] {
691695

692696
/* Internet Explorer */
693697

694-
/* Opera < 12.1 */
698+
/* Opera < 12.1 */

public/algorithm_visualizer.js

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/algorithm_visualizer.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/algorithm_visualizer.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/algorithm_visualizer.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/algorithm_visualizer.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)