Files
fixin.me/app/assets/stylesheets/application.css

685 lines
14 KiB
CSS

/*
* This is a manifest file that'll be compiled into application.css, which will
* include all the files listed below.
*
* Any CSS (and SCSS, if configured) file within this directory,
* lib/assets/stylesheets, or any plugin's vendor/assets/stylesheets directory
* can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at
* the bottom of the compiled file so the styles you add here take precedence
* over styles defined in any other CSS files in this directory. Styles in this
* file should be added after the last require_* statement. It is generally
* better to create a new file per style scope.
*
*= require_self
*/
/* Strive for simplicity:
* * style elements/tags only - if possible,
* * replace element/tag name with class name - if element has to be styled
* differently depending on context (e.g. <form>; <a> as link/button),
* * styles with multiple selectors should have all selectors with same
* specificity, to allow proper rule specificity vs order management.
*
* NOTE: style in a modular way, similar to how CSS @scope would be used,
* to make transition easier once @scope is widely available. */
/* TODO: review styles with multiple selectors and try to convert them to the same
* specificity. */
:root {
--color-focus-gray: #f3f3f3;
--color-border-gray: #dddddd;
--color-nav-gray: #c7c7c7;
--color-gray: #a0a0a0;
--color-table-gray: #909090;
--color-text-gray: #707070;
--color-dark-blue: #006c9b;
--color-blue: #009ade;
--color-dark-red: #b21237;
--color-red: #ff1f5b;
--depth: 0;
--z-index-flashes: 100;
--z-index-table-row-outline: 10;
}
*,
::before,
::after {
box-sizing: border-box;
}
::selection {
background-color: var(--color-blue);
color: white;
}
:focus-visible {
outline: none;
}
/* NOTE: move to higher priority layer instead of using !important? */
/* TODO: add CSS @layer requirements in README */
[disabled] {
border-color: var(--color-border-gray) !important;
color: var(--color-border-gray) !important;
/* NOTE: cannot set cursor when `pointer-events: none`; can be fixed by setting
* `cursor` on wrapping element.
cursor: not-allowed; */
fill: var(--color-border-gray) !important;
pointer-events: none !important;
}
/* Styles set `display` without distinguishing between [hidden] elements, making
* them visible. */
[hidden] {
display: none !important;
}
/* Color coding of input controls' background:
* blue - target for interaction with pointer,
* gray - target for interaction with keyboard,
* red - destructive, non-undoable action.
*/
button,
details,
input,
select,
textarea {
background-color: inherit;
font: inherit;
}
details,
input,
select {
text-align: inherit;
}
input,
select,
summary,
textarea {
border: 1px solid var(--color-gray);
border-radius: 0.25em;
padding: 0.2em 0.4em;
}
svg,
textarea {
margin: 0;
}
input[type=checkbox] {
accent-color: var(--color-blue);
appearance: none;
-webkit-appearance: none;
display: flex;
height: 1.1em;
margin: 0;
padding: 0;
width: 1.1em;
}
input[type=checkbox]:checked {
appearance: checkbox;
-webkit-appearance: checkbox;
}
/* Hide spin buttons of <input type=number>. */
/* TODO: add spin buttons inside <input type=number>: before (-) and after (+) input. */
input[type=number] {
appearance: textfield;
-moz-appearance: textfield;
text-align: end;
}
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
input::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Text color of table form controls:
* - black for row/table forms,
* - inherited for internal (column specific) buttons/forms. */
table input,
table select,
table summary,
table textarea {
border-color: var(--color-border-gray);
}
table input,
table select,
table textarea {
padding-block: 0.375em;
}
table form input,
table form select,
table form summary,
table form textarea {
color: inherit;
}
input:focus-visible,
select:focus-visible,
select:focus-within,
/* TODO: how to achieve `summary:focus-within` for `::details-content`? */
summary:focus-visible,
textarea:focus-visible {
accent-color: var(--color-dark-blue);
background-color: var(--color-focus-gray);
color: black;
}
input:hover,
select:hover,
summary:hover,
textarea:hover {
border-color: var(--color-blue);
outline: 1px solid var(--color-blue);
}
select:hover,
summary:hover {
color: black;
cursor: pointer;
}
/* TODO: style <details>/<summary> focus to match <select> as much as possible.
summary:focus-visible::before,
summary:hover::before {
background-color: black;
}
*/
input:invalid,
select:invalid,
textarea:invalid {
border-color: var(--color-red);
outline-color: var(--color-red);
}
/* `.button`: button-styled <a>, <button>, <input type=submit>.
* `.link`: any other <a>.
* `.tab`: tab-styled <a>.
*/
.button,
.link,
.tab {
cursor: pointer;
text-decoration: none;
white-space: nowrap;
}
.button,
.tab {
align-items: center;
color: var(--color-gray);
display: flex;
fill: var(--color-gray);
font-weight: bold;
}
.button {
border: 1px solid var(--color-gray);
border-radius: 0.25em;
font-size: 0.8rem;
padding: 0.6em 0.5em;
width: fit-content;
}
[name=cancel],
.auxiliary {
border-color: var(--color-border-gray);
color: var(--color-nav-gray);
fill: var(--color-nav-gray);
}
.button > svg,
.tab > svg {
height: 1.4em;
width: 1.4em;
}
.button > svg:not(:last-child),
.tab > svg:not(:last-child) {
margin-right: 0.2em;
}
.button:focus-visible,
.tab:focus-visible,
.tab:hover {
background-color: var(--color-focus-gray);
}
.button:hover {
background-color: var(--color-blue);
border-color: var(--color-blue);
color: white;
fill: white;
}
.dangerous:hover {
background-color: var(--color-red);
border-color: var(--color-red);
}
table .button {
border-color: var(--color-border-gray);
color: var(--color-table-gray);
font-weight: normal;
height: 100%;
padding: 0.4em;
}
/* TODO: move normal, non-button links (<a>:hover/:focus) styling here (i.e.
* page-wide, top-level) and remove from `table.items` - as the style should be
* same everywhere. */
/* TODO: apply link class to non-button/-tab links. Add light underscore for links? */
input[type=text]:read-only,
textarea:read-only {
border: none;
padding-inline: 0;
}
/* NOTE: collapse gaps around empty rows (`topside`) once possible with
* `grid-collapse` property and remove alternative `grid-template-areas`.
* https://github.com/w3c/csswg-drafts/issues/5813 */
body {
display: grid;
gap: 0.8em;
grid-template-areas:
"header header header"
"nav nav nav"
"leftside topside rightside"
"leftside main rightside";
grid-template-columns: 1fr minmax(max-content, 2fr) 1fr;
font-family: system-ui;
margin: 0.4em;
}
body:not(:has(.topside-area)) {
grid-template-areas:
"header header header"
"nav nav nav"
"leftside main rightside";
}
header {
grid-area: header;
}
.navigation {
display: flex;
grid-area: nav;
}
.navigation > .tab + .tab.right {
margin-inline-start: 4%;
}
.navigation > .tab {
border-bottom: 2px solid var(--color-nav-gray);
flex: 1;
font-size: 1rem;
justify-content: center;
padding-block: 0.4em;
}
.navigation > .tab.active {
border-bottom: 4px solid var(--color-blue);
color: var(--color-blue);
fill: var(--color-blue);
}
.topside-area {
grid-area: topside;
}
.leftside-area {
grid-area: leftside;
}
.main-area {
grid-area: main;
}
.rightside-area {
grid-area: rightside;
}
.buttongrid {
display: grid;
gap: 0.4em;
grid-template-areas: "context empty tools";
grid-template-columns: auto 1fr auto;
grid-template-rows: max-content;
}
.tools-area {
grid-area: tools;
}
#flashes {
display: grid;
row-gap: 0.4em;
grid-template-columns: 1fr auto auto auto 1fr;
left: 0;
pointer-events: none;
position: fixed;
right: 0;
top: 0.4em;
z-index: var(--z-index-flashes);
}
.flash {
align-items: center;
border-radius: 0.2em;
color: white;
display: grid;
grid-column: 2/5;
grid-template-columns: subgrid;
line-height: 2.2em;
pointer-events: auto;
}
.flash:before {
filter: invert();
height: 1.4em;
margin: 0 0.5em;
width: 1.4em;
}
.flash.alert:before {
content: url('pictograms/alert-outline.svg');
}
.flash.alert {
border-color: var(--color-red);
background-color: var(--color-red);
}
.flash.notice:before {
content: url('pictograms/check-circle-outline.svg');
}
.flash.notice {
border-color: var(--color-blue);
background-color: var(--color-blue);
}
.flash svg {
cursor: pointer;
fill: white;
height: 2.2em;
opacity: 0.6;
padding: 0.4em 0.5em;
width: 2.4em;
}
.flash svg:hover {
opacity: 1;
}
.labeled-form {
align-items: center;
display: grid;
gap: 0.9em 1.1em;
grid-template-columns: 1fr minmax(max-content, 0.5fr) 1fr;
}
.labeled-form label {
color: var(--color-gray);
font-size: 0.9rem;
grid-column: 1;
text-align: right;
white-space: nowrap;
}
.labeled-form label.required {
font-weight: bold;
}
/* Don't style `label.error + input` if case already covered by `input:invalid`. */
.labeled-form label.error {
color: var(--color-red);
}
.labeled-form em {
color: var(--color-text-gray);
font-size: 0.75rem;
font-weight: normal;
}
.labeled-form input {
grid-column: 2;
}
.labeled-form input[type=submit] {
font-size: 1rem;
margin: 1em auto 0 auto;
padding: 0.75em;
}
.labeled-form .auxiliary {
grid-column: 3;
/* If more buttons are needed, `grid-row` can be replaced with
* `reading-flow: grid-columns` to ensure proper [tabindex] order. */
grid-row: 1;
height: 100%;
padding-block: 0;
}
.tabular-form table {
border: none;
}
.tabular-form table td {
border: none;
text-align: left;
vertical-align: middle;
}
.tabular-form table td:first-child {
color: inherit;
}
.items-table {
border-spacing: 0;
border: 1px solid var(--color-border-gray);
border-radius: 0.25em;
font-size: 0.85rem;
text-align: left;
}
.items-table thead {
font-size: 0.8rem;
}
.items-table thead,
.items-table tbody tr:hover {
background-color: var(--color-focus-gray);
}
.items-table th {
padding-block: 0.75em;
text-align: center;
}
.items-table th,
.items-table td {
padding-inline: 1em 0;
}
/* For <a> to fill <td> completely, we use an `::after` pseudoelement. */
.items-table td.link {
padding: 0;
position: relative;
}
.items-table td.link a {
color: inherit;
font: inherit;
}
.items-table td.link a::after {
content: '';
inset: 0;
position: absolute;
}
.items-table td:first-child {
padding-inline-start: calc(1em + var(--depth) * 0.8em);
}
.items-table td:has(input, select, textarea) {
padding-inline-start: calc(0.6em - 0.9px);
}
.items-table td:first-child:has(input, select, textarea) {
padding-inline-start: calc(0.6em + var(--depth) * 0.8em - 0.9px);
}
.items-table th:last-child {
padding-inline-end: 0.4em;
}
.items-table td:last-child {
padding-inline-end: 0.1em;
}
.items-table td {
border-top: 1px solid var(--color-border-gray);
height: 2.4em;
padding-block: 0.1em;
}
.items-table .actions {
display: flex;
gap: 0.4em;
justify-content: end;
}
.items-table .actions.centered {
justify-content: center;
}
.items-table tr.dropzone {
position: relative;
}
.items-table tr.dropzone::after {
content: '';
inset: 1px 0 0 0;
position: absolute;
outline: 2px dashed var(--color-blue);
outline-offset: -1px;
z-index: var(--z-index-table-row-outline);
}
.items-table td.handle {
cursor: move;
}
.items-table tr.form td {
vertical-align: top;
}
/* TODO: replace `:hover:focus-visible` combos with proper LOVE style order. */
/* TODO: update table styling: simplify selectors, deduplicate, remove non-font rem. */
.items-table td.link a:hover,
.items-table td.link a:focus-visible,
.items-table td.link a:hover:focus-visible {
text-decoration: underline;
text-decoration-thickness: 0.05rem;
text-underline-offset: 0.2rem;
}
.items-table td.link a:hover {
color: var(--color-blue);
}
.items-table td.link a:focus-visible {
text-decoration-color: var(--color-gray);
}
.items-table td.link a:hover:focus-visible {
color: var(--color-dark-blue);
}
.items-table td:not(:first-child),
.grayed {
color: var(--color-table-gray);
fill: var(--color-table-gray);
}
.items-table svg {
height: 1rem;
vertical-align: middle;
width: 1rem;
}
.items-table svg:last-child {
height: 1.2rem;
width: 1.2rem;
}
.items-table td.svg {
text-align: center;
}
.items-table td.number {
text-align: right;
}
.centered {
margin: 0 auto;
}
.extendedright {
margin-right: auto;
}
.hexpand {
width: 100%;
}
.hflex {
display: flex;
gap: 0.8em;
}
.hflex.reverse {
flex-direction: row-reverse;
}
.hflex.centered {
justify-content: center;
}
.hint {
color: var(--color-table-gray);
font-style: italic;
font-size: 0.9rem;
text-align: center;
}
.hmin50 {
min-width: 50%;
}
.italic {
color: var(--color-gray);
font-style: italic;
}
.vflex {
display: flex;
gap: 0.8em;
flex-direction: column;
}
details {
align-content: center;
position: relative;
}
summary {
align-items: center;
color: var(--color-gray);
display: flex;
gap: 0.4em;
height: 100%;
white-space: nowrap;
}
summary::before {
background-color: currentColor;
content: "";
height: 1em;
mask-image: url('pictograms/chevron-down.svg');
mask-size: cover;
width: 1em;
}
summary:has(.button) {
padding-block: 0;
padding-inline-end: 0;
}
summary .button {
border: 1px solid var(--color-border-gray);
border-radius: inherit;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-style: none none none solid;
height: 100%;
}
summary span {
width: 100%;
}
details[open] summary::before {
transform: scaleY(-1);
}
summary::marker {
padding-left: 0.25em;
}
/* NOTE: use `details[open]::details-content` once widely available. */
details[open] ul {
background: white;
border: 1px solid var(--color-border-gray);
border-radius: 0.25em;
box-shadow: 1px 1px 3px var(--color-border-gray);
margin: -1px 0 0 0;
padding-left: 0;
position: absolute;
width: 100%;
}
li:hover {
background-color: var(--color-focus-gray);
}
li label {
align-items: center;
display: flex;
line-height: 1.4em;
}
li input[type=checkbox] {
margin: 0 0.25em;
}
li::marker {
content: '';
}
#measurement_form {
min-width: 66%;
width: max-content;
}
/*
* TODO:
* * disable <label> containing disabled checkbox: `label:has(input[disabled])`,
* * disabled label styling,
* * focused label styling (currently only checkbox has focus),
* * disabled checkbox blue square focus removal.
* */