Skip to content

Conversation

@yesshreyes
Copy link
Collaborator

No description provided.

RajashekarRaju and others added 5 commits June 10, 2025 23:02
- Introduce `KonsistUtils.kt` with a `checkNoDirectUsageExceptAllowed` function to support these tests.
…CaScaffold`, `CaSurface`, and `CaTextField`.

- Migrate existing UI elements in `composeApp` to use the new design system components.
- Add tests to ensure that direct usage of `androidx.compose.material3` components is disallowed, promoting the use of the new design system components.
- Mark the task "Create a separate module for reusable UI components" as complete in `README.md`.
- Replace direct usages of `material3.Text` with `KdText`.
- Rename design system components from `Ca` prefix to `Kd` (e.g., `CaScaffold` to `KdScaffold`).
- Add a test to prevent direct usage of `androidx.compose.material3.Text` outside the design system.
Copy link
Member

@RajashekarRaju RajashekarRaju left a comment

Choose a reason for hiding this comment

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

You missed 2 things

1. Ktlint

I believe checks are not happening in this new module, check why.

2. Guarding your screens by identifying which components are not declared

You know none of your screen code is still calling those wrappers directly. But there are dozens of other Material 3 APIs (e.g. AlertDialog, TopAppBar, TextButton, etc.) that also need to live in your design-system. To catch any you’ve missed, add a “global coverage” test:

@Test
fun `all material3 components have design-system wrappers`() {
    val ignoreComponents = setOf(
        "androidx.compose.material3.Typography",
    )

    checkAllMaterial3ComponentsMoved(
        allowedComponents = ignoreComponents,
        excludePaths = arrayOf(DESIGN_SYSTEM_PATH)
    )
}

And in your KonsistUtils.kt, add the helper that this test calls:

internal fun checkAllMaterial3ComponentsMoved(
    allowedComponents: Set<String>,
    excludePaths: Array<String> = emptyArray(),
) {
    val files = Konsist
        .scopeFromProject()
        .files
        .filter { file ->
            val path = file.path.replace("\\", "/").lowercase()
            excludePaths.none { path.contains(it.replace("\\", "/").lowercase()) }
        }

    val allMaterial3Imports = files
        .flatMap { it.imports }
        .map { it.name }
        .filter { it.startsWith("androidx.compose.material3.") }
        .distinct()

    val pending = allMaterial3Imports - allowedComponents

    assertTrue(
        actual = pending.isEmpty(),
        message = "Found pending Material3 components not in design-system:\n" +
                pending.joinToString("\n") { "$it" },
    )
}
  • excludePaths makes sure you don’t flag your own wrapper files.
  • allowedComponents is really an “ignore list” for things you don’t plan to wrap (typography, themes, annotations, etc.)

With this in place, every time you run your Konsist suite you’ll get a clear list of any Material 3 APIs still living in your app code rather than in design-system.

You can also guard from others declaring their own components, this is more like building a fool proof for your tests.

…`KdCircularProgressIndicator`, and `KdTopAppBar`.

- Add `modifier` parameter to existing design system components: `KdScaffold`, `KdText`, `KdIcon`, and `KdIconButton`.
- Update Konsist tests to ensure all Material3 components are wrapped by the design system and exclude ktlint suppressed files.
- Add ktlint plugin and dependency to `design-system` module.
- Suppress ktlint for `platform.kt` files.
@yesshreyes yesshreyes merged commit f10c0f9 into master Jun 12, 2025
1 check passed
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.

3 participants