Skip to content

Commit 64e00a3

Browse files
committed
Mobile admin menu, card number styling
1 parent 2e5759b commit 64e00a3

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
jQuery(function($) {
2+
$("[data-toggle]").on("click", function(e) {
3+
e.preventDefault();
4+
var targets = $(this).data("toggle").split(",");
5+
$.each(targets, function(index, target) {
6+
var $target = $(target);
7+
if ($target.data("toggle-class")) {
8+
$target.toggleClass($target.data("toggle-class"));
9+
} else {
10+
$target.toggle();
11+
}
12+
});
13+
});
14+
});

bolt-admin/bolt/admin/cards/base.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ class Sizes(Enum):
1616
size: Sizes = Sizes.SMALL
1717
# unique_id: str # Use for tying to dashboards, require it
1818

19-
title: str = ""
19+
# Required fields
20+
title: str
21+
22+
# Optional fields
2023
slug: str = ""
2124
description: str = ""
2225
text: str = ""

bolt-admin/bolt/admin/templates/admin/base.html

+15-8
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
</title>
1313
{% tailwind_css %}
1414
<link href="{{ asset('admin/admin.css') }}" rel="stylesheet">
15-
<script src="{{ asset('admin/chart.js') }}"></script>
1615
<script src="{{ asset('admin/jquery-3.6.1.slim.min.js') }}"></script>
16+
<script src="{{ asset('admin/chart.js') }}" defer></script>
17+
<script src="{{ asset('admin/admin.js') }}" defer></script>
1718
</head>
1819
<body class="flex min-h-screen text-black bg-stone-900">
19-
<div class="fixed flex flex-col justify-between flex-shrink-0 w-64 h-full px-6 pt-6 pb-5">
20+
<div id="admin-sidebar" data-toggle-class="hidden" class="fixed flex-col justify-between flex-shrink-0 hidden w-64 h-full px-6 pt-6 pb-5 lg:flex">
2021
<div>
2122
<a class="inline-flex items-center font-bold text-stone-300" href="{{ url('admin:index') }}">
2223
<svg class="w-5 h-5 mr-2" width="237" height="237" viewBox="0 0 237 237" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -62,9 +63,15 @@
6263
<a class="hover:text-white hover:underline" href="{{ url('logout') }}">Log out</a>
6364
</div>
6465
</div>
65-
<div class="flex-grow mt-3 mb-3 ml-64 mr-3 overflow-auto text-black bg-white border-l rounded-lg border-black/10">
66-
<div class="flex justify-between px-8 py-4 text-xs border-b border-gray-200">
66+
<div id="admin-content" data-toggle-class="fixed ml-64 -mr-64" class="flex-grow overflow-auto text-black bg-white border-l lg:rounded-lg lg:mt-3 lg:mb-3 lg:mr-3 lg:ml-64 border-black/10">
67+
<div class="flex justify-between px-4 py-4 text-xs border-b border-gray-200 lg:px-8">
6768
<div class="flex items-center space-x-2">
69+
<button type="button" data-toggle="#admin-sidebar,#admin-content" class="mr-1 lg:hidden">
70+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="w-5 h-5 bi bi-list" viewBox="0 0 16 16">
71+
<path fill-rule="evenodd" d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5"/>
72+
</svg>
73+
<span class="sr-only">Toggle menu</span>
74+
</button>
6875
<a class="text-stone-500" href="{{ url ('admin:index') }}">Admin</a>
6976
{% for parent in parent_view_classes %}
7077
<span class="text-stone-400">/</span>
@@ -73,12 +80,12 @@
7380
<span class="text-stone-400">/</span>
7481
<a class="text-stone-600" href="{{ request.path }}">{{ title }}</a>
7582
</div>
76-
<div>
83+
<div class="flex items-center">
7784
<a href="/">Back to app</a>
7885
</div>
7986
</div>
8087

81-
<div class="flex items-center justify-between px-8 mt-8">
88+
<div class="flex items-center justify-between px-4 mt-8 lg:px-8">
8289
<div>
8390
{% block header %}
8491
<h1 class="text-2xl font-semibold text-stone-700">
@@ -99,9 +106,9 @@ <h1 class="text-2xl font-semibold text-stone-700">
99106
</div>
100107
</div>
101108

102-
<div class="px-8 py-6">
109+
<div class="px-4 py-6 lg:px-8">
103110
{% if cards %}
104-
<div class="grid grid-cols-4 gap-6 mb-6">
111+
<div class="grid grid-cols-1 gap-6 mb-6 sm:grid-cols-2 lg:grid-cols-4">
105112
{% for card in cards %}
106113
<admin.Card size=card.size.value>
107114
{{ render_card(card)|safe }}

bolt-admin/bolt/admin/templates/admin/cards/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% block header %}
2-
<div class="text-sm">{{ title }}</div>
2+
<div>{{ title }}</div>
33
{% if description %}<div class="mt-1 text-xs text-gray-500">{{ description }}</div>{% endif %}
44
{% endblock %}
55

bolt-admin/bolt/admin/templates/admin/cards/card.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{% extends "admin/cards/base.html" %}
22

33
{% block content %}
4-
<div class="mt-3">
4+
<div class="mt-1">
55
{% if number is not none %}
6-
<div class="text-4xl">
6+
<div class="text-4xl font-bold">
77
{{ number }}
88
</div>
99
{% endif %}

0 commit comments

Comments
 (0)