Skip to content

LumexImage#273

Open
kevinvenclovas wants to merge 4 commits intoLumexUI:mainfrom
kevinvenclovas:lumex-image
Open

LumexImage#273
kevinvenclovas wants to merge 4 commits intoLumexUI:mainfrom
kevinvenclovas:lumex-image

Conversation

@kevinvenclovas
Copy link
Copy Markdown

@kevinvenclovas kevinvenclovas commented Feb 8, 2026

Description

Hi, want to help out on this nice repo and started with a small image component. Please if there is something to change let me know :)

What's been done?

  • Added Image component
  • Added docs and updates exist image with the new component

Checklist

  • My code follows the project's coding style and guidelines.
  • I have included inline docs for my changes, where applicable.
  • I have added, updated or removed tests according to my changes.
  • All tests are passing.
  • There's an open issue for the PR that I am making.

Additional Notes

Summary by CodeRabbit

  • New Features

    • Added a new Image component with blur levels, object-fit modes, radii, shadows, grayscale, width/height options, and click handling.
  • Documentation

    • Added a complete Image docs page with multiple interactive examples and preview snippets.
    • Updated navigation to include the new Image docs.
  • Tests

    • Added basic rendering tests for the Image component.
  • Chore

    • Updated solution/tooling metadata.

Introduce LumexImage, a customizable Blazor image component supporting object fit, blur, radius, shadow, and more. Replace all <img> tags in demo components with <LumexImage> for consistent styling. Add supporting enums, style logic, and a basic render test. Update solution file accordingly.
Introduced a GrayScale property to LumexImage, enabling grayscale rendering via a CSS class. Updated the Image class to apply the "grayscale" class when GrayScale is true. Also added pointer and hover styles when an OnClick handler is present. All changes are integrated into the GetStyles method for consistent styling.
Created /docs/components/image with interactive examples for all LumexImage features, including sizing, fit, radius, shadow, blur, grayscale, click handling, and custom styles. Updated navigation to include LumexImage and marked it as "New" where appropriate. All examples use PreviewCode and InteractiveWebAssembly rendering.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

Adds a new LumexImage component with supporting enums, styles, tests, and documentation examples; replaces raw img tags in docs with LumexImage; updates docs navigation and a solution metadata change.

Changes

Cohort / File(s) Summary
Solution & Navigation
LumexUI.sln, docs/LumexUI.Docs.Client/Common/Navigation/NavigationStore.cs
Tooling metadata change (VS version) and registration of LumexImage in the docs navigation lists.
New Image Component
src/LumexUI/Components/Image/LumexImage.razor, src/LumexUI/Components/Image/LumexImage.razor.cs, src/LumexUI/Styles/Image.cs
Implements LumexImage component, parameter surface (Src, Alt, Width, Height, Fit, FullWidth/Height, GrayScale, Shadow, Blur, Radius, OnClick) and style composition via Image.GetStyles. Adds runtime attribute injection for width/height.
Supporting Enums
src/LumexUI/Common/Enums/Blur.cs, src/LumexUI/Common/Enums/ObjectFit.cs
Adds Blur and ObjectFit enums used by the image component.
Docs: Image page & previews
docs/.../Image/Image.razor, docs/.../Image/Examples/*, docs/.../Image/PreviewCodes/*
Adds Image documentation page, many example Razor snippets (Blur, Click, Grayscale, ObjectFit, Radius, Shadow, Width/Height, CustomStyles, Usage) and corresponding interactive preview components.
Docs: Component migrations
docs/.../Card/Examples/BlurredFooter.razor, docs/.../Card/Examples/CoverImage.razor, docs/.../Card/Examples/Image.razor, docs/.../Select/Examples/CustomItems.razor, docs/.../Select/Examples/CustomStyles.razor, docs/.../Select/Examples/CustomValues.razor, docs/.../Select/Examples/ItemStartEndContent.razor
Replaces raw <img> tags with LumexImage usages across card and select example pages, mapping attributes to the component API and adding Fit/Alt where applicable.
Tests
tests/LumexUI.Tests/Components/Image/ImageTests.cs
Adds a basic test ensuring LumexImage renders without throwing; registers TwMerge in test DI.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

Suggested labels

📦 Scope: Components, 🚀 Type: Feature

Suggested reviewers

  • desmondinho

Poem

🐰 I hopped a code patch bright and new,
I painted pixels, blurred the view,
With radius, shadow, fit so fine,
The docs now show each styled design,
Hooray — a shiny LumexImage, from me to you! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description covers the main changes and includes a mostly completed checklist, but omits the key information that there's no open issue referenced despite the template requirement.
Title check ✅ Passed The title "LumexImage" directly corresponds to the main feature added in this PR - a new Image component called LumexImage with supporting enums, styles, documentation, tests, and demo updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🤖 Fix all issues with AI agents
In `@docs/LumexUI.Docs.Client/Pages/Components/Image/Examples/ImageRadius.razor`:
- Around line 1-7: Add descriptive Alt attributes to each LumexImage example so
the sample demonstrates accessible usage; update the five LumexImage instances
(the ones using Radius.None, Radius.Small, Radius.Medium, Radius.Large,
Radius.Full) to include Alt strings like "Radius none example", "Radius small
example", etc., ensuring each image has a meaningful alt attribute.

In `@docs/LumexUI.Docs.Client/Pages/Components/Image/Image.razor`:
- Around line 89-106: The "Custom Styles" docs incorrectly mention the Classes
dictionary for targeting internal slots even though the LumexImage component
renders only a single <img> element; update the Image.razor docs to remove or
change the Classes bullet so it no longer suggests internal slot
targeting—either delete the `<code>Classes</code>` list item or replace it with
a clarifying sentence stating that LumexImage only supports `Class` and `Style`
(no internal slots), referencing the component name LumexImage and the `Class`
and `Style` parameters to guide the change.
- Around line 72-75: The DocsSection title uses "GrayScale" but the in-text
<code> shows "Grayscale"; update the documentation so the <code> tag matches the
actual component parameter name GrayScale (as defined in LumexImage.razor.cs) to
ensure consistent casing—locate the DocsSection Title="GrayScale" block and
change the inline <code> content from "Grayscale" to "GrayScale".

In `@src/LumexUI/Components/Image/LumexImage.razor`:
- Line 5: Fix the typo in the inline comment in LumexImage.razor: change "bigger
den zero" to "bigger than zero" in the comment that explains adding width and
height only when values are greater than zero (the comment above the
width/height handling logic in the LumexImage.razor component).

In `@src/LumexUI/Components/Image/LumexImage.razor.cs`:
- Around line 15-17: Update the XML documentation in LumexImage.razor.cs to
replace incorrect "button" references with "image": change the component summary
to "A component representing an image.", update the property/event docs (e.g.,
the "radius of the button" summary to "radius of the image" and "button is
clicked" to "image is clicked"), and correct any stray type/name mentions from
LumexButton to LumexImage (inspect the LumexImage class, its Radius property and
click event XML comments and update them accordingly).

In `@src/LumexUI/Styles/Image.cs`:
- Around line 45-52: Rename the misleading parameter in GetBlurStyles from
shadow to blur and update the method signature and all internal references (the
parameter checks like "when: shadow is Blur.None" -> "when: blur is Blur.None");
also update any callers of GetBlurStyles to pass a variable named blur (or keep
callers unchanged if they pass by position) so the symbol name matches intent
and compiles cleanly; ensure the method signature and any XML docs or tests
referencing GetBlurStyles are updated to the new parameter name.
- Around line 54-62: GetObjectFitStyles currently adds "object-none" when
LumexImage.Fit is the enum default (ObjectFit.None), causing unwanted
object-none being applied; update the caller in GetStyles to only invoke
GetObjectFitStyles when LumexImage.Fit has been explicitly set (i.e., Fit !=
default(ObjectFit) or Fit != ObjectFit.None), so default/unspecified images
don't receive the object-none class; keep GetObjectFitStyles unchanged but make
its usage conditional based on LumexImage.Fit.

In `@tests/LumexUI.Tests/Components/Image/ImageTests.cs`:
- Around line 17-23: The test method is misnamed: change the method name
Button_ShouldRenderCorrectly to Image_ShouldRenderCorrectly so it accurately
reflects the component under test; locate the test method that calls
RenderComponent<LumexImage>() (currently named Button_ShouldRenderCorrectly) and
rename the method to Image_ShouldRenderCorrectly, keeping the body and assertion
(action.Should().NotThrow()) unchanged.
🧹 Nitpick comments (4)
docs/LumexUI.Docs.Client/Pages/Components/Image/Examples/CustomStyles.razor (1)

1-3: Consider adding an Alt attribute for accessibility.

This example (and several other new Image examples like ImageGrayscale, ImageWidthHeight) omit the Alt prop. Since these serve as documentation examples that users will copy, it would be good practice to demonstrate accessible image usage with descriptive alt text.

Proposed fix
 <LumexImage
     Src="https://picsum.photos/id/101/400/300"
-    Class="border-4 border-blue-500 rounded-xl shadow-xl" />
+    Alt="Sample image"
+    Class="border-4 border-blue-500 rounded-xl shadow-xl" />
docs/LumexUI.Docs.Client/Pages/Components/Image/Examples/ImageWidthHeight.razor (1)

1-4: Grid declares 3 columns but only contains 2 items.

grid-cols-3 with only 2 children leaves an empty cell. Consider using grid-cols-2 unless the extra space is intentional for visual layout purposes.

tests/LumexUI.Tests/Components/Image/ImageTests.cs (1)

17-23: Test coverage is very thin — consider adding tests for key parameters and the OnClick callback.

The component exposes Blur, ObjectFit, Radius, Shadow, GrayScale, Width/Height, FullWidth/FullHeight, and OnClick. A single "doesn't throw" test leaves these untested. At minimum, verifying that setting parameters produces expected CSS classes (via RootClass / TwMerge) and that OnClick fires would strengthen confidence.

src/LumexUI/Components/Image/LumexImage.razor.cs (1)

23-28: Src and Alt are non-nullable strings with no default value.

In Blazor, unset parameters will be null at runtime despite the non-nullable declaration, which could cause NullReferenceException or compiler warnings. Consider defaulting to string.Empty or making them nullable.

Proposed fix
-	[Parameter] public string Src { get; set; }
+	[Parameter] public string Src { get; set; } = string.Empty;

-	[Parameter] public string Alt { get; set; }
+	[Parameter] public string Alt { get; set; } = string.Empty;

Comment thread docs/LumexUI.Docs.Client/Pages/Components/Image/Image.razor
Comment thread docs/LumexUI.Docs.Client/Pages/Components/Image/Image.razor
Comment thread src/LumexUI/Components/Image/LumexImage.razor Outdated
Comment thread src/LumexUI/Components/Image/LumexImage.razor.cs
Comment thread src/LumexUI/Styles/Image.cs Outdated
Comment thread src/LumexUI/Styles/Image.cs
Comment thread tests/LumexUI.Tests/Components/Image/ImageTests.cs
- Add Alt="Lumex Image" to all LumexImage usages in demo/example .razor files for accessibility and HTML validity.
- Update Image.razor docs: fix grayscale parameter typo and clarify custom styles usage.
- Correct XML docs in LumexImage.razor.cs to refer to "image" instead of "button".
- Fix parameter naming in GetBlurStyles (Image.cs) from shadow to blur.
- Rename test method to Image_ShouldRenderCorrectly in ImageTests.cs.
- Fix minor comment typo in LumexImage.razor.
@desmondinho
Copy link
Copy Markdown
Contributor

Hey @kevinvenclovas,

Thank you very much for the PR! I am sorry for the long wait. I will review this asap.

@kevinvenclovas kevinvenclovas changed the title Lumex image LumexImage Feb 22, 2026
Copy link
Copy Markdown
Contributor

@desmondinho desmondinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kevinvenclovas,

Thank you very much for this PR -- it’s great work.

I noticed that the two components you implemented don't fully align with HeroUI's capabilities, structure, and/or styles. Since I'm aiming to achieve 100% parity, could you please make sure they closely follow the HeroUI components?

For reference: https://www.heroui.com/docs/components/image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This styling structure is old and I am trying to get rid of this asap, so it's better to use a new one. Please see Avatar or Alert for the reference.

@namespace LumexUI
@inherits LumexComponentBase

@{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use width and height attributes directly.

Comment on lines +23 to +28
[Parameter] public string Src { get; set; }

/// <summary>
/// Gets or sets the alt of the image.
/// </summary>
[Parameter] public string Alt { get; set; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing nullability operators -- compiler's gonna warn

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this file since it's an abstraction for a simple CSS classes. We don't do that. The only exception is Radius, though I wish I didn't introduce it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants