Convert reports to Tailwind CSS

This commit is contained in:
RunasSudo 2024-04-04 00:24:09 +11:00
parent b782f97af6
commit 9924df7e58
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
5 changed files with 114 additions and 15 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
__pycache__
/drcr/config.toml
/drcr/static/build
/instance
/venv

3
drcr/css/main.css Normal file
View File

@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

View File

@ -0,0 +1,11 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./*/templates/**/*.html"],
theme: {
extend: {},
fontFamily: {
"sans": ["Roboto Flex", "Helvetica", "Arial", "sans-serif"],
}
},
plugins: [],
}

View File

@ -0,0 +1,80 @@
{# DrCr: Web-based double-entry bookkeeping framework
Copyright (C) 2022–2024 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
<!DOCTYPE html>
<html class="h-full">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='build/main.css') }}">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,slnt,wght,GRAD@8..144,-10..0,100..1000,-200..150&display=swap">
</head>
<body class="h-full">
{% block body %}
<div class="min-h-full">
{# Navigation bar #}
<nav class="border-b border-gray-200 bg-white">
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div class="flex h-12 justify-between">
<div class="flex">
<div class="flex flex-shrink-0">
<a href="{{ url_for('index') }}" class="border-transparent text-gray-900 hover:border-gray-500 inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium">
DrCr
</a>
</div>
{# Menu items #}
<div class="hidden sm:-my-px sm:ml-6 sm:flex sm:space-x-4">
<a href="{{ url_for('journal') }}" class="border-transparent text-gray-700 hover:border-gray-500 hover:text-gray-900 inline-flex items-center border-b-2 px-1 pt-1 text-sm">
Journal
</a>
<a href="{{ url_for('statement_lines') }}" class="border-transparent text-gray-700 hover:border-gray-500 hover:text-gray-900 inline-flex items-center border-b-2 px-1 pt-1 text-sm">
Statement lines
</a>
<a href="{{ url_for('trial_balance') }}" class="border-transparent text-gray-700 hover:border-gray-500 hover:text-gray-900 inline-flex items-center border-b-2 px-1 pt-1 text-sm">
Trial balance
</a>
</div>
</div>
</div>
</div>
</nav>
<div class="py-8">
<main>
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
{% block content %}{% endblock %}
</div>
</main>
</div>
{% if config['DEBUG'] %}
<footer>
<div class="mt-6 mx-auto max-w-3xl px-4 sm:px-6 lg:max-w-7xl lg:px-8">
<div class="border-t border-gray-200 py-4 text-center text-sm text-gray-500 sm:text-left">
Queries executed in {{ dbtime() }} msec. Page generated in __EXECUTION_TIME__ msec.
</div>
</div>
</footer>
{% endif %}
</div>
{% endblock %}
{% block scripts %}{% endblock %}
</body>
</html>

View File

@ -1,5 +1,5 @@
{# DrCr: Web-based double-entry bookkeeping framework
Copyright (C) 2022–2023 Lee Yingtong Li (RunasSudo)
Copyright (C) 2022–2024 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@ -15,13 +15,13 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
{% extends 'base.html' %}
{% extends 'base_tailwind.html' %}
{% block title %}{{ report.title }}{% endblock %}
{% macro render_section(section) %}
{% if section.title %}
<tr>
<th>{{ section.title }}</th>
<th class="py-0.5 text-gray-900 font-semibold text-start">{{ section.title }}</th>
<th></th>
</tr>
{% endif %}
@ -35,35 +35,39 @@
{% if entry.__class__.__name__ == 'Section' %}
{{ render_section(entry) }}
{% elif entry.__class__.__name__ == 'Subtotal' %}
<tr{% if entry.bordered %} style="border-width:1px 0"{% endif %}>
<th>{{ entry.text }}</th>
<th class="text-end">{{ entry.amount.format_accounting() }}</th>
<tr{% if entry.bordered %} class="border-y border-gray-200"{% endif %}>
<th class="py-0.5 text-gray-900 font-semibold text-start">{{ entry.text }}</th>
<th class="py-0.5 text-gray-900 font-semibold text-end">{{ entry.amount.format_accounting() }}</th>
</tr>
{% elif entry.__class__.__name__ == 'Spacer' %}
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2" class="py-0.5">&nbsp;</td></tr>
{% else %}
<tr{% if entry.bordered %} style="border-width:1px 0"{% endif %}>
<{{ 'th' if entry.heading else 'td' }}>
<tr{% if entry.bordered %} class="border-y border-gray-200"{% endif %}>
{% if entry.heading %}<th class="py-0.5 text-gray-900 font-semibold text-start">{% else %}<td class="py-0.5 text-gray-900 text-start">{% endif %}
{% if entry.link %}
<a href="{{ entry.link }}">{{ entry.text }}</a>
<a href="{{ entry.link }}" class="hover:text-blue-700 hover:underline">{{ entry.text }}</a>
{% else %}
{{ entry.text }}
{% endif %}
</{{ 'th' if entry.heading else 'td' }}>
<{{ 'th' if entry.heading else 'td' }} class="text-end">{{ entry.amount.format_accounting() }}</{{ 'th' if entry.heading else 'td' }}>
{% if entry.heading %}<th class="py-0.5 text-gray-900 font-semibold text-end">{% else %}<td class="py-0.5 text-gray-900 text-end">{% endif %}
{{ entry.amount.format_accounting() }}
</{{ 'th' if entry.heading else 'td' }}>
</tr>
{% endif %}
{% endif %}
{% endmacro %}
{% block content %}
<h1 class="h2 mt-4">{{ report.title }}</h1>
<h1 class="text-3xl text-gray-900">
{{ report.title }}
</h1>
<table class="table table-borderless table-sm">
<table class="min-w-full">
<thead>
<tr style="border-bottom-width:1px">
<tr class="border-b border-gray-300">
<th></th>
<th class="text-end">$&nbsp;</th>
<th class="py-0.5 text-gray-900 font-semibold text-end">$&nbsp;</th>
</tr>
</thead>
<tbody>