🏡 index : ~doyle/chartered.git

author Jordan Doyle <jordan@doyle.la> 2021-10-16 16:20:48.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2021-10-16 16:27:48.0 +01:00:00
commit
9c375ffe72b5e4846a20fb2c963f4a8e4ff418b1 [patch]
tree
cf56b9f8879afd6970815ac69bc7e3a521738c68
parent
cf7a84d7ce3b2537694a61735fcb75fbad9ae5b2
download
9c375ffe72b5e4846a20fb2c963f4a8e4ff418b1.tar.gz

preliminary dark mode support



Diff

 chartered-frontend/src/dark.sass                                  | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 chartered-frontend/src/index.sass                                 | 10 +++++++---
 chartered-frontend/src/index.tsx                                  |  9 +++++++++
 chartered-frontend/src/pages/Dashboard.tsx                        |  6 +++---
 chartered-frontend/src/pages/Loading.tsx                          |  2 +-
 chartered-frontend/src/pages/Login.tsx                            |  2 +-
 chartered-frontend/src/pages/Search.tsx                           |  6 +++---
 chartered-frontend/src/pages/User.tsx                             |  2 +-
 chartered-frontend/src/pages/crate/CrateView.tsx                  |  6 +++---
 chartered-frontend/src/pages/crate/OrganisationView.tsx           |  4 ++--
 chartered-frontend/src/pages/organisations/CreateOrganisation.tsx |  2 +-
 chartered-frontend/src/pages/organisations/ListOrganisations.tsx  |  2 +-
 chartered-frontend/src/pages/ssh-keys/AddSshKeys.tsx              |  2 +-
 chartered-frontend/src/pages/ssh-keys/ListSshKeys.tsx             |  2 +-
 14 files changed, 130 insertions(+), 21 deletions(-)

diff --git a/chartered-frontend/src/dark.sass b/chartered-frontend/src/dark.sass
new file mode 100644
index 0000000..45d3a88 100644
--- /dev/null
+++ a/chartered-frontend/src/dark.sass
@@ -1,0 +1,96 @@
@import "../node_modules/bootstrap/scss/functions"
@import "../node_modules/bootstrap/scss/variables"
@import "../node_modules/bootstrap/scss/mixins"
@import "../node_modules/bootstrap/scss/_navbar"

html, body
  @media(prefers-color-scheme: dark)
    background: hsl(213, 44%, 7%) !important

.dark
  $primary: hsl(212, 70%, 30%)
  $secondary: hsl(213, 44%, 7%)
  $dark: hsl(0, 0%, 0%)
  $card-border-color: hsl(212, 25%, 12%)
  $light: rgba(255, 255, 255, 0.55)
  $link-color: $primary

  $body-color: $light
  $body-bg: $secondary

  $theme-colors: ("primary": $primary, "secondary": $secondary, "danger": $danger, "info": $indigo, "dark": $dark, "light": $light)

  @each $color, $value in $theme-colors
    --#{$variable-prefix}#{$color}: #{$value}

  $theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value")
  @each $color, $value in $theme-colors-rgb
    --#{$variable-prefix}#{$color}-rgb: #{$value}

  a
    color: $link-color

  table td
    color: $body-color !important

  a.btn
    color: white

  table
    border-color: $card-border-color !important

  .nav-pills .nav-item .nav-link.active
    background: $card-border-color !important

  .list-group-item
    background: transparent !important
    color: rgba(255, 255, 255, 0.55) !important

  .card
    background: $body-bg !important
    border: 1px solid $card-border-color !important
    color: rgba(255, 255, 255, 0.55) !important

    .card-header
      border-bottom: 1px solid $card-border-color !important

    .list-group
      border-top: none

    .card
      background: $card-border-color !important

  pre > pre
    text-shadow: rgba(0, 0, 0, .2) 0 1px !important
    background: $card-border-color !important

    code
      text-shadow: rgba(0, 0, 0, .2) 0 1px !important

  code
    background: $card-border-color !important

  .form-control
    background: transparent !important
    border-color: $card-border-color !important

  .input-group
    border-color: $card-border-color

    .input-group-text
      background: $body-bg !important
      color: white
      border-color: $card-border-color

    .form-control
      background: $secondary !important

  .navbar
    background: $card-border-color !important
    @extend .navbar-dark

    .navbar-brand
      color: $body-color !important

  --#{$variable-prefix}body-color: #{$body-color}
  --#{$variable-prefix}body-bg: #{$body-bg}
diff --git a/chartered-frontend/src/index.sass b/chartered-frontend/src/index.sass
index b906700..131ccbf 100644
--- a/chartered-frontend/src/index.sass
+++ a/chartered-frontend/src/index.sass
@@ -1,4 +1,11 @@
@import "../node_modules/bootstrap/scss/functions"
@import "../node_modules/bootstrap/scss/variables"
@import "../node_modules/bootstrap/scss/mixins"
@import "../node_modules/bootstrap/scss/root"

$primary: #0d6efd
$body-bg: $primary
$body-color: white
$font-family-monospace: "Source Code Pro", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace
$font-size-base: 0.875rem
$enable-cssgrid: true
@@ -9,9 +16,6 @@

html
    background: white

body
    background: $primary

code
    background: #f5f2f0
diff --git a/chartered-frontend/src/index.tsx b/chartered-frontend/src/index.tsx
index e9fc46e..d0e4103 100644
--- a/chartered-frontend/src/index.tsx
+++ a/chartered-frontend/src/index.tsx
@@ -1,3 +1,4 @@
import "./dark.sass"; // TODO: lazyload
import "./index.sass";

import "./overscrollColourFixer.ts";
@@ -24,6 +25,14 @@
import CreateOrganisation from "./pages/organisations/CreateOrganisation";
import User from "./pages/User";
import Search from "./pages/Search";

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
  document.querySelector("body")?.classList.add("dark");
}

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
  document.querySelector("body")?.classList.toggle("dark", e.matches);
});

function App() {
  return (
diff --git a/chartered-frontend/src/pages/Dashboard.tsx b/chartered-frontend/src/pages/Dashboard.tsx
index 24ad18a..b713d79 100644
--- a/chartered-frontend/src/pages/Dashboard.tsx
+++ a/chartered-frontend/src/pages/Dashboard.tsx
@@ -64,7 +64,7 @@
    });

  return (
    <div className="text-white">
    <div>
      <Nav />

      <div className="container mt-4 pb-4">
@@ -163,10 +163,10 @@
        <div className="card-body text-black d-flex flex-row">
          <div className="flex-grow-1 align-self-center">
            <h6 className="text-primary my-0">
              <span className="text-secondary">{organisation}/</span>
              <span className="text-muted">{organisation}/</span>
              {name}
            </h6>
            <small className="text-secondary">{children}</small>
            <small className="text-muted">{children}</small>
          </div>

          <ChevronRight size={16} className="align-self-center" />
diff --git a/chartered-frontend/src/pages/Loading.tsx b/chartered-frontend/src/pages/Loading.tsx
index b167e13..7cc5020 100644
--- a/chartered-frontend/src/pages/Loading.tsx
+++ a/chartered-frontend/src/pages/Loading.tsx
@@ -10,7 +10,7 @@

export default function LoadingPage() {
  return (
    <div className="min-vh-100 bg-primary d-flex justify-content-center align-items-center">
    <div className="min-vh-100 d-flex justify-content-center align-items-center">
      <div className="spinner-border text-light" role="status">
        <span className="visually-hidden">Loading...</span>
      </div>
diff --git a/chartered-frontend/src/pages/Login.tsx b/chartered-frontend/src/pages/Login.tsx
index 6abdec9..299ef2a 100644
--- a/chartered-frontend/src/pages/Login.tsx
+++ a/chartered-frontend/src/pages/Login.tsx
@@ -69,7 +69,7 @@
  };

  return (
    <div className="bg-primary p-4 text-white min-vh-100 d-flex justify-content-center align-items-center">
    <div className="p-4 min-vh-100 d-flex justify-content-center align-items-center">
      <div>
        <h1>chartered ✈️</h1>
        <h6>a private, authenticated cargo registry</h6>
diff --git a/chartered-frontend/src/pages/Search.tsx b/chartered-frontend/src/pages/Search.tsx
index 7787aa5..92350a8 100644
--- a/chartered-frontend/src/pages/Search.tsx
+++ a/chartered-frontend/src/pages/Search.tsx
@@ -19,7 +19,7 @@
      : "";

  return (
    <div className="text-white">
    <div>
      <Nav />

      <div className="container mt-4 pb-4">
@@ -175,13 +175,13 @@
                      className="text-decoration-none"
                    >
                      <h4 className="text-primary d-inline px-2 m-0">
                        <span className="text-secondary">
                        <span className="text-muted">
                          {crate.organisation}
                        </span>
                        /{crate.name}
                      </h4>
                    </Link>
                    <h6 className="text-secondary m-0 mt-1">{crate.version}</h6>
                    <h6 className="text-muted m-0 mt-1">{crate.version}</h6>
                  </div>

                  <p className="m-0">{crate.description}</p>
diff --git a/chartered-frontend/src/pages/User.tsx b/chartered-frontend/src/pages/User.tsx
index af0d27f..e1bc288 100644
--- a/chartered-frontend/src/pages/User.tsx
+++ a/chartered-frontend/src/pages/User.tsx
@@ -43,7 +43,7 @@
  const ready = !!user;

  return (
    <div className="text-white">
    <div>
      <Nav />

      <div className="container mt-4 pb-4">
diff --git a/chartered-frontend/src/pages/crate/CrateView.tsx b/chartered-frontend/src/pages/crate/CrateView.tsx
index 7201119..5af39b7 100644
--- a/chartered-frontend/src/pages/crate/CrateView.tsx
+++ a/chartered-frontend/src/pages/crate/CrateView.tsx
@@ -103,7 +103,7 @@
    crateInfo.homepage || crateInfo.documentation || crateInfo.repository;

  return (
    <div className="text-white">
    <div>
      <Nav />

      <div className="container mt-4 pb-4">
@@ -121,13 +121,13 @@
                  <h1 className="text-primary d-inline px-2">
                    <Link
                      to={`/crates/${organisation}`}
                      className="text-secondary text-decoration-none"
                      className="text-muted text-decoration-none"
                    >
                      {organisation}/
                    </Link>
                    {crate}
                  </h1>
                  <h2 className="text-secondary m-0">{crateVersion?.vers}</h2>
                  <h2 className="text-muted m-0">{crateVersion?.vers}</h2>
                </div>

                <p className="m-0">{crateInfo.description}</p>
diff --git a/chartered-frontend/src/pages/crate/OrganisationView.tsx b/chartered-frontend/src/pages/crate/OrganisationView.tsx
index 6c43bbd..138e59f 100644
--- a/chartered-frontend/src/pages/crate/OrganisationView.tsx
+++ a/chartered-frontend/src/pages/crate/OrganisationView.tsx
@@ -67,7 +67,7 @@
  const ready = !!organisationDetails;

  return (
    <div className="text-white">
    <div>
      <Nav />

      <div className="container mt-4 pb-4">
@@ -201,7 +201,7 @@
              <td className="align-middle">
                <div>
                  <Link to={`/crates/${organisation}/${v.name}`}>
                    <span className="text-secondary">{organisation}/</span>
                    <span className="text-muted">{organisation}/</span>
                    {v.name}
                  </Link>
                </div>
diff --git a/chartered-frontend/src/pages/organisations/CreateOrganisation.tsx b/chartered-frontend/src/pages/organisations/CreateOrganisation.tsx
index 3e6eff7..82f95a0 100644
--- a/chartered-frontend/src/pages/organisations/CreateOrganisation.tsx
+++ a/chartered-frontend/src/pages/organisations/CreateOrganisation.tsx
@@ -51,7 +51,7 @@
  };

  return (
    <div className="text-white">
    <div>
      <Nav />

      <div className="container mt-4 pb-4">
diff --git a/chartered-frontend/src/pages/organisations/ListOrganisations.tsx b/chartered-frontend/src/pages/organisations/ListOrganisations.tsx
index 584ff66..9ef34dc 100644
--- a/chartered-frontend/src/pages/organisations/ListOrganisations.tsx
+++ a/chartered-frontend/src/pages/organisations/ListOrganisations.tsx
@@ -33,7 +33,7 @@
  }

  return (
    <div className="text-white">
    <div>
      <Nav />

      <div className="container mt-4 pb-4">
diff --git a/chartered-frontend/src/pages/ssh-keys/AddSshKeys.tsx b/chartered-frontend/src/pages/ssh-keys/AddSshKeys.tsx
index f24621b..cf15065 100644
--- a/chartered-frontend/src/pages/ssh-keys/AddSshKeys.tsx
+++ a/chartered-frontend/src/pages/ssh-keys/AddSshKeys.tsx
@@ -47,7 +47,7 @@
  };

  return (
    <div className="text-white">
    <div>
      <Nav />

      <div className="container mt-4 pb-4">
diff --git a/chartered-frontend/src/pages/ssh-keys/ListSshKeys.tsx b/chartered-frontend/src/pages/ssh-keys/ListSshKeys.tsx
index f341f98..bbce0bd 100644
--- a/chartered-frontend/src/pages/ssh-keys/ListSshKeys.tsx
+++ a/chartered-frontend/src/pages/ssh-keys/ListSshKeys.tsx
@@ -82,7 +82,7 @@
  dateMonthAgo.setMonth(dateMonthAgo.getMonth() - 1);

  return (
    <div className="text-white">
    <div>
      <Nav />

      <div className="container mt-4 pb-4">