Navbar + css

This commit is contained in:
Edgar P. Burkhart 2022-05-20 19:44:32 +02:00
parent 467c8002e2
commit f85c67bb49
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
8 changed files with 78 additions and 10 deletions

View file

@ -7,7 +7,7 @@ from django.core.validators import validate_unicode_slug, FileExtensionValidator
class Category(models.Model): class Category(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=64, validators=[validate_unicode_slug]) name = models.CharField(max_length=64, validators=[validate_unicode_slug], default="New Category")
full_name = models.CharField(max_length=512, editable=False, default="") full_name = models.CharField(max_length=512, editable=False, default="")
parent = models.ForeignKey("self", on_delete=models.SET_NULL, blank=True, null=True) parent = models.ForeignKey("self", on_delete=models.SET_NULL, blank=True, null=True)
@ -40,7 +40,7 @@ class CategoryForm(ModelForm):
class Transaction(models.Model): class Transaction(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=256, default="Transaction") name = models.CharField(max_length=256, default="New Transaction")
description = models.TextField(null=True, blank=True) description = models.TextField(null=True, blank=True)
value = models.DecimalField(max_digits=12, decimal_places=2, default=0) value = models.DecimalField(max_digits=12, decimal_places=2, default=0)
date = models.DateField(default=date.today) date = models.DateField(default=date.today)
@ -67,7 +67,7 @@ class TransactionForm(ModelForm):
class Invoice(models.Model): class Invoice(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=256) name = models.CharField(max_length=256, default="New Invoice")
file = models.FileField( file = models.FileField(
upload_to="invoices/", validators=[FileExtensionValidator(["pdf"])] upload_to="invoices/", validators=[FileExtensionValidator(["pdf"])]
) )

View file

@ -1,3 +1,11 @@
h1 {
font-size: 4rem;
font-variant: small-caps;
font-weight: 850;
letter-spacing: -.05em;
margin: 0;
}
#transactions { #transactions {
display: grid; display: grid;
grid-template-columns: repeat(6, auto); grid-template-columns: repeat(6, auto);

View file

@ -6,6 +6,8 @@
body { body {
font-family: "Inter var experimental", "Inter var", "Inter", sans-serif; font-family: "Inter var experimental", "Inter var", "Inter", sans-serif;
margin: 0;
padding: 2em;
} }
:root { :root {
@ -17,3 +19,7 @@ body {
--bg-01: #dedede; --bg-01: #dedede;
} }
h1 {
margin: 0;
}

View file

@ -0,0 +1,37 @@
:root {
--nav-lh: 2em;
--nav-pad: 1em;
--nav-height: calc(2 * var(--nav-pad) + var(--nav-lh));
}
body {
margin-top: var(--nav-height);
}
nav {
background: var(--bg-inv);
color: var(--text-inv);
position: absolute;
top: 0;
left: 0;
right: 0;
height: var(--nav-height);
line-height: var(--nav-lh);
padding: var(--nav-pad);
}
nav > a {
display: inline-block;
color: inherit;
text-decoration: inherit;
height: var(--nav-lh);
margin: 0 var(--nav-pad);
}
nav > a.cur {
font-weight: 750;
}
nav > a.home {
font-variant: small-caps;
}
nav > a.logout {
float: right;
}

View file

@ -9,9 +9,32 @@
{% block link %} {% block link %}
<link rel="stylesheet" href="{% static 'css/main.css' %}" type="text/css" /> <link rel="stylesheet" href="{% static 'css/main.css' %}" type="text/css" />
<link rel="stylesheet" href="{% static 'css/nav.css' %}" type="text/css" />
{% endblock %} {% endblock %}
</head> </head>
<body> <body>
{% block nav %}
{% spaceless %}
<nav>
<a href="{% url 'index' %}"
class="home{% if request.resolver_match.url_name == "index" %} cur{% endif %}">
Nummi
</a>
<a href="{% url 'transaction' %}"
class="{% if request.resolver_match.url_name == "transaction" %} cur{% endif %}">
Add transaction
</a>
<a href="{% url 'category' %}"
class="{% if request.resolver_match.url_name == "category" %} cur{% endif %}">
Add category
</a>
<a href="{% url 'logout' %}"
class="logout">
Log Out
</a>
</nav>
{% endspaceless %}
{% endblock %}
{% block body %} {% block body %}
{% endblock %} {% endblock %}
</body> </body>

View file

@ -1,8 +1,6 @@
{% extends "main/base.html" %} {% extends "main/base.html" %}
{% block body %} {% block body %}
<a href="{% url 'index' %}">Home</a>
<h1>{{ category.tree|join:" → " }}</h1> <h1>{{ category.tree|join:" → " }}</h1>
<form action="{% url 'update_category' category.id %}" method="post"> <form action="{% url 'update_category' category.id %}" method="post">

View file

@ -9,9 +9,6 @@
{% block body %} {% block body %}
<h1>Nummi</h1> <h1>Nummi</h1>
<a href="{% url 'logout' %}">Logout</a>
<a href="{% url 'transaction' %}">Add transaction</a>
{% if transactions %} {% if transactions %}
<div id="transactions"> <div id="transactions">
<div class="header"> <div class="header">

View file

@ -1,9 +1,8 @@
{% extends "main/base.html" %} {% extends "main/base.html" %}
{% block body %} {% block body %}
<a href="{% url 'index' %}">Home</a>
<h1>{{ transaction }}</h1> <h1>{{ transaction }}</h1>
<form action="{% url 'update_transaction' transaction.id %}" method="post"> <form action="{% url 'update_transaction' transaction.id %}" method="post">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_p }}