Initial commit

This commit is contained in:
2023-07-23 13:34:00 +01:00
commit 967c16b6bf
65 changed files with 2868 additions and 0 deletions

View File

@ -0,0 +1,644 @@
@import url("https://rsms.me/inter/inter.css");
:root {
font-family: "Inter", sans-serif;
color-scheme: light;
}
@supports (font-variation-settings: normal) {
:root {
font-family: "Inter var", sans-serif;
}
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
[hidden] {
display: none !important;
}
body {
display: flex;
background-color: rgb(243, 244, 246);
}
h1 {
font-size: 2rem;
font-weight: 800;
letter-spacing: -0.025em;
margin-bottom: 1rem;
}
h1, h2, h3, h4, h5, h6 {
color: rgb(17, 24, 39);
}
/*@media (prefers-color-scheme: dark) {
:root {
color-scheme: dark;
}
body {
background-color: rgb(17, 24, 39);
}
h1, h2, h3, h4, h5, h6 {
color: rgb(255, 255, 255);
}
}*/
.main-content {
height: 100vh;
width: 100%;
max-width: 80rem;
overflow-y: auto;
padding: 2.5rem 4rem;
margin: 0 auto;
background-color: inherit;
}
@media (max-width: 40rem) {
.main-content {
padding-inline: 0;
}
}
/* Layout */
.flex-2 {
flex: 2;
}
.flex-5 {
flex: 5;
}
.row {
display: flex;
align-items: baseline;
gap: 0.75rem;
}
.row__fill {
flex: auto;
}
/* Icon */
.icon {
fill: currentColor;
height: 1.5rem;
width: 1.5rem;
}
.icon--sm {
height: 1.25rem;
width: 1.25rem;
}
/* Sidebar */
.sidebar {
flex: none;
height: 100vh;
width: 16rem;
padding: 0.5rem;
display: flex;
flex-direction: column;
border-right: 1px solid rgb(229, 231, 235);
background-color: rgb(255, 255, 255);
}
.sidebar__toggle, .sidebar__toggle + label {
display: none;
}
@media (max-width: 40rem) {
.sidebar {
position: fixed;
transform: translateX(-100%);
transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
will-change: transform;
}
.sidebar__toggle:checked ~ .sidebar {
transform: translateX(0);
}
.sidebar__toggle {
display: initial;
position: fixed;
visibility: hidden;
}
.sidebar__toggle + label {
background: none;
border: none;
outline: none;
cursor: pointer;
display: initial;
position: absolute;
transform: translateX(0);
transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
will-change: transform;
z-index: 2;
}
.sidebar__toggle:checked + label {
transform: translateX(16rem);
}
.sidebar__toggle + label::before {
content: "";
pointer-events: none;
position: fixed;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.2);
opacity: 0;
transition: opacity 0.5s cubic-bezier(0.19, 1, 0.22, 1);
will-change: opacity;
z-index: 1;
}
.sidebar__toggle:checked + label::before {
opacity: 100%;
pointer-events: auto;
}
.main-content {
transform: translateX(0);
transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
will-change: transform;
}
.sidebar__toggle:checked ~ .main-content {
transform: translateX(16rem);
}
}
.sidebar__header {
color: rgb(17, 24, 39);
font-size: 1.5rem;
font-weight: 800;
letter-spacing: -0.025em;
padding: 1.5rem 0.75rem;
}
.sidebar__body {
flex: 1;
}
.sidebar__item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 0.5rem;
border-radius: 0.375rem;
color: rgb(107, 114, 128);
font-weight: 500;
}
.sidebar__item--active {
background-color: rgb(243, 244, 246);
color: rgb(75, 85, 99);
}
.sidebar__link {
color: inherit;
text-decoration: none;
}
/*@media (prefers-color-scheme: dark) {
.sidebar {
border-color: rgb(75, 85, 99);
background-color: rgb(31, 41, 55);
}
.sidebar__header {
color: rgb(255, 255, 255);
}
.sidebar__item {
color: rgb(209, 213, 219);
}
.sidebar__item:where(:hover) {
background-color: rgb(55, 65, 81);
color: rgb(255, 255, 255);
}
.sidebar__item--active {
background-color: rgb(17, 24, 39);
color: rgb(255, 255, 255);
}
}*/
/* Modal */
.modal {
background-color: transparent;
border: none;
overflow: visible;
margin: auto;
min-width: min(28rem, 100%);
}
.modal::backdrop {
background: rgba(0, 0, 0, 0.2);
backdrop-filter: blur(4px);
}
html:has(.modal[open]) {
overflow: hidden;
}
/* HACK: should probably be a .button--icon */
.modal__close-button {
padding: 0 !important;
margin-block: -1rem;
width: 2rem;
height: 2rem;
}
/* Slide toggle */
.slide-toggle {
padding: 0.125rem;
border-radius: 0.5rem;
background-color: rgb(243, 244, 246);
}
.slide-toggle__option {
display: inline-flex;
align-items: center;
}
.slide-toggle__control {
appearance: none;
}
/*@media (prefers-color-scheme: dark) {
.slide-toggle {
background-color: rgb(17, 24, 39);
}
}*/
/* Card */
.card {
overflow: hidden;
background-color: rgb(255, 255, 255);
border-radius: 0.5rem;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}
.card__content {
margin: 1.5rem;
}
.card__header {
border-bottom: 1px solid rgb(243, 244, 246);
padding: 1.25rem 1.5rem;
}
.card__footer {
border-top: 1px solid rgb(243, 244, 246);
padding: 0.75rem 1.5rem;
}
.card__footer--shaded {
background-color: rgb(249, 250, 251);
border-color: transparent;
}
/* Table */
.table {
overflow: hidden;
border-radius: 0.5rem;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}
.table table {
min-width: 100%;
border-collapse: collapse;
}
.table__header {
background-color: rgb(249, 250, 251);
color: rgb(107, 114, 128);
font-size: 0.75rem;
font-weight: 500;
letter-spacing: 0.05em;
line-height: 1rem;
text-align: start;
text-transform: uppercase;
padding: 0.75rem 1.5rem;
white-space: nowrap;
}
.table__header--sortable a {
color: inherit;
text-decoration: none;
position: relative;
}
.table__header--sortable a::after {
position: absolute;
margin-left: 0.3rem;
}
.table__header--sortable a[data-dir=asc]::after {
content: "\25B2";
}
.table__header--sortable a[data-dir=desc]::after {
content: "\25BC";
}
.table__cell {
background-color: rgb(255, 255, 255);
color: rgb(17, 24, 39);
border-top: 1px solid rgb(229, 231, 235);
font-size: 0.875rem;
line-height: 1.25rem;
padding: 1rem 1.5rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.table__cell--icon {
font-size: 1.25rem;
}
.table__cell--numeric {
text-align: end;
}
.table__paginator {
display: flex;
justify-content: space-between;
background-color: rgb(255, 255, 255);
color: rgb(55, 65, 81);
border-top: 1px solid rgb(229, 231, 235);
font-size: 0.875rem;
line-height: 1.25rem;
padding: 0.75rem 1.5rem;
}
/*@media (prefers-color-scheme: dark) {
.table__header {
background-color: rgb(55, 65, 81);
color: rgb(156, 163, 175);
}
.table__cell {
background-color: rgb(31, 41, 55);
border-color: rgb(55, 65, 81);
color: rgb(255, 255, 255);
}
.table__paginator {
background-color: rgb(55, 65, 81);
border-color: rgb(55, 65, 81);
color: rgb(156, 163, 175);
}
}*/
/* Link */
.link {
display: inline-block;
text-decoration: none;
appearance: none;
font-weight: 600;
color: rgb(26, 86, 219);
cursor: pointer;
}
.link:focus-visible:not(.link--disabled, [disabled]), .link:hover {
outline: none;
text-decoration: underline;
text-decoration-thickness: 2px;
text-underline-offset: 2px;
}
.link--disabled, .link[disabled] {
pointer-events: none;
opacity: 50%;
}
/* Button */
.button {
display: inline-block;
text-decoration: none;
appearance: none;
background-color: rgb(255, 255, 255);
border: 1px solid rgb(209, 213, 219);
border-radius: 0.375rem;
color: rgb(55, 65, 81);
font-size: 0.875rem;
font-weight: 500;
line-height: 1.25rem;
padding: 0.5rem 1rem;
cursor: pointer;
}
.button--primary {
background-color: rgb(26, 86, 219);
border-color: transparent;
color: rgb(255, 255, 255);
}
.button--danger {
background-color: rgb(220, 38, 38);
border-color: transparent;
color: rgb(255, 255, 255);
}
.button:focus-visible:not(.button--disabled, [disabled]), .button:hover {
outline: none;
filter: brightness(0.85);
}
.button--disabled, .button[disabled] {
pointer-events: none;
opacity: 50%;
}
.button-group {
display: flex;
gap: 1rem;
}
/* Form field */
.form-field {
border: none;
margin-bottom: 1.5rem;
}
.form-field__label {
display: flex;
align-items: baseline;
justify-content: space-between;
font-size: 0.875rem;
font-weight: 500;
line-height: 1.25rem;
color: rgb(55, 65, 81);
}
.form-field__control {
flex: auto;
position: relative;
margin-top: 0.25rem;
border-radius: 0.375rem;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.form-field__corner-hint {
font-size: 0.65rem;
line-height: 1rem;
text-transform: uppercase;
}
/* Input */
.input {
display: flex;
position: relative;
}
.input__control {
appearance: none;
width: 100%;
padding: 0.5rem 0.75rem;
border-radius: 0.375rem;
font-family: inherit;
font-size: 0.875rem;
line-height: 1.25rem;
text-overflow: ellipsis;
background-color: rgb(255, 255, 255);
border: 1px solid rgb(209, 213, 219);
z-index: 1;
}
.input__control[list]::-webkit-calendar-picker-indicator {
display: none !important;
}
/*
.input--leading-addon-sm .input__control {
padding-left: 1.75rem;
}
*/
.input__inset + .input__control {
padding-left: 2.25rem;
}
.input__control:has(+ .input__control), .input__control:has(+ .input__addon:not([hidden])) {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
.input__control:focus {
outline: 2px solid rgb(63, 131, 248);
outline-offset: -1px;
z-index: 2;
}
.input__control::placeholder {
opacity: 1;
color: rgb(156, 163, 175);
}
.input__inset {
display: flex;
align-items: center;
color: rgb(107, 114, 128);
font-size: 0.875rem;
line-height: 1.25rem;
pointer-events: none;
padding: 0 0.75rem;
position: absolute;
height: 100%;
z-index: 3;
}
.input__addon {
color: rgb(107, 114, 128);
background-color: rgb(249, 250, 251);
border-color: rgb(209, 213, 219);
}
.input__control + .input__control, .input__control ~ .input__addon {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-left-width: 0;
}
/*@media (prefers-color-scheme: dark) {
.input__control {
background-color: rgb(55, 65, 81);
border-color: rgb(75, 85, 99);
}
.input__addon {
color: rgb(156, 163, 175);
}
}*/
/* Text area */
.textarea {
appearance: none;
width: 100%;
padding: 0.5rem 0.75rem;
border-radius: 0.375rem;
font-family: inherit;
font-size: 0.875rem;
line-height: 1.25rem;
background-color: rgb(255, 255, 255);
border: 1px solid rgb(209, 213, 219);
}
.textarea:focus {
outline: 1px solid rgb(63, 131, 248);
border-color: rgb(63, 131, 248);
}
.textarea::placeholder {
opacity: 1;
color: rgb(156, 163, 175);
}
/* Select */
.select {
appearance: none;
width: 100%;
padding: 0.5rem 0.75rem;
border-radius: 0.375rem;
font-family: inherit;
font-size: 0.875rem;
line-height: 1.25rem;
background-color: rgb(255, 255, 255);
border: 1px solid rgb(209, 213, 219);
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-size: 1.5rem 1.5rem;
background-position: right 0.5rem center;
}
.select:focus {
outline: 1px solid rgb(63, 131, 248);
border-color: rgb(63, 131, 248);
}

View File

@ -0,0 +1,17 @@
import { Controller } from "/lib/hotwired/stimulus/dist/stimulus.js";
export default class ListFilterController extends Controller {
static targets = ["option"];
filter(event) {
for (const option of this.optionTargets) {
if (!event.target.value) {
option.disabled = false;
continue;
}
const value = option.getAttribute("data-list-filter-value");
option.disabled = value !== event.target.value;
}
}
}

View File

@ -0,0 +1,33 @@
import { Controller } from "/lib/hotwired/stimulus/dist/stimulus.js";
export default class ModalController extends Controller {
static targets = ["frame"];
open() {
if (!this.element.open) {
this.element.showModal();
}
}
close(event) {
if (!this.element.open) {
return;
}
event.preventDefault();
this.element.close();
this.frameTarget.src = undefined;
this.frameTarget.innerHTML = "";
switch (event.type) {
case "turbo:submit-end":
Turbo.visit(location.href, { action: "replace" });
break;
case "popstate":
event.stopImmediatePropagation();
history.go(1);
break;
}
}
}

View File

@ -0,0 +1,21 @@
import { Controller } from "/lib/hotwired/stimulus/dist/stimulus.js";
export default class SearchFormController extends Controller {
static targets = ["button"];
#timeoutHandle;
connect() {
this.buttonTarget.hidden = true;
}
disconnect() {
clearTimeout(this.#timeoutHandle);
this.buttonTarget.hidden = false;
}
input() {
clearTimeout(this.#timeoutHandle);
this.#timeoutHandle = setTimeout(() => this.element.requestSubmit(), 500);
}
}

View File

@ -0,0 +1,37 @@
import { Application } from "/lib/hotwired/stimulus/dist/stimulus.js";
import ListFilterController from "./controllers/list-filter.js";
import ModalController from "./controllers/modal.js";
import SearchFormController from "./controllers/search-form.js";
const app = Application.start();
app.register("list-filter", ListFilterController);
app.register("modal", ModalController);
app.register("search-form", SearchFormController);
let timeout;
document.addEventListener("turbo:visit", () => {
clearTimeout(timeout);
});
document.addEventListener("turbo:render", () => {
clearTimeout(timeout);
if (document.getElementById("sidebarToggle").checked) {
timeout = setTimeout(() => document.getElementById("sidebarToggle").checked = false, 500);
}
});
let transition;
document.addEventListener("turbo:before-render", async event => {
if (document.startViewTransition) {
event.preventDefault();
if (transition == undefined) {
transition = document.startViewTransition(() => event.detail.resume());
await transition.finished;
transition = undefined;
} else {
await transition.finished;
event.detail.resume();
}
}
});