Skip to content

feat: Changed admin panel style theme #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lms/lmsweb/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ class AdminCommentTextView(AdminModelView):
admin = Admin(
webapp,
name='LMS',
template_mode='bootstrap3',
template_mode='bootstrap4',
index_view=MyAdminIndexView(), # NOQA
)
3 changes: 3 additions & 0 deletions lms/lmsweb/config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ MAILGUN_API_KEY = os.getenv('MAILGUN_API_KEY')
MAILGUN_DOMAIN = os.getenv('MAILGUN_DOMAIN', 'mail.pythonic.guru')
SERVER_ADDRESS = os.getenv('SERVER_ADDRESS', '127.0.0.1:5000')

# ADMIN PANEL
FLASK_ADMIN_FLUID_LAYOUT = True

# SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = 'Lax'
Expand Down
197 changes: 197 additions & 0 deletions lms/static/admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
@import "https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700";


body {
font-family: 'Poppins', sans-serif;
background: #fafafa;
}

p {
font-family: 'Poppins', sans-serif;
font-size: 1.1em;
font-weight: 300;
line-height: 1.7em;
color: #999;
}

a, a:hover, a:focus {
color: inherit;
text-decoration: none;
transition: all 0.3s;
}

.navbar {
padding: 15px 10px;
background: #fff;
border: none;
border-radius: 0;
margin-bottom: 40px;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

.navbar-btn {
box-shadow: none;
outline: none !important;
border: none;
}

.line {
width: 100%;
height: 1px;
border-bottom: 1px dashed #ddd;
margin: 40px 0;
}

/* ---------------------------------------------------
SIDEBAR STYLE
----------------------------------------------------- */

.wrapper {
display: flex;
width: 100%;
align-items: stretch;
perspective: 1500px;
}


#sidebar {
min-width: 250px;
max-width: 250px;
background: #0d6efd;
color: #fff;
transition: all 0.6s cubic-bezier(0.945, 0.020, 0.270, 0.665);
transform-origin: bottom left;
}

#sidebar.active {
margin-left: -250px;
transform: rotateY(100deg);
}

#sidebar .sidebar-header {
padding: 20px;
background: #0d6efd;
}

#sidebar ul.components {
padding: 20px 0;
border-bottom: 1px solid #47748b;
}

#sidebar ul p {
color: #fff;
padding: 10px;
}

#sidebar ul li a {
padding: 10px;
font-size: 1.1em;
display: block;
}
#sidebar ul li a:hover {
color: #0653c5;
background: #fff;
}

#sidebar ul li.active > a, a[aria-expanded="true"] {
color: #fff;
background: #0653c5;
}

ul ul a {
font-size: 0.9em !important;
padding-left: 30px !important;
background: #0d6efd;
}

ul.CTAs {
padding: 20px;
}

ul.CTAs a {
text-align: center;
font-size: 0.9em !important;
display: block;
border-radius: 5px;
margin-bottom: 5px;
}


/* ---------------------------------------------------
CONTENT STYLE
----------------------------------------------------- */
#content {
width: 100%;
padding: 20px;
min-height: 100vh;
transition: all 0.3s;
}

#sidebarCollapse {
width: 40px;
height: 40px;
background: #f5f5f5;
cursor: pointer;
}

#sidebarCollapse span {
width: 80%;
height: 2px;
margin: 0 auto;
display: block;
background: #555;
transition: all 0.8s cubic-bezier(0.810, -0.330, 0.345, 1.375);
transition-delay: 0.2s;
}

#sidebarCollapse span:first-of-type {
transform: rotate(45deg) translate(2px, 2px);
}
#sidebarCollapse span:nth-of-type(2) {
opacity: 0;
}
#sidebarCollapse span:last-of-type {
transform: rotate(-45deg) translate(1px, -1px);
}


#sidebarCollapse.active span {
transform: none;
opacity: 1;
margin: 5px auto;
}


/* ---------------------------------------------------
MEDIAQUERIES
----------------------------------------------------- */
@media (max-width: 768px) {
#sidebar {
margin-left: -250px;
transform: rotateY(90deg);
}
#sidebar.active {
margin-left: 0;
transform: none;
}
#sidebarCollapse span:first-of-type,
#sidebarCollapse span:nth-of-type(2),
#sidebarCollapse span:last-of-type {
transform: none;
opacity: 1;
margin: 5px auto;
}
#sidebarCollapse.active span {
margin: 0 auto;
}
#sidebarCollapse.active span:first-of-type {
transform: rotate(45deg) translate(2px, 2px);
}
#sidebarCollapse.active span:nth-of-type(2) {
opacity: 0;
}
#sidebarCollapse.active span:last-of-type {
transform: rotate(-45deg) translate(1px, -1px);
}

}
6 changes: 6 additions & 0 deletions lms/templates/admin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends 'admin/master.html' %}
{% block head_css %}
{{ super() }}
{% endblock head_css %}
{% block body %}
{% endblock %}
121 changes: 121 additions & 0 deletions lms/templates/admin/master.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{% import 'admin/layout.html' as layout with context -%}
{% import 'admin/static.html' as admin_static with context %}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% if admin_view.category %}{{ admin_view.category }} - {% endif %}{{ admin_view.name }} - {{ admin_view.admin.name }}{% endblock %}</title>
{% block head_meta %}
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
{% endblock %}
{% block head_css %}
<link href="{{ admin_static.url(filename='bootstrap/bootstrap4/swatch/{swatch}/bootstrap.min.css'.format(swatch=config.get('FLASK_ADMIN_SWATCH', 'default')), v='4.2.1') }}"
rel="stylesheet">
{% if config.get('FLASK_ADMIN_SWATCH', 'default') == 'default' %}
<link href="{{ admin_static.url(filename='bootstrap/bootstrap4/css/bootstrap.min.css', v='4.2.1') }}" rel="stylesheet">
{% endif %}
<link href="{{ admin_static.url(filename='admin/css/bootstrap4/admin.css', v='1.1.1') }}" rel="stylesheet">
<link href="{{ admin_static.url(filename='bootstrap/bootstrap4/css/font-awesome.min.css', v='4.7.0') }}" rel="stylesheet">
<link rel="stylesheet" href="{{ url_for('static', filename='admin.css') }}">
{% if admin_view.extra_css %}
{% for css_url in admin_view.extra_css %}
<link href="{{ css_url }}" rel="stylesheet">
{% endfor %}
{% endif %}
<style>
.hide {
display: none;
}
</style>
{% endblock %}
{% block head %}
{% endblock %}
{% block head_tail %}
{% endblock %}
</head>
<body>
<div class="wrapper">
{% block page_body %}
<nav id="sidebar">
<div class="sidebar-header">
{% block brand %}
<a class="navbar-brand" href="{{ admin_view.admin.url }}">{{ admin_view.admin.name }}</a>
{% endblock %}
</div>

{% block main_menu %}
<ul class="list-unstyled components">
{{ layout.menu() }}
</ul>
{% endblock %}
</nav>

<div id="content">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">

<button type="button" id="sidebarCollapse" class="navbar-btn">
<span></span>
<span></span>
<span></span>
</button>
<button class="btn btn-dark d-inline-block d-lg-none ml-auto" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-align-justify"></i>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
{% block menu_links %}
<ul class="nav navbar-nav navbar-right">
{{ layout.menu_links() }}
</ul>
{% endblock %}
</div>
</div>
</nav>
{% block access_control %}
{% endblock %}
{% block messages %}
{{ layout.messages() }}
{% endblock %}

{# store the jinja2 context for form_rules rendering logic #}
{% set render_ctx = h.resolve_ctx() %}

{% block body %}{% endblock %}
</div>

{% endblock %}
</div>

{% block tail_js %}
<script src="{{ admin_static.url(filename='vendor/jquery.min.js', v='2.1.4') }}" type="text/javascript"></script>
<script src="{{ admin_static.url(filename='bootstrap/bootstrap4/js/popper.min.js') }}" type="text/javascript"></script>
<script src="{{ admin_static.url(filename='bootstrap/bootstrap4/js/bootstrap.min.js', v='4.2.1') }}"
type="text/javascript"></script>
<script src="{{ admin_static.url(filename='vendor/moment.min.js', v='2.9.0') }}" type="text/javascript"></script>
<script src="{{ admin_static.url(filename='vendor/bootstrap4/util.js', v='4.3.1') }}" type="text/javascript"></script>
<script src="{{ admin_static.url(filename='vendor/select2/select2.min.js', v='4.2.1') }}"
type="text/javascript"></script>
<script src="{{ admin_static.url(filename='admin/js/helpers.js', v='1.0.0') }}" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#sidebarCollapse').on('click', function () {
$('#sidebar').toggleClass('active');
$(this).toggleClass('active');
});
});
</script>
{% if admin_view.extra_js %}
{% for js_url in admin_view.extra_js %}
<script src="{{ js_url }}" type="text/javascript"></script>
{% endfor %}
{% endif %}
{% endblock %}

{% block tail %}
{% endblock %}
</body>
</html>
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ flake8-quotes==3.2.0
flake8-tidy-imports==4.1.0
flake8-todo==0.7
flake8==3.8.3
Flask-Admin==1.5.6
Flask-Admin==1.5.8
Flask-Babel==2.0.0
Flask-Limiter==1.4
git+git://github.com/maxcountryman/flask-login@e3d8079#egg=flask-login
Expand Down