-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
214 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# v2.2.0 | ||
## 03/02/2017 | ||
|
||
1. [](#new) | ||
* Added new `accordian` shortcode | ||
|
||
# v2.1.0 | ||
## 02/25/2017 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.accordian-wrapper { | ||
margin: 30px 0; | ||
text-align: left; } | ||
.accordian-wrapper label { | ||
position: relative; | ||
z-index: 20; | ||
display: block; | ||
cursor: pointer; | ||
color: #777; | ||
font-size: 110%; | ||
background: #f9f9f9; | ||
margin: 0; | ||
padding: 3px 15px; | ||
border: 1px solid #eee; | ||
border-bottom: 1px solid transparent; } | ||
.accordian-wrapper label:hover { | ||
background: #eee; | ||
color: #444; } | ||
.accordian-wrapper label:hover:after, .accordian-wrapper input:checked + label:hover:after { | ||
opacity: 0.3; | ||
content: ''; | ||
position: absolute; | ||
width: 30px; | ||
height: 20px; | ||
right: 15px; | ||
top: 7px; | ||
background: transparent url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiB3aWR0aD0iNDgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE0LjgzIDE2LjQybDkuMTcgOS4xNyA5LjE3LTkuMTcgMi44MyAyLjgzLTEyIDEyLTEyLTEyeiIvPjxwYXRoIGQ9Ik0wLS43NWg0OHY0OGgtNDh6IiBmaWxsPSJub25lIi8+PC9zdmc+) no-repeat center center; } | ||
.accordian-wrapper input:checked + label:hover:after { | ||
-ms-transform: rotate(180deg); | ||
-webkit-transform: rotate(180deg); | ||
transform: rotate(180deg); } | ||
.accordian-wrapper input { | ||
display: none; } | ||
.accordian-wrapper article { | ||
background: rgba(255, 255, 255, 0.5); | ||
overflow: hidden; | ||
max-height: 0px; | ||
position: relative; | ||
z-index: 10; | ||
transition: max-height 0.3s ease-in-out; | ||
border: 1px solid #eee; | ||
border-top: 0; | ||
border-bottom: 0; | ||
padding: 0 15px; } | ||
.accordian-wrapper input:checked ~ article { | ||
max-height: 500px; } | ||
.accordian-wrapper input:checked + label { | ||
border-bottom: 1px solid #eee; } | ||
.accordian-wrapper > div:last-child label, .accordian-wrapper > div:last-child input:checked ~ article { | ||
border-bottom: 1px solid #eee; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
.accordian-wrapper { | ||
margin: 30px 0; | ||
text-align: left; | ||
|
||
label { | ||
position: relative; | ||
z-index: 20; | ||
display: block; | ||
cursor: pointer; | ||
color: #777; | ||
font-size: 110%; | ||
background: #f9f9f9; | ||
margin: 0; | ||
padding: 3px 15px; | ||
border: 1px solid #eee; | ||
border-bottom: 1px solid transparent; | ||
|
||
&:hover { | ||
background: #eee; | ||
color: #444; | ||
} | ||
} | ||
|
||
label:hover:after, input:checked + label:hover:after { | ||
opacity: 0.3; | ||
content: ''; | ||
position: absolute; | ||
width: 30px; | ||
height: 20px; | ||
right: 15px; | ||
top: 7px; | ||
background: transparent url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiB3aWR0aD0iNDgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE0LjgzIDE2LjQybDkuMTcgOS4xNyA5LjE3LTkuMTcgMi44MyAyLjgzLTEyIDEyLTEyLTEyeiIvPjxwYXRoIGQ9Ik0wLS43NWg0OHY0OGgtNDh6IiBmaWxsPSJub25lIi8+PC9zdmc+) no-repeat center center; | ||
} | ||
|
||
input:checked + label:hover:after { | ||
-ms-transform: rotate(180deg); | ||
-webkit-transform: rotate(180deg); | ||
transform: rotate(180deg); | ||
} | ||
|
||
input { | ||
display: none; | ||
} | ||
|
||
article { | ||
background: rgba(255, 255, 255, 0.5); | ||
overflow: hidden; | ||
max-height: 0px; | ||
position: relative; | ||
z-index: 10; | ||
transition: max-height 0.3s ease-in-out; | ||
border: 1px solid #eee; | ||
border-top: 0; | ||
border-bottom: 0; | ||
padding: 0 15px; | ||
} | ||
|
||
input:checked ~ article{ | ||
max-height: 500px; | ||
} | ||
|
||
input:checked + label { | ||
border-bottom: 1px solid #eee; | ||
} | ||
|
||
> div:last-child { | ||
label, input:checked ~ article { | ||
border-bottom: 1px solid #eee; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Grav\Plugin\Shortcodes; | ||
|
||
use Thunder\Shortcode\Shortcode\ShortcodeInterface; | ||
|
||
|
||
class AccordianShortcode extends Shortcode | ||
{ | ||
public function init() | ||
{ | ||
$this->shortcode->getHandlers()->add('ui-accordian', function(ShortcodeInterface $sc) { | ||
|
||
// Add assets | ||
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-accordian.css'); | ||
|
||
$hash = $this->shortcode->getId($sc); | ||
|
||
$independent = filter_var($sc->getParameter('independent', false), FILTER_VALIDATE_BOOLEAN); | ||
|
||
$output = $this->twig->processTemplate('partials/ui-accordian.html.twig', [ | ||
'hash' => $hash, | ||
'open' => $sc->getParameter('open'), | ||
'type' => $independent ? 'checkbox' : 'radio', | ||
'accordian_items' => $this->shortcode->getStates($hash), | ||
]); | ||
|
||
return $output; | ||
}); | ||
|
||
$this->shortcode->getHandlers()->add('ui-accordian-item', function(ShortcodeInterface $sc) { | ||
// Add accordian to accordian state using parent accordian id | ||
$hash = $this->shortcode->getId($sc->getParent()); | ||
$this->shortcode->setStates($hash, $sc); | ||
return; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="accordian-wrapper"> | ||
{% for key,item in accordian_items %} | ||
{% set checked = (open != 'none' and loop.index0 == open or (type == 'checkbox' and open == 'all')) %} | ||
<div> | ||
<input id="{{ hash ~ key }}" name="{{ hash }}" type="{{ type }}" {{ checked ? 'checked="checked"' : ''}} /> | ||
<label for="{{ hash ~ key }}">{{ item.getParameter('title') }}</label> | ||
<article>{{ item.getContent()|raw }}</article> | ||
</div> | ||
{% endfor %} | ||
</div> |