Toggle menu - animate height - zurb-foundation

How to make a dropdown .top-bar? Foundation hides it by display: none; and i can't use transition height.
Below header structure
<div class="title-bar" data-responsive-toggle="example-animated-menu" data-hide-for="large">
<div class="toggle-button"><button class="menu-icon" type="button" data-toggle></button></div>
<div class="title-bar-title show-for-sr" >Menu</div>
</div>
<nav class="top-bar navigation" id="example-animated-menu">
<div class="dropdown menu navigation-list" data-dropdown-menu >
<ul id="menu-menu " class="menu algin-right vertical medium-horizontal" data-responsive-menu="drilldown medium-dropdown" data-auto-height="true" data-animate-height="true">
<li>X</li>
<li>X</li>
<li>X</li>
<li>X</li>
<li>X</li>
<li>X</li>
</ul>
</div>
<form class="search">
<div class="grid-x grid-padding-x">
<div class="small-9 cell">
<input type="text" id="middle-label" placeholder="Search">
</div>
<div class="small-3 cell">
<label for="middle-label" class="text-left middle"><img src="img/ico-search.png" alt="#" /></label>
</div>
</div>
</form>
</nav>

You can display the .top-bar as a child of .dropdown-pane and then override the display: none; with display: block.
Then simply add a max-height transition to the .top-bar going from 0 to the height of your choice.
HTML:
<div class="dropdown-pane"
id="example-animated-menu"
data-dropdown
data-position="bottom"
data-alignment="bottom"
data-v-offset="40px">
<nav class="top-bar navigation" ></nav>
</div>
CSS:
.dropdown-pane {
width: 100%;
padding: 0;
display: block;
max-height: 0;
-webkit-transition: all 0.11s ease;
transition: all 0.11s ease;
}
.top-bar {
max-height: 0;
overflow: hidden;
}
.is-open .top-bar {
max-height: 76px;
-webkit-transition: max-height 0.5s ease;
transition: max-height 0.5s ease;
overflow: hidden;
}
See a JSFiddle demo

Related

Django show image button not functioning with for loop

My site allows users to upload bulk images. The issue is when a user is on mobile they could potentially have to scroll through 100's of images. I want to implement a show more button.
I found this demo online that I got to work
html:
<div class="container">
<div class="grid">
<div class="cell">
<img src="https://i.natgeofe.com/n/3861de2a-04e6-45fd-aec8-02e7809f9d4e/02-cat-training-NationalGeographic_1484324.jpg" class="book" />
</div>
<div class="cell">
<img src="https://i.natgeofe.com/n/3861de2a-04e6-45fd-aec8-02e7809f9d4e/02-cat-training-NationalGeographic_1484324.jpg" class="book" />
</div>
</div>
</div>
<button onclick={showMore()}>Show all books</button>
<script>
const showMore = () => {
document.querySelectorAll('.cell').forEach(c => c.style.display = 'block')
}
</script>
css:
#media screen and (min-width: 600px) {
.container{
overflow: auto;
height: (70vh);
}
.grid {
display: flex;
flex-wrap: wrap;
flex-direction: row;
}
.cell {
width: calc(50% - 2rem);
}
}
.cell {
margin: 1rem;
}
button {
display: none;
}
#media screen and (max-width: 600px) {
.cell {
display: none;
}
.cell:first-child {
display: block;
}
button {
display: inline-block;
}
}
However when I use the same code just with a for loop to display it does not work and just displays all the images.
<div class="container">
<div class="grid">
{% for images in postgallery %}
<div class="cell">
<img src="{{ images.images.url }}" class="book" />
</div>
{% endfor %}
</div>
</div>
<button onclick="{showMore()}">Show all books</button>
<script>
const showMore = () => {
document.querySelectorAll(".cell").forEach((c) => (c.style.display = "block"));
};
</script>

ApexCharts.js Line Chart - Display percent from total in tooltip

I want to display percent instead of an integer.
Now it simply shows the value as integer when hovering on the data point of the chart (the tooltip).
I think I need to set in the formatter formula like this:
let test = value / SUM(all_values)
return test.toFixed(0) + '%'
But, I could not find it in their documentation, the best I found is this one which always gives me 100%, per every data point:
tooltip: {
y: {
formatter: function(value, opts) {
let percent = opts.w.globals.seriesPercent[opts.seriesIndex][opts.dataPointIndex];
return percent.toFixed(0) + '%'
}
}
}
You're right that you'll need to use the tooltip formatter, but the array you're using to get the percentage values isn't correct.
If you log the values opts.w.globals.seriesPercent you'll find that it's all 100's:
[[100, 100, 100, ..., 100]]
(I suspect this might be because it's intended to be used with other chart types.)
You can still get the percentage though, it'll just need to be worked out.
Using your same method to format the tooltip, but getting the values from opts.series instead:
tooltip: {
y: {
formatter: function(value, opts) {
const sum = opts.series[0].reduce((a, b) => a + b, 0);
const percent = (value / sum) * 100;
return percent.toFixed(0) + '%'
},
},
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="app/app.js"></script>
<script>
let apiLabels = [];
let apiData = [];
let currentTimestamp = (Math.floor(Date.now() / 1000)).toString();
//use this URL for daily fetch
//let url = "https://aave-api-v2.aave.com/data/rates-history?reserveId=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480xb53c1a33016b2dc2ff3653530bff1848a515c8c5&resolutionInHours=24&from="+currentTimestamp;
let url = "https://aave-api-v2.aave.com/data/rates-history?reserveId=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480xb53c1a33016b2dc2ff3653530bff1848a515c8c5&resolutionInHours=24&from=1639813032";
// months list
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
// fetch from api
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
let myData = JSON.parse(this.responseText);
console.log(myData);
for (let i = 0; i < myData.length; i++) {
//let formedDate = (myData[i]['x']['year']+'-'+myData[i]['x']['month']+'-'+myData[i]['x']['date']).toString();
let formedDate = monthNames[myData[i]['x']['month']] + ' ' + myData[i]['x']['date'];
console.log(formedDate);
let formedLiquidData = (myData[i]['liquidityRate_avg'] * 100).toFixed(2);
console.log(formedLiquidData+"%");
apiLabels.push(formedDate);
apiData.push(formedLiquidData);
}
const data = {
labels: apiLabels,
datasets: [
{
label: "USDC",
borderColor: "rgb(180,11,107)",
data: apiData
}
]
};
const config = {
type: "line",
data: data,
options:{
scales: {
y: {
ticks: {
callback: function (value, index, values) {
return value + '%';
}
}
},
},
},
};
const myChart = new Chart(document.getElementById("myChart"), config);
}
});
xhr.open(
"GET",
url
);
xhr.send();
</script>
</div>
<div id="app"></div>
<title>brew</title>
<style>
body {
background-color: white;
}
.center-form {
width: 80%;
margin: auto;
}
#title {
color: teal;
text-align: center;
}
.waitlist {
position: relative;
z-index: 3;
width: 146px;
height: 30px;
margin-top: 60px;
border-style: solid;
border-width: 1px;
border-color: #081852;
background-color: transparent;
box-shadow: -10px 10px 0 0 #081852;
color: #081852;
font-size: 12px;
line-height: 30px;
font-weight: 400;
text-align: center;
letter-spacing: 0.21px;
position: fixed;
right: 3%;
top: -5%;
}
.waitlist-button {
display: inline-block;
padding: 9px 15px;
background-color: #3898EC;
color: white;
border: 0;
line-height: inherit;
text-decoration: none;
cursor: pointer;
border-radius: 0;
}
.box-prices {
padding: 20px;
width: 200px;
height: auto;
color: #000;
/* background-color: #fff; */
border: 4px solid #1c1c53;
border-radius: 2px;
}
.dropbtn {
background-color: navy;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #ddd;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #0b95f1;
}
footer {
display: flex;
justify-content: space-between;
}
.myChart {
width: 50%;
height: 40px;
}
/* Decorative */
a {
text-decoration: none;
color: #555;
}
footer {
background-color: #82cdf8;
padding: 20px 40px;
}
.right {
float: left;
text-align: center;
}
.article {
color: white;
}
</style>
</head>
<body>
<img src="https://uploads-ssl.webflow.com/61768faf04d20bf3487b5a2a/6176a6363e64b8d84e32d0b7_brew-icon-256px-v2.png"
loading="eager" width="55" height="55" alt="Brew" class="img-logo" position="absolute" top="-3%" left="7;">
<!-------------- title------------------------>
<div class="container">
<div class="row">
<div class="col-md-12 mt-2">
<h1 style="color: #1c98">
Stablecoin Deposits on Aave
</h1>
<a data-w-id="14f1dfb2-926f-581f-7faa-3f62171b1db3" href="" class="waitlist waitlist-button">Join the
waitlist</a>
</div>
</div>
</div>
<!------------------------AAVE PRICE ------------>
<div class="container">
<div class="row mt-5">
<div class="col-md-6">
<div class="aave-prices">
<p>AAVE PRICE</p>
<p>$172.8</p>
<p>16%</p>
</div>
</div>
<!------------------------AAVE DESCRIPTION ------------>
<div class="col-md-6">
<h1>What is AAVE ?</h1>
<p>Aave is an open source and non-custodial liquidity protocol for earning
interest on deposits and borrowing assets.</p>
</div>
</div>
<!------------------------AAVe CHAIN ------------>
<div class="row">
<div class="col-md-12 mt-3">
<button class="dropbtn">CHAIN</button>
<div class="dropdown-content">
Polygon
Ethereum
Avalance
</div>
</div>
</div>
</div>
<!------graph----->
<div>
<canvas id="myChart" height="50" weidth="50"></canvas>
</div>
<!-- calculator -->
<div class="container mt-5" style="border: 1px solid black; border-radius: 5px;">
<div class="row">
<div class="col-md-12">
<h1 id="title">How Much You Can Earn ?</h1>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<form>
<div class="form-group mt-2">
<label class="form-group">Amount</label>
<input class="form-control mt-2" type="text" id="principal" placeholder="$">
</div>
<div class="form-group mt-2">
<label class="form-group">Interest rate: 4%</label>
</div>
<div class="form-group mt-2">
<label class="form-group">Compound Freequency: Daily</label>
</div>
<div class="form-group mt-2">
<label class="form-group">Payout Freequency: Monthly</label>
</div>
<button class="btn btn-block btn-info mt-3" type="button" onclick="calculate()">Calculate</button>
</form>
</div>
<div class="col-md-6">
<form style="padding-top: 70px;">
<div class="form-group mt-2">
<label class="form-group">Interest rate: 5%</label>
</div>
<div class="form-group mt-2">
<label class="form-group">Compound Freequency: Daily</label>
</div>
<div class="form-group mt-2">
<label class="form-group">Payout Freequency: Monthly</label>
</div>
</form>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<h5 class="total">Result USD</h5>
<h1 id="USD"></h1>
</div>
<div class="col-md-6">
<h5 class="total">Result USDT</h5>
<h1 id="USDC"></h1>
</div>
</div>
</div>
<!-- calculator end -->
<div>
<canvas id="myChart_subbagain" height="50" weidth="50" top="80%"></canvas>
</div>
<!----footer-->
<div class="col-md-12 mt-5">
<footer>
<div class="col-md-6">
<img src="/dawnload.png" alt="" width="150">
</div>
<div class="col-md-6">
<section class="right">
Join Brew Today
<article>USDC is not a legal tender recognised by US or any other government. Unlike a bank account, your
deposit is not insured. While Brew will make every effort to ensure that your deposit earn the best interest
rates in the most secure way possible, please note that any investment entails risk. Interest Rates are
subject to change anytime as per the market conditions.</article>
</section>
</div>
</footer>
</div>
</body>
<script type="text/javascript">
function calculate() {
var principle = 0;
var interest = 5 / 100;
var numberOfPeriod = 12;
var time = 10;
var CI = 0;
principle = document.getElementById("principal").value;
// CI = ((p * (1 + i) ^ n) - p);
CI = principle * (1 + interest / numberOfPeriod) ^ (numberOfPeriod * time);
document.getElementById("USD").innerHTML = CI;
document.getElementById("USDC").innerHTML = CI;
}
</script>
<!------cal graph-->
</html>

I need to display a python array in angular

This is the array
[
{
"TO":"test#gmail.com",
"FROM":"nathanoluwaseyi#gmail.com",
"SUBJECT":"subject 1",
"NAME":"Oluwaseyi Oluwapelumi",
"MESSAGE-DATE":[
[
"Hey eniayomi heeyyy",
"2019-12-03 20:49:07"
]
]
},
{
"TO":"test#gmail.com",
"FROM":"pelz#gmail.com",
"SUBJECT":"Thanks for contacting R",
"NAME":"",
"MESSAGE-DATE":[
[
"Thanks for contacting me! Once i check my email, i shall definitely get back.",
"2019-08-18 19:48:10"
],
[
"will check it.",
"2019-08-18 19:48:10"
]
]
}
]
i need it to display on the angular frontend.
this is the mail.component.html file
<div class="card-body p-0">
<div class="float-left" style="width: 330px; height: 430px; border-right: 1px solid #dad9d9; overflow-x: hidden; overflow-y: auto;">
<div class="p-2 profile-card" style="width: 315px; height: 100px; border-bottom: 1px solid #dad9d9;" *ngFor="let mail of dataservice.data; let i = index;" (click)="viewMail(mail.MESSAGE_DATE,mail.FROM,mail.NAME,mail.DATE,i)" [ngClass]="{'highlight': selectedIndex === i}">
<div class="row">
<div class="col-md-3 pt-2">
<div class="rounded-circle shadow" style="background-image: url('images/avt.jpg'); background-repeat: round; height: 70px; width: 70px;">
<div style="height: 20px; width: 20px; border: 3px solid white;" class="rounded-circle bg-success"></div>
</div>
</div>
<div class="col-md-7 p-0 pl-3 pt-4" style="line-height: 12px;">
<p style="font-size:18px;"><b>{{mail.FROM}}</b></p>
<p style="font-size:13px;">{{mail.NAME }}.</p>
</div>
<div class="col-md-2 p-0 pt-3" style="line-height:11px;">
<p class="text-secondary" style="font-size:12px;">20m <i class="fa fa-star fa-md" aria-hidden="true"></i></p>
</div>
</div>
</div>
this is the data.service.ts file
mail_det() {
this.message = 'Welcome!';
console.log(this.message);
this.staff_email=sessionStorage.getItem('email');
console.log(this.staff_email)
this.http.get(this.domain_protocol + this.f_domain_name+'/api/v1.0/get_user_detail/?id='+this.staff_email)
.subscribe((res) => {
this.data = res
console.log(this.data)
})
}
this is the mail.component.ts file
viewMail(mail, mailer, mailee, user_date, _index: number) {
this.router.navigate(['mail/'+ mailer])
console.log(mail)
console.log(mailer)
console.log(user_date)
this.message = ''
sessionStorage.setItem('mailer', mailer)
sessionStorage.setItem('mailee', mailee);
sessionStorage.setItem('user_date', user_date)
console.log(sessionStorage.getItem('mailer'))
this.user_message = mail;
this.mailee = mailee;
this.user_date = user_date;
this.selectedIndex = _index;
}
i am doing something wrong. The only thing i get to show is the mail.FROM and mail.SUBJECT. I know this is because of the array in the mesage part. I dont know how to go about that.
In Data.service.ts
mail_det() {
this.message = 'Welcome!';
console.log(this.message);
this.staff_email=sessionStorage.getItem('email');
console.log(this.staff_email)
this.http.get(this.domain_protocol + this.f_domain_name+'/api/v1.0/get_user_detail/?id='+this.staff_email);
}
in mail.component.ts
public data: Array<any> = [];
constructor(public dataSrv: DataService <-- this is the class name of the data service you created; import it)
ngOnInit(){
this.dataSrv.mail_det().subscribe(result =>{
console.log(result); <-- your api response;
this.data = result;
}, error => {console.log(error);
});
}
in mail.component.html
<div class="card-body p-0">
<div class="float-left" style="width: 330px; height: 430px; border-right: 1px solid #dad9d9; overflow-x: hidden; overflow-y: auto;">
<div class="p-2 profile-card" style="width: 315px; height: 100px; border-bottom: 1px solid #dad9d9;" *ngFor="let mail of data; let i = index;" (click)="viewMail(mail.MESSAGE_DATE,mail.FROM,mail.NAME,mail.DATE,i)" [ngClass]="{'highlight': selectedIndex === i}">
<div class="row">
<div class="col-md-3 pt-2">
<div class="rounded-circle shadow" style="background-image: url('images/avt.jpg'); background-repeat: round; height: 70px; width: 70px;">
<div style="height: 20px; width: 20px; border: 3px solid white;" class="rounded-circle bg-success"></div>
</div>
</div>
<div class="col-md-7 p-0 pl-3 pt-4" style="line-height: 12px;">
<p style="font-size:18px;"><b>{{mail.FROM}}</b></p>
<p style="font-size:13px;">{{mail.NAME }}.</p>
</div>
<div class="col-md-2 p-0 pt-3" style="line-height:11px;">
<p class="text-secondary" style="font-size:12px;">20m <i class="fa fa-star fa-md" aria-hidden="true"></i></p>
</div>
</div>
</div>

Align icons (on the left) and text (on the right) in a list

I have a list of items. Each item has an icon (fontawesome) on the left and text on the right. Unfortunately I'm not able to align the items.
My CSS and HTML code is:
.colle ul {
margin-left: -20px;
}
.colle ul li {
list-style-type: none;
margin-bottom: 35px;
display: flex;
}
.colle ul li i {
margin-right: 25px;
}
.colle ul li p {
margin: 0;
}
<div class="colle">
<ul>
<li>
<i class="fa fa-black-tie" style="color:#0e3c68;font-size:230%;"></i>
<div style="color: #0e3c68;">
<strong>DIRECTOR: </strong><br> <strong>Francisco </strong><br><div style="color: #0e3c68;font-size:80%;line-height: 12px;">Universidad Francisco de Vitoria</div>
</div></li> </ul>
<li> <i class="fa fa-suitcase" style="color:#0e3c68;font-size:230%;"></i> <div style="color: #0e3c68;">
<strong>COMITÉ CIENTÍFICO ASESOR: </strong><br> <strong>Francisco </strong><br><div style="color: #0e3c68;font-size:80%;line-height: 12px;">Universidad Francisco de Vitoria</div>
</li>
<li> <i class="fa fa-mobile" style="color:#0e3c68;font-size:230%;"></i> <div style="color: #0e3c68;"><strong>CONTACTO: </strong><br> <strong>Francisco</strong><br><div style="color: #0e3c68;line-height: 12px;">9135567 ext. 2115</div> </li>
</div>
(Unfortunately the code snippet can't run the icons) What I'm trying to do is having all perfectly aligned. You can find an image of what I have done up to now. Anyone can help me?
Since you are trying to have two columns, your flex container (the "li") should have two child elements. One should be the (i.fa) icon, and the other should be a container (e.g "div") with all of the info that you want next to the icon.
Then, you need to give at least the icon a fixed width. This is what will align things.
I modified your code to do that, and also replaced your inline styles with classes. That just makes it more maintainable and readable.
See my version here: https://codepen.io/anon/pen/aEzQgM
Here is the code:
.colle ul {
margin-left: -20px;
}
.colle ul li {
list-style-type: none;
margin-bottom: 35px;
display:flex;
}
.colle ul li i.fa {
color:#0e3c68;
font-size:230%;
width:1em;
height:1em;
}
.data1{
color: #0e3c68;
font-weight:bold;
}
.data2{
color: #0e3c68;
font-size:80%;
line-height: 12px;
}
.data3{
color: #0e3c68;
font-size:80%;
line-height: 12px;
}
.colle ul li p {
margin: 0;
}
<div class="colle">
<ul>
<li>
<i class="fa fa-black-tie">x</i>
<div class="data">
<div class="data1">DIRECTOR:</div>
<div class="data2">Francisco</div>
<div class="data3">Universidad Francisco de Vitoria</div>
</div>
</li>
<li>
<i class="fa fa-suitcase">x</i>
<div class="data">
<div class="data1">COMITÉ CIENTÍFICO ASESOR:</div>
<div class="data2">Francisco</div>
<div class="data3">Universidad Francisco de Vitoria</div>
</div>
</li>
<li>
<i class="fa fa-mobile">x</i>
<div class="data">
<div class="data1">CONTACTO:</div>
<div class="data2">Francisco</div>
<div class="data3">9135567 ext. 2115</div>
</div>
</li>
</ul>
</div>
.colle ul li {
list-style-type: none;
margin-bottom: 35px;
display: flex;
align-items: center;
}
align-items: center will align both your flex items vertically center.

Isotope last items in row with equal height

this is my question:
is it possible to set equal heights to last items in row?
My masonry layout is on two columns and I would like to set the last two items with the same height...
UPDATE
This is a simple starting code that I think to use because I haven't yet begun to work on it:
/* ---- js ---- */
jQuery(document).ready(function($) {
var $container = $('#container');
$container.imagesLoaded(function () {
$container.masonry({
isInitLayout: false,
isFitWidth: true
});
$container.masonry('layout');
});
});
/* ---- css ---- */
.wrapper{
margin: 0 auto;
}
#container {
width: 100%;
height: 1200px;
background: #DDD;
margin: 0 auto;
}
#container:after {
content: '';
display: block;
clear: both;
}
.item {
float: left;
width: 500px;
background: #0D8;
border-color: hsla(0, 0%, 0%, 0.7);
}
.item img{
max-width: 100%;
}
<!-- ---- html ---- -->
<div class="wrapper">
<div id="container">
<div class="item"><img src="img/image1.jpg" width="500" height="200" alt="" /></div>
<div class="item"><img src="img/image2.jpg" width="500" height="450" alt="" /></div>
<div class="item"><img src="img/image3.jpg" width="500" height="300" alt="" /></div>
<div class="item"><img src="img/image4.jpg" width="500" height="260" alt="" /></div>
<div class="item"><img src="img/image5.jpg" width="500" height="500" alt="" /></div>
<div class="item"><img src="img/image6.jpg" width="500" height="420" alt="" /></div>
<div class="item"><img src="img/image7.jpg" width="500" height="260" alt="" /></div>
<div class="item"><img src="img/image8.jpg" width="500" height="430" alt="" /></div>
</div>
</div>
Thank you.
Fabio