JSFiddle - React, Tailwind, and code Playground
by luchaninov
HTML
<script src="https://raw.github.com/YuriyLuchaninov/tagjs/master/tag.js"></script>
<script src="https://raw.github.com/YuriyLuchaninov/tagjs/master/examples/toggle/toggle.js"></script>
<toggle id="toggle1">
<toggle-page>
<toggle-header class='header-style'>
Title (attached events on content)
</toggle-header>
<toggle-content>
<button id="alert">Alert</button>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam.
</toggle-content>
</toggle-page>
<toggle-page>
<toggle-header class='header-style'>
Title
</toggle-header>
<toggle-content>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
</toggle-content>
</toggle-page>
<toggle-page>
<toggle-header class='header-style'>
Title (subtoggle)
</toggle-header>
<toggle-content>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
<toggle>
<toggle-page>
<toggle-header class='header-style'>
Title
</toggle-header>
<toggle-content>
Mauris.
</toggle-content>
</toggle-page>
...
CSS
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
body {
font: 14px/20px 'Arial';
color: #333;
margin: 20px auto;
width: 600px;
}
ul{
margin: 0;
padding: 0;
list-style: none;
}
.menu a{
color: #333;
display: block;
padding:5px 10px;
text-decoration: none;
}
.menu a:hover{
background: rgba(0,0,0,0.1);
}
.content {
padding: 5px 10px;
}
/*components css*/
.transitions {
-webkit-transition: all 0.35s ease-in-out;
-moz-transition: all 0.35s ease-in-out;
-o-transition: all 0.35s ease-in-out;
-ms-transition: all 0.35s ease-in-out;
transition: all 0.35s ease-in-out;
}
.toggle .toggle-content {
overflow: hidden;
max-height: 0;
opacity: 0;
}
/*styles*/
.header-style{
padding: 10px;
font-weight: bold;
color: #172c47;
cursor: pointer;
text-shadow: 1px 1px 0 #3e88cb, 0 0 1px #31659a, 0 0 1px #31659a;
background: #429ee5;
background: -moz-linear-gradient(top, #429ee5 0%, #1e5799 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#429ee5), color-stop(100%,#1e5799));
background: -webkit-linear-gradient(top, #429ee5 0%,#1e5799 100%);
background: -o-linear-gradient(top, #429ee5 0%,#1e5799 100%);
background: -ms-linear-gradient(top, #429ee5 0%,#1e5799 100%);
background: linear-gradient(to bottom, #429ee5 0%,#1e5799 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#429ee5', endColorstr='#1e5799',GradientType=0 );
}
.toggle-content .inner{
padding: 10px;
}
.toggle>div{ background: #fff; }
.toggle>div:nth-child(odd){ background: #f0f0f0; }
.toggle .toggle{
margin-top: 20px;
}
JavaScript
$('#alert').on('click', function(e) {
alert(e.currentTarget);
});
//apply components
$TB.apply($('#toggle1').get(0));