Skip to content

Implement inline loading component - #129

Open
jayvijaygohil wants to merge 8 commits into
gabrieldrn:mainfrom
jayvijaygohil:103-implement-inline-loading-component
Open

Implement inline loading component#129
jayvijaygohil wants to merge 8 commits into
gabrieldrn:mainfrom
jayvijaygohil:103-implement-inline-loading-component

Conversation

@jayvijaygohil

@jayvijaygohil jayvijaygohil commented Apr 9, 2026

Copy link
Copy Markdown

Notes / Description

This PR adds the InlineLoading component set to the shared carbon module, including both the standalone inline loading primitive and an InlineLoadingButton variant.

Resolves

What's included

  • New InlineLoading composable in commonMain
  • New InlineLoadingStatus enum with the supported states:
    • Inactive
    • Active
    • Finished
    • Error
  • Accessibility semantics for inline loading (let me know if this needs to be changed as I am not so sure of the requirements):
    • polite live region while loading/inactive
    • assertive live region for finished/error states
    • default status content descriptions when no visible label is provided
    • optional custom contentDescription override
  • New InlineLoadingButton composable in commonMain:
    • replaces the triggering button with inline loading feedback while work is in progress
    • preserves the previous button width/height during state transitions
    • supports button icon/type/size options
  • Compose UI tests covering:
    • standalone inline loading layout/rendering for each state
    • label/icon visibility
    • accessibility content descriptions
    • live region behavior
    • inline loading button state transitions and sizing behavior
  • Catalog updates:
    • add a dedicated Inline loading demo destination/screen
    • include both standalone and button usage demos with interactive state controls
  • Public API dump update for both InlineLoading and InlineLoadingButton
  • Docs update:
    • add Inline loading to the components index
    • add Inline loading button to the components index
    • mark Inline loading as available in the component availability matrix

Platforms testing checklist

  • Android
  • iOS
  • Desktop
    • Linux (needs test)
    • Apple
    • Windows (needs test)
  • WASM (needs test)

Screenshots / videos

Screenshot 2026-04-09 at 12 24 57 AM Screenshot 2026-04-09 at 12 25 08 AM

@jayvijaygohil
jayvijaygohil marked this pull request as draft April 9, 2026 04:53
@jayvijaygohil
jayvijaygohil force-pushed the 103-implement-inline-loading-component branch from 4fa760d to cbb7994 Compare April 9, 2026 05:37
@jayvijaygohil
jayvijaygohil marked this pull request as ready for review April 9, 2026 05:37
* @param interactionSource The [MutableInteractionSource] that keeps track of the button's state.
*/
@Composable
public fun InlineLoadingButton(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Would it be better to add an overload to Button instead of creating a separate InlineLoadingButton component? I wasn't sure which approach aligns best with the architecture.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@gabrieldrn gabrieldrn Apr 13, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

That's a good question. The approach I would have taken is integrating the inline loading directly into the button component, making it available with an optional inlineLoadingState: InlineLoadingState? = null. Default null value meaning no loading.
If you look at the existing Button API, you'll see that there's an alt one wrapping the component to display a tooltip. If we are to create an InlineLoadingButton, then we also need to make a tooltip alt, thus increasing the API complexity, tests and maintenance efforts.
For instance, by just adding a parameter to the existing APIs, you just need to add a coverage for it in the existing tests, instead of creating a new test class, and it would require re-writing the same test from the Button tests, or refactor them in an abstraction to be shared between the two implementations.
What do you think?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure! I can defo. do that. No issues.

@gabrieldrn gabrieldrn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you for your contribution, and sorry for the late notice. Very clean work!

* (From [Inline loading documentation](https://carbondesignsystem.com/components/inline-loading/usage))
*/
@Immutable
@Suppress("UndocumentedPublicProperty")

@gabrieldrn gabrieldrn Apr 13, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Would be better to add them in Detekt's baseline, to mark them as "officially not documented". I tend to consider the Suppress annotation to mark stuff with a temporary "fix".

~ limitations under the License.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Not sure where you found that vectorized drawing haha, but it should be the one you find at https://carbondesignsystem.com/components/overview/components/ in the components grid instead. I use an inspector in a web browser to extract the SVG asset then convert it to an AVD.

@jayvijaygohil jayvijaygohil Apr 24, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, ngl this was the hardest part. :D

I have had to use an svg converter and then once imported as a vector asset, I had to manipulate it for it to look proper but your approach seems better. I'll update it using the link you mentioned. Thanks.

*/
@Immutable
@Suppress("UndocumentedPublicProperty")
public enum class InlineLoadingStatus {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

To stick with the rest of the implementations and the design system lexicon, using the State word instead of Status would be preferable.

Box(modifier = modifier) {
when (status) {
InlineLoadingStatus.Inactive -> Unit
InlineLoadingStatus.Active -> SmallLoading()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looking at the web implementations, the blue arc seems to have an angle of 60°, while SmallLoading is 270°. Feel free to refactor the loading component if it helps to have this 60° for the inline loading, but keep the existing API signatures

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.

Implement Inline loading component

2 participants