From 1490b191af0559cef8cf4e31a507641a94c37596 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Fri, 7 Apr 2023 09:44:08 +0200 Subject: [PATCH] [TASK] refactor code and add base css components --- frontend/scss/app.scss | 88 ++---------------------- frontend/scss/components/_btns.scss | 23 +++++++ frontend/scss/components/_headlines.scss | 3 + frontend/scss/components/_input.scss | 3 + frontend/scss/components/_links.scss | 9 +++ frontend/scss/components/_sidebar.scss | 83 ++++++++++++++++++++++ templates/admin/user/index.html.tera | 2 +- templates/auth/login.html.tera | 14 ++-- templates/auth/set-pw.html.tera | 14 ++-- templates/includes/cox-icon.html.tera | 4 ++ templates/includes/delete-icon.html.tera | 6 ++ templates/includes/lock-icon.html.tera | 3 + templates/includes/macros.html.tera | 4 +- templates/index.html.tera | 42 ++++------- 14 files changed, 165 insertions(+), 133 deletions(-) create mode 100644 frontend/scss/components/_btns.scss create mode 100644 frontend/scss/components/_headlines.scss create mode 100644 frontend/scss/components/_input.scss create mode 100644 frontend/scss/components/_links.scss create mode 100644 frontend/scss/components/_sidebar.scss create mode 100644 templates/includes/cox-icon.html.tera create mode 100644 templates/includes/delete-icon.html.tera create mode 100644 templates/includes/lock-icon.html.tera diff --git a/frontend/scss/app.scss b/frontend/scss/app.scss index c9e7c41..5f1ce76 100644 --- a/frontend/scss/app.scss +++ b/frontend/scss/app.scss @@ -2,86 +2,8 @@ @tailwind components; @tailwind utilities; -/* purgecss start ignore */ -.sidebar { - position: fixed; - overflow-y: scroll; - top: 0; - background: white; - z-index: 2000; - width: 0; - box-shadow: 0 1rem 3rem rgba(0,0,0,.175); - - &.open { - background-color: rgba(255, 255, 255, 100%); - display: block; - height: 100vh; - right: 0; - top: 0; - width: 375px; - z-index: 40000; - } - - &.slide-in { - transition-duration: 75ms; - transition-property: all; - transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); - transition-timing-function: cubic-bezier(0, 0, 0.2, 1); - } - - &.from-right { - right: -24rem; - - &.open { - right: 0; - } - } - - &.from-left { - left: -24rem; - - &.open { - left: 0; - } - } - - &-overlay { - display: none; - - &.show { - background-color: rgba(0, 0, 0, 0.2); - content: ''; - display: block; - height: 100%; - left: 0; - position: fixed; - top: 0; - width: 100%; - z-index: 1025; - } - } - - &-close { - border-radius: 100%; - width: 27.5px; - - &:focus { - background: white !important; - } - } - - &-footer { - position: fixed; - margin: 0 -8px -4px; - width: 374px; - bottom: 0; - } - - &-header { - position: fixed; - width: 375px; - top: 0; - z-index: 1; - } -} -/* purgecss end ignore */ +@import 'components/headlines'; +@import 'components/sidebar'; +@import 'components/btns'; +@import 'components/links'; +@import 'components/input'; diff --git a/frontend/scss/components/_btns.scss b/frontend/scss/components/_btns.scss new file mode 100644 index 0000000..c696504 --- /dev/null +++ b/frontend/scss/components/_btns.scss @@ -0,0 +1,23 @@ +.btn { + @apply rounded-md px-3 py-2 text-sm font-semibold text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 cursor-pointer text-center; + + &-primary { + @apply bg-primary-600 hover:bg-primary-500 focus-visible:outline-primary-600; + } + + &-dark { + @apply bg-primary-900 hover:bg-primary-950 focus-visible:outline-primary-950; + } + + &-attention { + @apply bg-[#f43f5e] hover:bg-[#ff0000] focus-visible:outline-[#ff0000]; + } + + &-alert { + @apply bg-[#ff0000] hover:bg-[#ff0000] focus-visible:outline-[#ff0000]; + } + + &-fw { + @apply w-28; + } +} diff --git a/frontend/scss/components/_headlines.scss b/frontend/scss/components/_headlines.scss new file mode 100644 index 0000000..a547fab --- /dev/null +++ b/frontend/scss/components/_headlines.scss @@ -0,0 +1,3 @@ +.h1 { + @apply text-center text-3xl uppercase tracking-wide font-bold text-primary-900; +} diff --git a/frontend/scss/components/_input.scss b/frontend/scss/components/_input.scss new file mode 100644 index 0000000..453fd78 --- /dev/null +++ b/frontend/scss/components/_input.scss @@ -0,0 +1,3 @@ +.input { + @apply relative block w-full border-0 py-1.5 px-2 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6; +} diff --git a/frontend/scss/components/_links.scss b/frontend/scss/components/_links.scss new file mode 100644 index 0000000..d03040d --- /dev/null +++ b/frontend/scss/components/_links.scss @@ -0,0 +1,9 @@ +.link { + &-primary { + @apply text-primary-600 hover:text-primary-900 underline; + } + + &-dark { + @apply text-primary-900 hover:text-primary-950 underline; + } +} diff --git a/frontend/scss/components/_sidebar.scss b/frontend/scss/components/_sidebar.scss new file mode 100644 index 0000000..78597ac --- /dev/null +++ b/frontend/scss/components/_sidebar.scss @@ -0,0 +1,83 @@ +/* purgecss start ignore */ +.sidebar { + position: fixed; + overflow-y: scroll; + top: 0; + background: white; + z-index: 2000; + width: 0; + box-shadow: 0 1rem 3rem rgba(0,0,0,.175); + + &.open { + background-color: rgba(255, 255, 255, 100%); + display: block; + height: 100vh; + right: 0; + top: 0; + width: 375px; + z-index: 40000; + } + + &.slide-in { + transition-duration: 75ms; + transition-property: all; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + transition-timing-function: cubic-bezier(0, 0, 0.2, 1); + } + + &.from-right { + right: -24rem; + + &.open { + right: 0; + } + } + + &.from-left { + left: -24rem; + + &.open { + left: 0; + } + } + + &-overlay { + display: none; + + &.show { + background-color: rgba(0, 0, 0, 0.2); + content: ''; + display: block; + height: 100%; + left: 0; + position: fixed; + top: 0; + width: 100%; + z-index: 1025; + } + } + + &-close { + border-radius: 100%; + width: 27.5px; + + &:focus { + background: white !important; + } + } + + &-footer { + position: fixed; + margin: 0 -8px -4px; + width: 374px; + bottom: 0; + } + + &-header { + position: fixed; + width: 375px; + top: 0; + z-index: 1; + } +} +/* purgecss end ignore */ diff --git a/templates/admin/user/index.html.tera b/templates/admin/user/index.html.tera index 8391a71..b206925 100644 --- a/templates/admin/user/index.html.tera +++ b/templates/admin/user/index.html.tera @@ -4,7 +4,7 @@ {% block content %}
-

Users

+

Users

diff --git a/templates/auth/login.html.tera b/templates/auth/login.html.tera index 241af67..47c8857 100644 --- a/templates/auth/login.html.tera +++ b/templates/auth/login.html.tera @@ -4,7 +4,7 @@
Your Company -

Ruderassistent

+

Ruderassistent

{% if flash %} @@ -23,21 +23,17 @@
- - + {{ macros::input(label='Name', name='name', type='input', required=true, class='rounded-t-md') }}
- - + {{ macros::input(label='Passwort', name='password', type='password', class='rounded-b-md') }}
- diff --git a/templates/auth/set-pw.html.tera b/templates/auth/set-pw.html.tera index fd4ac6c..1670f97 100644 --- a/templates/auth/set-pw.html.tera +++ b/templates/auth/set-pw.html.tera @@ -2,28 +2,24 @@ {% block content %}
-

Passwort setzen

+

Passwort setzen

- - + {{ macros::input(label='Passwort', name='password', type='password', required=true, class='rounded-t-md') }}
- - + {{ macros::input(label='Passwort bestätigen', name='password_confirm', type='password', required=true, class='rounded-b-md') }}
- diff --git a/templates/includes/cox-icon.html.tera b/templates/includes/cox-icon.html.tera new file mode 100644 index 0000000..fb4685e --- /dev/null +++ b/templates/includes/cox-icon.html.tera @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/templates/includes/delete-icon.html.tera b/templates/includes/delete-icon.html.tera new file mode 100644 index 0000000..6ffc9e5 --- /dev/null +++ b/templates/includes/delete-icon.html.tera @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/templates/includes/lock-icon.html.tera b/templates/includes/lock-icon.html.tera new file mode 100644 index 0000000..6b52f1f --- /dev/null +++ b/templates/includes/lock-icon.html.tera @@ -0,0 +1,3 @@ + diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index 0898127..279506f 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -24,9 +24,9 @@
{% endmacro header %} -{% macro input(label, name, type, required=false) %} +{% macro input(label, name, type, required=false, class='rounded-md') %} - + {% endmacro input %} {% macro checkbox(label, name, id='', checked=false) %} diff --git a/templates/index.html.tera b/templates/index.html.tera index 0d66077..4c87478 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -17,8 +17,7 @@ {% endif %} {% endif %} -

- Ausfahrten

+

Ausfahrten

{% for day in days %}
@@ -34,7 +33,7 @@ {{ planned_event.planned_starting_time }} Uhr ({{ planned_event.name }})
Details + class="inline-block mr-3 link-primary">Details
{% set_global cur_user_participates = false %} @@ -44,13 +43,11 @@ {% endif %} {% endfor %} {% if cur_user_participates %} - Abmelden + Abmelden {% endif %} {% if planned_event.max_people > planned_event.rower | length %} {% if cur_user_participates == false %} - Mitrudern + Mitrudern {% endif %} {% endif %} @@ -63,21 +60,13 @@ {% endif %} {% endfor %} {% if cur_user_participates %} - - - - + + {% include "includes/cox-icon" %} Abmelden {% else %} - - - - + + {% include "includes/cox-icon" %} Steuern {% endif %} @@ -138,13 +127,8 @@ {% if loggedin_user.is_admin %} - - - - + class="inline-block btn btn-alert"> + {% include "includes/delete-icon" %} Termin löschen {% endif %} @@ -166,7 +150,7 @@ {{ trip.planned_starting_time }} Uhr ({{ trip.cox_name }})
Details + class="inline-block link-primary mr-3">Details
{% set_global cur_user_participates = false %} @@ -227,7 +211,7 @@
{% if loggedin_user.is_admin %} Event hinzufügen + class="inline-block link-dark mr-3">Event hinzufügen