ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - popovanton0/Blueprint: ๐Ÿ“ Visualize the dimensions of your composables on a blueprint!
๐Ÿ“ Visualize the dimensions of your composables on a blueprint! - popovanton0/Blueprint
Visit Site

GitHub - popovanton0/Blueprint: ๐Ÿ“ Visualize the dimensions of your composables on a blueprint!

GitHub - popovanton0/Blueprint: ๐Ÿ“ Visualize the dimensions of your composables on a blueprint!

๐Ÿ“ Blueprint

Release Introductory Medium Article License

Visualize the dimensions of your composables on a blueprint

Blueprint Usage Example Blueprint Usage Example

Introductory Medium Article

The Problem

Have you ever desired to see, what exactly is that padding's value while looking at the composable preview window? Especially when you are developing a button with 5 color styles, 3 sizes, and 2 optional icons; and each combination of these parameters has different paddings?

Combinatorial explosion of UI components in design systems requires having a lot of context about paddings, dp's, sizes, corner radiuses, and other dimensional information in your head at the same time.

Many combinations of buttons Many combinations of buttons

In addition, code to produce those combinations can get tricky to analyze. So, verification also becomes hard: you make screenshots, move them to Figma, overlay them on top, and try to see the difference. Tedious ๐Ÿ˜ฉ!

The Solution

The Blueprint library provides a way to visualize dimensional information in your UI using a simple DSL-based definition:

  1. Just wrap your target UI in a Blueprint composable
  2. Mark children with Modifier.blueprintId(id: String) modifier
  3. Write the blueprint definition
Blueprint(
    blueprintBuilder = {
        widths {
            group {
                "item0".right lineTo "item1".left
                "item0" lineTo "item0"
                "item2" lineTo "item3"
            }
        }
        heights {
            group { "item0Icon" lineTo "item0Text" }
            group { "item0" lineTo "item0" }
            group(End) { "item3Icon".bottom lineTo "item3Text".top }
        }
    }
) {
    val items = remember { listOf("Songs", "Artists", "Playlists", "Settings") }
    NavigationBar {
        items.forEachIndexed { index, item ->
            NavigationBarItem(
                modifier = Modifier.blueprintId("item$index"),
                icon = { Icon(Modifier.blueprintId("item${index}Icon"), TODO()) },
                label = { Text(Modifier.blueprintId("item${index}Text"), TODO()) },
                selected = index == 0,
                onClick = { TODO() }
            )
        }
    }
}

Preview

Blueprint Usage Example Blueprint Usage Example

And another example:

Blueprint Usage Example Blueprint Usage Example

Correct arrow padding rendering animation

https://github.com/popovanton0/Blueprint/assets/15000556/7a90b534-3c7e-437a-8e08-1fdd4329c752

https://github.com/popovanton0/Blueprint/assets/15000556/535a016f-0ca9-41d2-8e52-2ed7b36fbdc0

almost_none_space_to_draw no_blueprint_if_globally_disabled
arrow_customization 0 not_enough_space_to_draw
arrow_customization 15 padding_not_applied
arrow_customization 45 reacts_to_blueprint_builder_update_(with_green)
arrow_customization 90 reacts_to_blueprint_builder_update_(without_green)
basicTest size_labels
correct_line_widths_and_alignments when_blueprint_is_disabled_it_is_not_shown
customFontSizeAndColor when_specifying_blueprint_ids_that_are_not_referenced_in_the_composable_no_dimensions_are_shown
emptyBlueprint when_specifying_blueprint_ids_that_are_then_removed_from_the_composition_dimensions_are_shown_and_then_hidden_(with_green)
fractional_dp_values_rendering when_specifying_blueprint_ids_that_are_then_removed_from_the_composition_dimensions_are_shown_and_then_hidden_(without_green)

Features

You can customize

  1. Line and border strokes (width and color)
  2. Font size and color
  3. Arrow style (length, angle, round or square cap)
  4. Decimal precision of the dimensional values

Of course, Blueprint works in Android Studio's Previewโœจ!

Also, you can disable all the overhead of this library in your release builds by either:

  1. Disabling blueprint rendering using blueprintEnabled property.
  2. Using the no-op version of the library:
    dependencies {
        debugImplementation("com.github.popovanton0.blueprint:blueprint:1.0.0-alpha05")
        releaseImplementation("com.github.popovanton0.blueprint:blueprint-no-op:1.0.0-alpha05")
    }
    

Getting Started

Release

Add the following code to your project's root build.gradle file:

repositories {
    maven { url "https://jitpack.io" }
}

Next, add the dependency below to your module's build.gradle file:

dependencies {
    implementation "com.github.popovanton0.blueprint:blueprint:1.0.0-alpha05"
}

Add the following code to your project's root settings.gradle.kts file:

dependencyResolutionManagement {
    // ...
    repositories {
        // ...
        maven { url = uri("https://jitpack.io") }
    }
}

Next, add the dependency below to your module's build.gradle.kts file:

dependencies {
    implementation("com.github.popovanton0.blueprint:blueprint:1.0.0-alpha05")
}

Or using Gradle Version Catalog:

[versions]
blueprint = "1.0.0-alpha05"

[libraries]
blueprint = { module = "com.github.popovanton0.blueprint:blueprint", version.ref = "blueprint" }

[!WARNING] Do not use this dependency notation: com.github.popovanton0:blueprint:1.0.0-alpha05. It doesn't work!

Licence

Copyright 2023 Anton Popov

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory