Skip to content

Commit

Permalink
erge branch 'master' of https://github.com/tlienart/Franklin.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
tlienart committed Oct 24, 2021
2 parents 63d757f + 58e242c commit d5fd301
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 0 deletions.
29 changes: 29 additions & 0 deletions demos/_css/extras.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,32 @@ pre {
outline: 0;
background-color: #eee9e6;
}


/* Collapsible section example */
/* Style the button that is used to open and close the collapsible content */
.collapsible {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: inherit;
}

/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
.active, .collapsible:hover {
background-color: #ccc;
}

/* Style the collapsible content. Note: hidden by default */
.collapsiblecontent {
padding: 0 18px;
display: none;
overflow: hidden;
background-color: #f1f1f1;
}
/* End collapsible section example */
19 changes: 19 additions & 0 deletions demos/_layout/page_foot.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,22 @@
&copy; {{ fill author }}. {{isnotpage /tag/*}}Last modified: {{ fill fd_mtime }}.{{end}} Website built with <a href="https://github.com/tlienart/Franklin.jl">Franklin.jl</a>.
</div>
</div>

<!-- Collapsible button example -->
<script>
var coll = document.getElementsByClassName("collapsible");
var i;

for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
</script>
<!-- End collapsible button example -->
77 changes: 77 additions & 0 deletions demos/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,83 @@ The ordering is reverse chronological but just use the table of contents to guid

\toc

## (018) collapsible block
How to make a section expand when clicked, so that content is initially hidden? (Based on [this html guide](https://www.w3schools.com/howto/howto_js_collapsible.asp).)

\newcommand{\collaps}[2]{
~~~<button type="button" class="collapsible">~~~ #1 ~~~</button><div class="collapsiblecontent">~~~ #2 ~~~</div>~~~
}
\collaps{We first define a command, `\collaps{title}{content}`, allowing both the title and the content to be given as markdown and processed by Franklin}{
```html
\newcommand{\collaps}[2]{
~~~<button type="button" class="collapsible">~~~ #1 ~~~</button><div class="collapsiblecontent">~~~ #2 ~~~</div>~~~
}
```
}
\collaps{Then, we need to add styling for these classes. Here, we add it to `_css/extras.css`.}{
```css
/* Style the button that is used to open and close the collapsible content */
.collapsible {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: inherit;
}
/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
.active, .collapsible:hover {
background-color: #ccc;
}
/* Style the collapsible content. Note: hidden by default */
.collapsiblecontent {
padding: 0 18px;
display: none;
overflow: hidden;
background-color: #f1f1f1;
}
```
}
\collaps{Finally, we need the javascript that can be added either on the page where it is used, or in e.g. the foot `_layout/page_foot.html`}{
```html
<script>
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
</script>
```
}
With these definitions, the expandible code sections could be added!
\collaps{An additional example: **Press here to expand**}{In the content part you can have latex: $x^2$,
lists
* Item 1
* Item 2
And all other stuff processed by Franklin!
}
## (017) making cells work in their own path
Currently if you're saving a figure in a code block, you need to specify where to place that figure, if you don't it will go in the current directory which is the main site directory, typically you don't want that, so one trick is to use the `@OUTPUT` macro like so:
Expand Down

2 comments on commit d5fd301

@tlienart
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/47409

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.61 -m "<description of version>" d5fd301a5c191114a2661a4411601d3ead5001fe
git push origin v0.10.61

Please sign in to comment.