Work with templates as frontend developer - html

I have accepted a job, in which I have to work on some html and css in frontend. However, the files I was given to work with seem to be interpreted by some kind of interpreter (I think Flask with Jinja2). All I have however are frontend files and I cannot figure out, how to debug my code without any interpreter.
F:.
├───static
│ ├───css
│ └───images
│ └───navigation
└───templates
├───admin
├───cart
├───home
├───order
├───partials
├───payment
├───product
├───ticket
└───user
above I have listed the folders I have to work with. Each folder only contains html files, that look like this for example:
<input id="navi-open" type="checkbox" name="" class="ct" />
<div id="navigation" class="column">
<label for="navi-open" class="navi-button">
<img src="{{ url_for('static', filename='images/cancel.png') }}" alt="" />
</label>
<div id="navigation-items" class="column h-sb">
<div class="category">
<a href="{{ url_for('home.home') }}" style="opacity:1"
class="navigation-item light {{ 'active' if current_page == 'homepage' else '' }}">
<div style="opacity:1" class="icon">
<img src="{{ url_for('static', filename='images/karma_blackwhite.png') }}" alt=""
style="filter: invert(0);" />
</div>
<div class="label">Homepage</div>
<div class="tooltip">Homepage</div>
<div class="indicator"></div>
</a>
<a href="{{ url_for('home.news') }}" class="navigation-item {{ 'active' if current_page == 'news' else '' }}">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/newspaper.png') }}" alt="" />
</div>
<div class="label">News</div>
<div class="tooltip">News</div>
<div class="indicator"></div>
</a>
<a href="{{ url_for('home.about') }}" class="navigation-item {{ 'active' if current_page == 'about' else '' }}">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/information.png') }}" alt="" />
</div>
<div class="label">About</div>
<div class="tooltip">About</div>
<div class="indicator"></div>
</a>
<a href="{{ url_for('home.reviews') }}"
class="navigation-item {{ 'active' if current_page == 'reviews' else '' }}">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/feedback.png') }}" alt="" />
</div>
<div class="label">Reviews</div>
<div class="tooltip">Reviews</div>
<div class="indicator"></div>
</a>
</div>
{% if current_user.is_authenticated %}
<div class="category">
<a href="{{ url_for('cart.cart') }}" class="navigation-item {{ 'active' if current_page == 'cart' else '' }}">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/shopping-cart.png') }}" alt="" />
</div>
<div class="label">Cart</div>
<div class="tooltip">Cart</div>
<div class="indicator"></div>
</a>
<a href="{{ url_for('ticket.view_all_tickets') }}"
class="navigation-item {{ 'active' if current_page == 'tickets' else '' }}">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/envelope.png') }}" alt="" />
</div>
<div class="label">Tickets</div>
<div class="tooltip">Tickets</div>
<div class="indicator"></div>
</a>
<a href="{{ url_for('user.notifications') }}" num="{{ current_user.notifications|length }}"
class="navigation-item {{ 'active' if current_page == 'notifications' else '' }}">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/chat-2.png') }}" alt="" />
</div>
<div class="label">Notifications</div>
<div class="tooltip">Notifications</div>
<div class="indicator"></div>
</a>
<a href="{{ url_for('order.view_all_orders') }}"
class="navigation-item {{ 'active' if current_page == 'orders' else '' }}">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/package-6.png') }}" alt="" />
</div>
<div class="label">Orders</div>
<div class="tooltip">Orders</div>
<div class="indicator"></div>
</a>
</div>
<div class="category">
<a href="{{ url_for('user.profile') }}"
class="navigation-item {{ 'active' if current_page == 'settings' else '' }}">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/settings.png') }}" alt="" />
</div>
<div class="label">Settings</div>
<div class="tooltip">Settings</div>
<div class="indicator"></div>
</a>
<a href="{{ url_for('user.logout') }}" class="navigation-item">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/logout.png') }}" alt="" />
</div>
<div class="label">Logout</div>
<div class="tooltip">Logout</div>
<div class="indicator"></div>
</a>
</div>
{% else %}
<label for="login" class="navigation-item">
<div class="icon">
<img src="{{ url_for('static', filename='images/navigation/login.png') }}" alt="" />
</div>
<div class="label">Login</div>
<div class="tooltip">Login</div>
<div class="indicator"></div>
</label>
{% endif %}
</div>
<input id="login" type="checkbox" name="" class="popup-controller" />
<div class="popup-wrapper">
<label for="login" class="popup-bg"></label>
<div class="popup">
<div class="popup-content">
<form id="auth-container" action="{{ url_for('user.login') }}" method="post">
{{ g.login_form.csrf_token }}
<div class="title-big">Log in to your account</div>
<div class="input-group">
<div class="input-wrapper">
<div class="input-field column"><input type="text" name="username" required="required"
placeholder="Username" />
<div class="input-label required">Username</div>
<div class="input-status"></div>
</div>
</div>
<div class="input-wrapper">
<div class="input-field column"><input type="password" name="password" required="required"
placeholder="Password" />
<div class="input-label required">Password</div>
<div class="input-status"></div>
</div>
</div>
</div>
<div class="action-btns btns row">
<button type="submit" class="button submit">Log in</button>
</div>
<div class="infos row h-sb">
Restore password
Create an account
</div>
</form>
</div>
</div>
</div>
</div>
I don't know how to work with this, if I just need to change frontend code...
Thanks

First of all, congratulations on your new job!
Did you try debugging the company's code using VScode? they have a great tutorial on how to debug python codes, and specifically Django code; Check https://code.visualstudio.com/docs/python/tutorial-django

Related

how to display <div> next to each other within a for loop?(laravel)

I'm working on a alumni portal where I need to display the committee member details. I need to print like 4 members in a line and next 4 in the next line. Any solution would be helpful.
<h2>Member Details</h2>
<div class="jumbotron container">
<div class="pull-right">
<a class="btn btn-primary" data-toggle="modal" id="mediumButton" data-target="#mediumModal" data-attr="{{ route('add_details')}}" title="Add Institute Details"> <i class="fas fa-plus-circle"></i>
</a>
</div>
<div class="container main" id="wrapper">
#foreach ($members as $member)
<div class="img-box">
<pre>
<img src="/uploads/image/{{ $member->image }}" width="100" height="100"/>
{{ $member->id }}<br/>
<a> {{ $member->name }}</a>
<!-- #if(($member->id) >=5 )
<span style="white-space: pre-line">
</span>
#endif
</pre> -->
</div>
#endforeach
</div>
</div>
if you use Bootstrap try this
<div class="row">
#foreach ($members as $member)
<div class="col-md-3">
<div class="img-box">
<pre>
<img src="/uploads/image/{{ $member->image }}" width="100" height="100"/>
{{ $member->id }}<br/>
<a> {{ $member->name }}</a>
</pre>
</div>
</div>
#endforeach
</div>
Add "display:grid;" to the container "div" tag You need to define the property.

HTML form , not responsive while inside a div

I'm creating a web page and if i put my div inside a form it makes it non-responsive but if i put that same form outside the div, everything works just fine.
I wanted to have a div called container-2 and 2 forms inside, one is on the left as you can see and the other one is a card payment method. If i try to resize my screen, the second form goes under the first one because i've set the flex-wrap:wrap; but the first form stays non-responsive.
Here is the code and thanks in advance.
<div class="container-2">
<form method="POST">-
<div class="item" id="payment">
<div class="row">
<h4>Možnost nakupa 1: Plačilo po povzetju <small><i>(Za plačevanje s kartico je treba izbrati samo
količino in vrsto izdelka!)</i></small></h4>
{% csrf_token %}
{% if form %}
<div class="input-group">
<div style="color: red;">{{ form.name.errors }}</div>
{{ form.name }}
</div>
<div class="input-group">
<div style="color: red;">{{ form.last_name.errors }}</div>
{{ form.last_name }}
</div>
<div class="input-group">
<div style="color: red;">{{ form.street_name.errors }}</div>
{{ form.street_name }}
</div>
<div class="input-group">
<div style="color: red;">{{ form.city_name.errors }}</div>
{{ form.city_name }}
</div>
<div class="input-group">
<div style="color: red;">{{ form.email.errors }}</div>
{{ form.email }}
</div>
<div class="input-group">
<div style="color: red;">{{ form.number.errors }}</div>
{{ form.number }}
</div>
{% endif %}
</div>
</div>
<div class="item">
<div class="row">
<div class="input-group">
{{ form.num_elements.errors }}
{{ form.num_elements }}
</div>
<div class="input-group" id="check_div">
<div
style="display: flex;width:100%;justify-content: space-between;align-items: center;font-size:medium;flex-wrap: wrap;">
<div style="display: flex;justify-content: space-between;margin:3px;">
{{ form.select_type.errors }}
{{ form.select_type.label_tag }}
{{ form.select_type }}
</div>
<div style="display: flex;justify-content: space-between;margin:3px;">
{{ form.select_type2.errors }}
{{ form.select_type2.label_tag }}
{{ form.select_type2 }}
</div>
</div>
</div>
<div class="input-group">
{{ form.warning_el.errors }}
{{ form.warning_el }}
</div>
<div style="display: flex;justify-content: space-between;margin: 0.5rem;">
<button class="button" type="submit" id="button"> Naroči <small>(povzetje)</small></button>
<a class="button" id="stripe-button">Plačaj s kartico!</a>
</div>
</div>
</div>
</form>
<div>
<form id="payment-form" data-locale="si">
<div id="payment-element">
<!--Stripe.js injects the Payment Element-->
</div>
<button id="submit" class="button1">
<div class="spinner hidden" id="spinner"></div>
<span id="button-text">Pay now</span>
</button>
<div id="payment-message" class="hidden"></div>
</form>
</div>
</div>
This is container-2.
You can add 100% in with property of your form css:
#payment {
width: 100%;
}

Have liquid syntax include an additional liquid syntax?

I am trying to refactor my site using the D.R.Y. method, part of that is using liquid syntax to help.
Currently everything works with what I have here:
page-internal.html
---
layout: default
<div>
<div class="d-flex" style="background-color: #e9ecef;">
<div class="jumbotron mx-auto mb-0 py-3 px-5" style="max-width: 1200px">
<div class="col-lg-12 p-3 mx-auto">
<img width="50" height="50"
class="rounded-circle float-left mr-2"
src="/assets/img/internal/{{ page.image }}" />
<h1 class="display-4">{{ page.title | escape }}</h1>
<p class="lead">{{ content }}</p>
</div>
</div>
</div>
<div>
<div class="d-flex justify-content-center">
{% include card-post-{{ page.passname }}.html %}
</div>
</div>
</div>
The {{ page.passname }} pulls from a .md file like so:
---
layout: page-internal
title: User Interface
permalink: /pages/design-ui
image: ui.svg
passname: ui
---
That works just fine, too. But then I have to create several pages to pull from instead of just referencing passname to grab the right .md page (I hope I'm making sense here, apologies if I'm not). That page looks like this
card-post.ui.html
And the html on that page is:
<div class="container-fluid">
<div class="col-lg-12 mx-auto row d-flex justify-content-center mt-3" style="max-width: 1400px">
{% for post in site.categories.ui %}
<div class="card col-sm-12 col-lg-3 m-2">
<div class="card-body d-flex flex-column">
<div class="media">
<div class="d-flex mr-3">
<a href="{{ post.url }}">
<img width="40" height="40"
class="rounded-circle"
src="/assets/img/{{ post.image }} " alt="{{ post.title }}" />
</a>
</div>
<div class="media-body">
<h6 class="mb-1">{{ post.title }}</h6>
</div>
</div>
<div class="d-flex flex-column" style="height: 105px;">
<div class="p-2">
<p class="text-muted">{{ post.excerpt }}</p>
</div>
</div>
<div class=" flex-column align-items-end">
<button type="button" class="btn btn-secondary btn-sm btn-block" onclick="location.href = '{{ post.url }}';">View project</button>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
What I'd like to do is take the two html sites and have it like this:
---
layout: default
---
<div>
<div class="d-flex" style="background-color: #e9ecef;">
<div class="jumbotron mx-auto mb-0 py-3 px-5" style="max-width: 1200px">
<div class="col-lg-12 p-3 mx-auto">
<img width="50" height="50"
class="rounded-circle float-left mr-2"
src="/assets/img/internal/{{ page.image }}" />
<h1 class="display-4">{{ page.title | escape }}</h1>
<p class="lead">{{ content }}</p>
</div>
</div>
</div>
<div>
<div class="d-flex justify-content-center">
{% include card-post-{{ page.passname }}.html %}
<div class="container-fluid">
<div class="col-lg-12 mx-auto row d-flex justify-content-center mt-3" style="max-width: 1400px">
{% for post in site.categories.ui %}
<div class="card col-sm-12 col-lg-3 m-2">
<div class="card-body d-flex flex-column">
<div class="media">
<div class="d-flex mr-3">
<a href="{{ post.url }}">
<img width="40" height="40"
class="rounded-circle"
src="/assets/img/{{ post.image }} " alt="{{ post.title }}" />
</a>
</div>
<div class="media-body">
<h6 class="mb-1">{{ post.title }}</h6>
</div>
</div>
<div class="d-flex flex-column" style="height: 105px;">
<div class="p-2">
<p class="text-muted">{{ post.excerpt }}</p>
</div>
</div>
<div class=" flex-column align-items-end">
<button type="button" class="btn btn-secondary btn-sm btn-block" onclick="location.href = '{{ post.url }}';">View project</button>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
This would work however the syntax here:
{% for post in site.categories.ui %}
Needs to be (and this is where I can't figure out what to do)
{% for post in site.categories. {{ page.passname }} %}
This throws an error:
Liquid Warning: Liquid syntax error (line 23): Unexpected character { in "post in site.categories.{{ page.passname }}" in /_layouts/page-internal.html
So my question is, how can I get the passname from said .md post (in this instance it'd be design-ui.md ) and put it into {% for post in site.categories.ui %} where the word ui would be dependint on the .md
I hope I said all this right, apologies if not.
Your loop syntax {% for post in site.categories. {{ page.passname }} %}
is incorrect :
You may reach your category with bracket notation :
{% for post in site.categories[page.passname] %}

How to make columns not dependent on each other with Bootstrap?

There is a menu on the left with the effect of the accordion, on the right content is formed with a jinja. I need to do so that the height of the menu and the contents do not depend on each other.
as here: click
HTML:
<!-- menu -->
<div class="col-md-3">
<div class="wrapper">
<h1 class="header-tabs">Brands</h1>
<div class="tab">
{% for brand in brands %}
<button value="{{ brand.id }}">{{ brand.brand_name }
</button>
{% endfor %}
</div>
</div>
</div>
<!-- content -->
{% for sm in smartphones %}
<div class="col-md-2">
<img class="photo-phone" height="150" width="150" src="{{ sm.photo.url }}">
</div>
<div class="col-md-5">
<h3 class="header-phone">{{ sm.brand }} {{ sm.model }}</h3>
<p descr-phone>{{ sm.description }}</p>
</div>
<div class="col-md-2">
<h4 class="price">{{ sm.price }}$</h4>
<input type="button" class="button-buy" value="Buy">
</div>
{% endfor %}
The usual way to achieve that is by nesting. Nesting must always be done using row-column pairs i.e. never nest a column directly inside another column.
So, in your case, you'd first create a column with the class col-md-9 then put a .row inside that column and then put all your content columns inside that newly created row.
Note that inside this newly created row you now have a total of 12 column units to work with.
Click "run code snippet" below and expand to full page for testing:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
<!-- menu -->
<div class="col-md-3">
<div class="wrapper">
<h1 class="header-tabs">Brands:</h1>
<div class="tab">
<!-- {% for brand in brands %}-->
<button value="{{ brand.id }}">
<!-- {{ brand.brand_name }-->
Brand Name
</button>
<!-- {% endfor %}-->
</div>
</div>
</div>
<!-- content -->
<div class="col-md-9">
<div class="row">
<!-- {% for sm in smartphones %}-->
<div class="col-md-3 mb-3">
<!-- <img class="photo-phone" height="150" width="150" src="{{ sm.photo.url }}">-->
<img class="photo-phone img-fluid" src="https://placeimg.com/640/480/tech">
</div>
<div class="col-md-6">
<h3 class="header-phone">
<!-- {{ sm.brand }} {{ sm.model }}-->
Brand Model
</h3>
<p descr-phone>
<!-- {{ sm.description }}-->
Description
</p>
</div>
<div class="col-md-3 mb-3">
<h4 class="price">
<!-- {{ sm.price }}$-->
$1,000
</h4>
<input type="button" class="button-buy" value="Buy">
</div>
<div class="col-md-3 mb-3">
<!-- <img class="photo-phone" height="150" width="150" src="{{ sm.photo.url }}">-->
<img class="photo-phone img-fluid" src="https://placeimg.com/640/480/tech">
</div>
<div class="col-md-6">
<h3 class="header-phone">
<!-- {{ sm.brand }} {{ sm.model }}-->
Brand Model
</h3>
<p descr-phone>
<!-- {{ sm.description }}-->
Description
</p>
</div>
<div class="col-md-3 mb-3">
<h4 class="price">
<!-- {{ sm.price }}$-->
$1,000
</h4>
<input type="button" class="button-buy" value="Buy">
</div>
<div class="col-md-3 mb-3">
<!-- <img class="photo-phone" height="150" width="150" src="{{ sm.photo.url }}">-->
<img class="photo-phone img-fluid" src="https://placeimg.com/640/480/tech">
</div>
<div class="col-md-6">
<h3 class="header-phone">
<!-- {{ sm.brand }} {{ sm.model }}-->
Brand Model
</h3>
<p descr-phone>
<!-- {{ sm.description }}-->
Description
</p>
</div>
<div class="col-md-3 mb-3">
<h4 class="price">
<!-- {{ sm.price }}$-->
$1,000
</h4>
<input type="button" class="button-buy" value="Buy">
</div>
<!-- {% endfor %}-->
</div>
</div>
</div>
</div>
Also note the use of the spacing class mb-3 (margin-bottom 3 units).
The img-fluid class makes the images responsive.
Reference:
https://getbootstrap.com/docs/4.0/layout/grid/#nesting

unordered list- first list item is raised in position

Does anybody know why the first li item is raised in its position. And it only happens when I add id or class to the div.
Here is code:
<div id="pickList">
<ul *ngFor="let channel of currentPickSelection">
<li class="list-group-item" style="float:Left;margin:1px;" (dragover)="onDragOver(channel[0])" (drop)="onDrop()"
[ngStyle]="{'background-color': channel[0].compChannel[0].compChannelLogo.length !== 0 ? '#8EC0D1' : 'aliceblue' }">
<ng-container *ngIf="channel[0].compChannel[0].compChannelLogo.length !== 0; else noCompChannel">
<img class="img-rounded" src="{{ channel[0].logo }}" alt="{{ channel[0].channel }}" width="50" height="50">
<img class="img-rounded" src="{{ channel[0].compChannel[0].compChannelLogo }}" alt="{{ channel[0].compChannel[0].compChannelName }}"
width="50" height="50">
</ng-container>
<br>
<div align="center">
<strong>
<font size="2">{{ channel[0].pickCode }}</font>
</strong>
</div>
</li>
</ul>
</div>
Here is the CSS:
#pickList {
height:565px;
scroll-behavior: auto;
overflow:auto;
}
I figured it out this way, by adding an extra div in between
<div class="row pickList" align="center">
<div>
<ul *ngFor="let channel of currentPickSelection">
<li class="list-group-item" style="float:Left;margin:1px;" (dragover)="onDragOver(channel[0])" (drop)="onDrop()" [ngStyle]="{'background-color': channel[0].compChannel[0].compChannelLogo.length !== 0 ? '#8EC0D1' : 'aliceblue' }">
<ng-container *ngIf="channel[0].compChannel[0].compChannelLogo.length !== 0; else noCompChannel">
<img class="img-rounded" src="{{ channel[0].logo }}" alt="{{ channel[0].channel }}" width="50" height="50">
<img class="img-rounded" src="{{ channel[0].compChannel[0].compChannelLogo }}" alt="{{ channel[0].compChannel[0].compChannelName }}"
width="50" height="50">
</ng-container>
<br>
<div align="center">
<strong>
<font size="2">{{ channel[0].pickCode }}</font>
</strong>
</div>
</li>
</ul>
</div>
</div>