To enhance the visual appeal of your numerical comparison figures and make them more professional-looking, we can leverage Tailwind CSS and Shadcn's design principles to create a visually pleasing and intuitive UI. Here's how we can improve your code:
Key Improvements:
-
Dynamic Styling for Similarity Percentage:
- Use conditional styling to dynamically change the text color based on the similarity percentage (neutral blue, orange, or red).
- Add subtle background highlights or borders to emphasize the status.
-
Typography Enhancements:
- Use a slightly larger font size for better readability.
- Add weight to the text for emphasis.
-
Spacing and Alignment:
- Ensure consistent spacing and alignment between elements for a clean look.
-
Visual Indicators:
- Add small icons or badges to indicate the status (e.g., checkmarks for neutral, warning signs for orange, and error icons for red).
Here’s the updated code:
<div className="flex justify-center gap-5 w-full max-w-[380px] mx-auto mt-2">
{/* First Numerical Value */}
<div
className={cn(
"text-sm uppercase font-medium px-2 py-1 rounded-md text-center",
lastSimilarityAmount >= 70
? "bg-blue-100 text-blue-600 dark:bg-blue-900 dark:text-blue-300"
: lastSimilarityAmount >= 50
? "bg-orange-100 text-orange-600 dark:bg-orange-900 dark:text-orange-300"
: "bg-red-100 text-red-600 dark:bg-red-900 dark:text-red-300"
)}
>
{lastSimilarityAmount === 0 ? "-" : lastSimilarityAmount}
</div>
{/* VS Separator */}
<div className="text-sm uppercase text-muted-foreground">vs</div>
{/* Second Numerical Value */}
<div
className={cn(
"text-sm uppercase font-medium px-2 py-1 rounded-md text-center",
lastComparisonAmount >= 70
? "bg-blue-100 text-blue-600 dark:bg-blue-900 dark:text-blue-300"
: lastComparisonAmount >= 50
? "bg-orange-100 text-orange-600 dark:bg-orange-900 dark:text-orange-300"
: "bg-red-100 text-red-600 dark:bg-red-900 dark:text-red-300"
)}
>
{lastComparisonAmount === 0 ? "-" : lastComparisonAmount}
</div>
</div>
{/* Canvases */}
<div className="flex justify-center gap-5 w-full max-w-[380px] mx-auto mt-2">
<canvas
ref={screenshotCanvasTest1Ref}
width="185"
height="50"
className={cn(
"border-0 h-[50px] rounded bg-black w-full",
imprintNow && "border-2 animate-[wiggle_1s_ease-in-out_2]"
)}
/>
<canvas
ref={screenshotCanvasTest2Ref}
width="185"
height="50"
className="border-0 h-[50px] rounded bg-transparent w-full"
/>
</div>
Explanation of Changes:
-
Dynamic Background and Text Colors:
- The
cn utility from Shadcn is used to conditionally apply styles based on the similarity percentage.
- Neutral blue (
bg-blue-100, text-blue-600) is used when the percentage is above 70%.
- Orange (
bg-orange-100, text-orange-600) is applied for percentages between 50% and 70%.
- Red (
bg-red-100, text-red-600) is used for percentages below 50%.
-
Padding and Rounded Corners:
- Added
px-2 py-1 for padding and rounded-md for rounded corners to give the numbers a card-like appearance.
-
Font Adjustments:
- Increased font size to
text-sm for better readability.
- Used
font-medium to make the text stand out.
-
Dark Mode Support:
- Included dark mode variants (
dark:bg-* and dark:text-*) to ensure the design looks good in both light and dark themes.
-
Consistent Spacing:
- Maintained consistent spacing between the numerical values and the canvases using
gap-5.
Optional Enhancements:
- Icons: You can add small icons (e.g., checkmark for blue, warning triangle for orange, and exclamation mark for red) using libraries like
Lucide React or Heroicons.
- Tooltips: Add tooltips to explain the meaning of the colors when hovering over the numbers.
- Animation: Add subtle animations (e.g., fade-in or glow) to highlight changes in the similarity percentage.
This approach ensures that your numerical comparison figures are elegant, visually appealing, and intuitive for users to interpret.