refactor(styles): migrate hardcoded CSS values to variables

* Define global variables for colors, layout, and spacing scales in
* Replace hardcoded padding, gap, color, and border values with CSS variables across guide components (, , , , )
* Add  utility class to guide frames in  for unified styling
This commit is contained in:
johannes-hernehult 2026-07-08 20:52:13 +02:00
parent 075e41ec89
commit a329ed1cbe
7 changed files with 70 additions and 100 deletions

View file

@ -3,14 +3,14 @@
place-items: center; place-items: center;
cursor: pointer; cursor: pointer;
border-style: dashed; border-style: dashed;
padding: 2rem; padding: var(--size-lg);
font-weight: bold; font-weight: bold;
&:hover, &:hover,
&:focus-visible { &:focus-visible {
border-color: #ff770080; border-color: var(--color-accent-border);
color: #ff7700; color: var(--color-accent);
background-color: #ff770010; background-color: var(--color-accent-bg-subtle);
} }
} }

View file

@ -1,27 +1,22 @@
.frame { .frame {
padding: 1rem; padding: var(--size-md);
background: #ddd; background: var(--color-bg-panel);
border-left: 3px solid var(--color-accent-border);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 1rem; gap: var(--size-md);
border-radius: var(--radius);
} }
.frame .buttons { .frame .buttons {
display: flex; display: flex;
gap: 1rem; gap: var(--size-md);
} }
.frame .buttons button { .frame .buttons button {
padding: 0.5rem 1rem; padding: var(--size-sm) var(--size-md);
} }
.frame .buttons .remove { .frame .buttons .remove {
margin-left: auto; margin-left: auto;
} }
.frame .steps {
display: flex;
flex-direction: column;
gap: 1rem;
}

View file

@ -1,12 +1,12 @@
.step { .step {
display: flex; display: flex;
gap: 1rem; gap: var(--size-md);
} }
.step label { .step label {
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
gap: 0.5rem; gap: var(--size-sm);
flex: 1; flex: 1;
} }

View file

@ -1,73 +1,61 @@
main:has(.guide) { main:has(.guide) {
padding: 1rem 7rem; padding: var(--size-md) 7rem;
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.guide__frames { .guide__frames {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 3rem; gap: var(--size-xl);
} }
.guide { .guide {
max-width: 600px; max-width: 600px;
.delete-button { .delete-button {
position: absolute; position: absolute;
bottom: 1rem; bottom: var(--size-md);
right: 1rem; right: var(--size-md);
} }
.edit-button { .edit-button {
position: absolute; position: absolute;
top: 1rem; top: var(--size-md);
right: 8rem; right: 8rem;
} }
.export-button { .export-button {
position: absolute; position: absolute;
top: 1rem; top: var(--size-md);
right: 1rem; right: var(--size-md);
} }
.guide__frame { .guide__frame {
padding: 1rem; padding: var(--size-md);
background-color: #dedede; background-color: var(--color-bg-panel);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.5rem; gap: var(--size-sm);
} }
.guide__frame img { .guide__frame img {
max-height: 350px; max-height: 350px;
object-fit: contain; object-fit: contain;
object-position: left center; object-position: left center;
} }
.guide__frame ol { .guide__frame ol {
margin-left: 1rem; margin-left: var(--size-md);
} }
} }
@media print { @media print {
main:has(.guide) { main:has(.guide) {
padding: 0rem; padding: 0rem;
justify-content: flex-start; justify-content: flex-start;
} }
.guide__frames { .guide__frames {
display: block; display: block;
} }
.guide__frame { .guide__frame {
position: relative; position: relative;
break-inside: avoid; break-inside: avoid;
page-break-inside: avoid; page-break-inside: avoid;
background-color: #dedede; background-color: var(--color-bg-panel);
margin: var(--size-lg) 0;
margin: 2rem 0;
} }
.guide__frame img { .guide__frame img {
max-width: 100%; max-width: 100%;
max-height: 100px; max-height: 100px;

View file

@ -20,7 +20,7 @@ export default function Guide() {
<div className="guide__frames"> <div className="guide__frames">
{guide.frames.map((frame, index) => ( {guide.frames.map((frame, index) => (
<div key={index} className="guide__frame"> <div key={index} className="guide__frame frame">
<h2>{frame.title}</h2> <h2>{frame.title}</h2>
<img src={URL.createObjectURL(frame.file)} alt={frame.title} /> <img src={URL.createObjectURL(frame.file)} alt={frame.title} />

View file

@ -3,16 +3,13 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
.new-guide__form { .new-guide__form {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 2rem; gap: var(--size-lg);
width: 100%; width: 100%;
max-width: 540px; max-width: 540px;
} }
.new-guide__form label { .new-guide__form label {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View file

@ -1,114 +1,114 @@
:root { :root {
/* color */
--color-border: #ccc; --color-border: #ccc;
--color-bg-sidebar: #eee; --color-bg-sidebar: #eee;
--sidebar-width: 250px; --color-bg-panel: #fafafa;
--gap-nav: 1rem; --color-accent: #ff7700;
} --color-accent-hover: #ff9900;
--color-accent-border: #ff770080;
--color-accent-bg-subtle: #ff770010;
/* layout */
--sidebar-width: 250px;
--radius: 4px;
/* spacing scale */
--size-xs2: 0.125rem;
--size-xs: 0.25rem;
--size-sm: 0.5rem;
--size-md: 1rem;
--size-lg: 2rem;
--size-xl: 3rem;
}
html, html,
body { body {
font-family: system-ui, Arial, sans-serif; font-family: system-ui, Arial, sans-serif;
position: relative; position: relative;
} }
#root { #root {
min-height: 100vh; min-height: 100vh;
} }
.app-body { .app-body {
display: flex; display: flex;
flex: 1; flex: 1;
} }
header { header {
position: fixed; position: fixed;
height: 100%; height: 100%;
width: var(--sidebar-width); width: var(--sidebar-width);
padding: 1rem; padding: var(--size-md);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
gap: var(--gap-nav); gap: var(--size-sm);
border-right: 3px solid var(--color-border); border-right: 3px solid var(--color-border);
background-color: var(--color-bg-sidebar); background-color: var(--color-bg-sidebar);
.main-title a { .main-title a {
text-decoration: none; text-decoration: none;
color: inherit; color: inherit;
} }
.create-new-guide-btn { .create-new-guide-btn {
padding: 0.5rem 1rem; padding: var(--size-sm) var(--size-md);
border-radius: 4px; border-radius: var(--radius);
background-color: #ff7700; background-color: var(--color-accent);
color: #fff; color: #fff;
text-decoration: none; text-decoration: none;
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;
} }
.guide-list { .guide-list {
list-style: none; list-style: none;
padding: 0; padding: 0;
margin-top: 0.5rem; margin-top: var(--size-sm);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.5rem; gap: var(--size-sm);
} }
} }
main { main {
margin-left: var(--sidebar-width); margin-left: var(--sidebar-width);
flex: 1; flex: 1;
padding: 1rem; padding: var(--size-md);
} }
footer { footer {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
margin: 0 auto; margin: 0 auto;
padding: 0.5rem; padding: var(--size-sm);
text-align: center; text-align: center;
width: var(--sidebar-width); width: var(--sidebar-width);
} }
nav { nav {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
padding-bottom: 2rem; padding-bottom: var(--size-lg);
width: 100%; width: 100%;
a { a {
padding: 0.6rem 1rem 0.5rem; padding: 0.6rem var(--size-md) 0.5rem;
border-radius: 4px; border-radius: var(--radius);
line-height: 1; line-height: 1;
display: block; display: block;
} }
.settings-btn { .settings-btn {
margin-top: auto; margin-top: auto;
align-self: center; align-self: center;
font-weight: bold; font-weight: bold;
} }
.settings-btn.active { .settings-btn.active {
margin-top: auto; margin-top: auto;
align-self: center; align-self: center;
color: #ff7700; color: var(--color-accent);
} }
h2 { h2 {
margin-top: 2rem; margin-top: var(--size-lg);
font-size: 1rem; font-size: 1rem;
opacity: 0.5; opacity: 0.5;
} }
li { li {
width: 100%; width: 100%;
} }
.guide-list a { .guide-list a {
transition: transition:
background-color 0.125s, background-color 0.125s,
@ -116,25 +116,22 @@ nav {
background-color: #fff; background-color: #fff;
border-left: 4px solid var(--color-border); border-left: 4px solid var(--color-border);
} }
.guide-list a.active { .guide-list a.active {
background-color: #fff; background-color: #fff;
border-left: 4px solid #ff7700; border-left: 4px solid var(--color-accent);
} }
.guide-list a:hover:not(.active) { .guide-list a:hover:not(.active) {
border-left: 4px solid #ff9900; border-left: 4px solid var(--color-accent-hover);
opacity: 0.8; opacity: 0.8;
} }
} }
ul { ul {
padding: 0; padding: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.125rem; gap: var(--size-xs);
list-style: none; list-style: none;
} }
a, a,
input, input,
button, button,
@ -144,37 +141,30 @@ textarea {
font-size: inherit; font-size: inherit;
color: inherit; color: inherit;
} }
a { a {
text-decoration: none; text-decoration: none;
} }
input, input,
textarea, textarea,
.file-upload { .file-upload {
border: 3px solid var(--color-border); border: 2px solid var(--color-bg-sidebar);
border-radius: 4px; border-radius: var(--radius);
padding: 0.25rem; padding: var(--size-sm);
} }
textarea { textarea {
resize: none; resize: none;
height: 5rem; height: 5rem;
} }
hr { hr {
margin: 1rem 0; margin: var(--size-md) 0;
border: none; border: none;
height: 3px; height: 3px;
background-color: var(--color-border); background-color: var(--color-bg-sidebar);
border-radius: 4px; border-radius: var(--radius);
} }
:focus-visible { :focus-visible {
outline: 2px solid #ff7700; border: 2px solid var(--color-accent);
outline-offset: 2px;
} }
@media print { @media print {
header, header,
footer, footer,