Add NumberCircle Component

This commit is contained in:
araemer 2025-10-25 18:36:03 +02:00
parent 0b549c878c
commit 9f550bbce1
5 changed files with 42 additions and 15 deletions

View file

@ -52,10 +52,6 @@
/* containers */ /* containers */
.circular-container {
@apply flex-shrink-0 w-7 h-7 rounded-full bg-blue-300 text-white flex items-center justify-center shadow-sm;
}
.highlight-container-bg { .highlight-container-bg {
@apply bg-gray-200 rounded p-2; @apply bg-gray-200 rounded p-2;
} }

View file

@ -0,0 +1,29 @@
import clsx from "clsx";
import React from "react";
type NumberCircleProps = React.HTMLAttributes<HTMLDivElement> & {
/** The number displayed inside the circle */
number: number;
};
/**
* A small circular badge displaying a number.
*
* Can be used as a standalone indicator or as a drag handle.
* Accepts any div attributes (e.g. `className`, `title`, `onClick`, or DnD listeners).
*/
export function NumberCircle({ number, className, ...rest }: NumberCircleProps) {
return (
<div
{...rest}
className={clsx(
"flex-shrink-0 w-7 h-7 rounded-full bg-blue-300 text-white",
"flex items-center justify-center shadow-sm",
"cursor-default select-none",
className
)}
>
{number}
</div>
);
}

View file

@ -1,4 +1,5 @@
import clsx from "clsx"; import clsx from "clsx";
import {NumberCircle} from "./NumberCircle.tsx";
type NumberedListItemProps = { type NumberedListItemProps = {
/** Index of the element. Index + 1 is displayed in circle */ /** Index of the element. Index + 1 is displayed in circle */
@ -18,9 +19,9 @@ export function NumberedListItem({index, text, className = ""}: NumberedListItem
"flex items-start gap-4", "flex items-start gap-4",
className)}> className)}>
{/* Step number circle */} {/* Step number circle */}
<div className="circular-container"> <NumberCircle
{index + 1} number={index + 1}
</div> />
{/* Step text */} {/* Step text */}
<p className="leading-relaxed">{text}</p> <p className="leading-relaxed">{text}</p>

View file

@ -8,6 +8,7 @@ import type {InstructionStepModel} from "../../models/InstructionStepModel";
import Button from "../basics/Button"; import Button from "../basics/Button";
import {X} from "lucide-react" import {X} from "lucide-react"
import {ButtonType} from "../basics/BasicButtonDefinitions"; import {ButtonType} from "../basics/BasicButtonDefinitions";
import {NumberCircle} from "../basics/NumberCircle.tsx";
type InstructionStepDesktopListItemProps = { type InstructionStepDesktopListItemProps = {
id: string | number; id: string | number;
@ -34,14 +35,13 @@ export function InstructionStepDesktopListItem({
style={style} style={style}
className="flex items-start gap-3" className="flex items-start gap-3"
> >
<div <NumberCircle
{...attributes} {...attributes}
{...listeners} {...listeners}
className="circular-container cursor-grab" number={index + 1}
className="cursor-grab"
title="Ziehen, um neu zu ordnen" title="Ziehen, um neu zu ordnen"
> />
{index + 1}
</div>
<textarea <textarea
className="w-full min-h-[60px] resize-none overflow-hidden" className="w-full min-h-[60px] resize-none overflow-hidden"

View file

@ -3,6 +3,7 @@ import {X} from "lucide-react";
import {ButtonType} from "../basics/BasicButtonDefinitions.ts"; import {ButtonType} from "../basics/BasicButtonDefinitions.ts";
import type {InstructionStepModel} from "../../models/InstructionStepModel.ts"; import type {InstructionStepModel} from "../../models/InstructionStepModel.ts";
import {MoveButtonControl} from "../basics/MoveButtonControl.tsx"; import {MoveButtonControl} from "../basics/MoveButtonControl.tsx";
import {NumberCircle} from "../basics/NumberCircle.tsx";
type InstructionStepMobileListItemProps = { type InstructionStepMobileListItemProps = {
/** Index of the instruction step */ /** Index of the instruction step */
@ -61,9 +62,9 @@ export function InstructionStepMobileListItem({
> >
{/* Left column: Number of the instruction step and move controls */} {/* Left column: Number of the instruction step and move controls */}
<div className="flex flex-col items-center pt-1"> <div className="flex flex-col items-center pt-1">
<div className="circular-container"> <NumberCircle
{index + 1} number={index + 1}
</div> />
<MoveButtonControl <MoveButtonControl
isUpDisabled={isFirst} isUpDisabled={isFirst}
isDownDisabled={isLast} isDownDisabled={isLast}