Skip to content

Commit

Permalink
Merge pull request #43 from turingschool/dropdowns
Browse files Browse the repository at this point in the history
add simple dropdown
  • Loading branch information
memcmahon authored May 10, 2024
2 parents aa9c35f + 10abbb1 commit 6b7c76c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
15 changes: 14 additions & 1 deletion _sass/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
border: none;
}

.answer {
.dropdown {
@extend %call-to-action-shared;
border-left: 8px solid #CCC;

Expand All @@ -77,3 +77,16 @@
transform: rotate(90deg);
transition: transform 0.2s ease;
}

.expander-arrow {
cursor: pointer;
transform: rotate(0deg);
transition: transform 0.2s ease;
height: 15px;
width: 15px;
}

.expander-arrow.expanded {
transform: rotate(90deg);
transition: transform 0.2s ease;
}
Binary file added assets/images/dropdown-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions public/js/expander.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
console.log("in expander.js")
$('.answer > h3').each(function(idx, title) {
$('.dropdown > h3').each(function(idx, title) {
const titleText = $(title).text();
$(title).replaceWith(`<h3><img class="expander-arrow" src="/assets/images/arrow.svg" alt="expander arrow" /> ${titleText}</h3>`);
});

$('.answer > h3').nextAll().hide();
$('.dropdown > h3').nextAll().hide();

$('.answer > h3').on('click', function() {
$('.dropdown > h3').on('click', function() {
let arrowEl = $(this).find('img.expander-arrow');

if (!arrowEl.hasClass('expanded')) {
Expand Down
17 changes: 17 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ The `today.html` file is where you will find the basic html page for today, and

## Some handy tips for editing/creating content

### Creating Dropdowns

To create a dropdown like this:

![screenshot of dropdown format](./assets/images/dropdown-example.png)

Use the following structure:

```
<section class="dropdown">
### Test Dropdown - this must be a <h3>
test content
</section>
```

### Headers in your markdown files

Put something like this at the top of all your markdown files:
Expand Down

0 comments on commit 6b7c76c

Please sign in to comment.