From 4145cec102b7ca3677a934cc4dff35977b681599 Mon Sep 17 00:00:00 2001 From: johannes-hernehult Date: Wed, 8 Jul 2026 21:41:41 +0200 Subject: [PATCH] Refactor Frame usage and improve HTML semantics * Extract inline guide frames into a reusable Frame component * Update step elements to use proper ordered lists (
    and
  1. ) * Move related image and list styling to Frame.css --- src/components/frame/Frame.tsx | 18 ++++++++++++++++++ src/features/guides/components/Frame.css | 10 ++++++++++ src/features/guides/components/Frame.tsx | 4 ++-- src/features/guides/components/Step.tsx | 4 ++-- src/features/guides/routes/Guide.css | 23 ++++++++--------------- src/features/guides/routes/Guide.tsx | 14 ++------------ 6 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 src/components/frame/Frame.tsx diff --git a/src/components/frame/Frame.tsx b/src/components/frame/Frame.tsx new file mode 100644 index 0000000..566b516 --- /dev/null +++ b/src/components/frame/Frame.tsx @@ -0,0 +1,18 @@ +import type { FrameType } from "../../lib/schemas"; + +export default function Frame({ frame } : { frame: FrameType }) { + return ( +
    +

    {frame.title}

    + {frame.title} + +
      + {frame.steps.map((step, stepIndex) => ( +
    1. + {step.text} +
    2. + ))} +
    +
    + ); +} diff --git a/src/features/guides/components/Frame.css b/src/features/guides/components/Frame.css index cbf8e5b..54ba5fd 100644 --- a/src/features/guides/components/Frame.css +++ b/src/features/guides/components/Frame.css @@ -8,6 +8,12 @@ border-radius: var(--radius); } +.frame img { + max-height: 350px; + object-fit: contain; + object-position: left center; +} + .frame .buttons { display: flex; gap: var(--size-md); @@ -20,3 +26,7 @@ .frame .buttons .remove { margin-left: auto; } + +.frame ol { + margin-left: var(--size-md); +} diff --git a/src/features/guides/components/Frame.tsx b/src/features/guides/components/Frame.tsx index c62362b..a7f60b4 100644 --- a/src/features/guides/components/Frame.tsx +++ b/src/features/guides/components/Frame.tsx @@ -72,7 +72,7 @@ export default function Frame({ > Add Step -
    +
      {frame.steps.map((step: StepType, index: number) => ( ))} -
    +
); } diff --git a/src/features/guides/components/Step.tsx b/src/features/guides/components/Step.tsx index a535df8..15ecce7 100644 --- a/src/features/guides/components/Step.tsx +++ b/src/features/guides/components/Step.tsx @@ -13,7 +13,7 @@ export default function Step({ index: number; }) { return ( -
+
  • + ); } diff --git a/src/features/guides/routes/Guide.css b/src/features/guides/routes/Guide.css index 2d82ec1..fc96af4 100644 --- a/src/features/guides/routes/Guide.css +++ b/src/features/guides/routes/Guide.css @@ -3,11 +3,13 @@ main:has(.guide) { display: flex; justify-content: center; } + .guide__frames { display: flex; flex-direction: column; gap: var(--size-xl); } + .guide { max-width: 600px; .delete-button { @@ -15,40 +17,30 @@ main:has(.guide) { bottom: var(--size-md); right: var(--size-md); } + .edit-button { position: absolute; top: var(--size-md); right: 8rem; } + .export-button { position: absolute; top: var(--size-md); right: var(--size-md); } - .guide__frame { - padding: var(--size-md); - background-color: var(--color-bg-panel); - display: flex; - flex-direction: column; - gap: var(--size-sm); - } - .guide__frame img { - max-height: 350px; - object-fit: contain; - object-position: left center; - } - .guide__frame ol { - margin-left: var(--size-md); - } + } @media print { main:has(.guide) { padding: 0rem; justify-content: flex-start; } + .guide__frames { display: block; } + .guide__frame { position: relative; break-inside: avoid; @@ -56,6 +48,7 @@ main:has(.guide) { background-color: var(--color-bg-panel); margin: var(--size-lg) 0; } + .guide__frame img { max-width: 100%; max-height: 100px; diff --git a/src/features/guides/routes/Guide.tsx b/src/features/guides/routes/Guide.tsx index 779b47b..2d4f023 100644 --- a/src/features/guides/routes/Guide.tsx +++ b/src/features/guides/routes/Guide.tsx @@ -2,6 +2,7 @@ import "./Guide.css"; import { useParams, Link } from "react-router"; import { useGuides } from "../../../lib/contexts/guide.context"; import useGuide from "../hooks/useGuide"; +import Frame from "../../../components/frame/Frame"; export default function Guide() { const { id } = useParams(); @@ -20,18 +21,7 @@ export default function Guide() {
    {guide.frames.map((frame, index) => ( -
    -

    {frame.title}

    - {frame.title} - -
      - {frame.steps.map((step, stepIndex) => ( -
    1. - {step.text} -
    2. - ))} -
    -
    + ))}