Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Module-Type Based Styling #35

Merged
merged 8 commits into from
Apr 20, 2024
Merged

Conversation

iurysza
Copy link
Owner

@iurysza iurysza commented Apr 17, 2024

🚀 Description

This PR introduces enhancements to the module graph visualization by adding plugin-type-based styling options.

There's default support and set precedence for key plugins, namely:
- React Native
- Kotlin Multiplatform
- Android Application
- Android Library
- Kotlin
- Java Library
- Java

To enable the custom styling, users need to use the setStyleByPluginType option.

moduleGraphConfig {
      setStyleByPluginType.set(true)
}

The supported plugins already have a default color pattern , but users can also customize them via the Theme.BASE objec.

Finally, you can add custom styling for other plugins by providing a CustomPlugin with an id and its color.
eg.:

import dev.iurysouza.modulegraph.ModuleType.*
import dev.iurysouza.modulegraph.Theme

moduleGraphConfig {
  theme.set(
    Theme.BASE(mapOf("lineColor" to "#f5a623"),
      moduleTypes = listOf(
        AndroidApp("#CBA45C"),
        AndroidLibrary("#292B2B"),
      ),
    ),
  )
}

Important

We determine the module's plugin type based on the plugins applied to it. We need to sort out a precedence order because a module might have several plugins.
So for example, if a module has both react-native and android-library on it, it's identified as react-native . But if it has both android-library and kotlin, then it's an android-library.

Example graph

%%{
  init: {
    'theme': 'base',
    'themeVariables': {"lineColor":"#f5a623"}
  }
}%%

graph LR
  subgraph app
    playground
    main
  end
  subgraph core
    webview-to-native-player
    common
    footballinfo
    design-system
    reddit
  end
  subgraph features
    match-thread
    match-day
  end
  match-thread --> webview-to-native-player
  match-thread --> common
  match-thread --> footballinfo
  match-thread --> design-system
  match-thread --> reddit
  match-day --> common
  match-day --> footballinfo
  match-day --> design-system
  match-day --> reddit
  playground --> webview-to-native-player
  playground --> match-thread
  playground --> design-system
  playground --> match-day
  main --> match-thread
  main --> match-day
  main --> design-system
  main --> common
  reddit --> common
  webview-to-native-player --> common
  footballinfo --> common

classDef android_library fill:#292B2B,stroke:#fff,stroke-width:2px,color:#fff;
classDef android_application fill:#CBA45C,stroke:#fff,stroke-width:2px,color:#fff;
class match-thread android_library
class webview-to-native-player android_library
class common android_library
class footballinfo android_library
class design-system android_library
class reddit android_library
class match-day android_library
class playground android_application
class main android_application

📄 Motivation and Context

This feature will help developers quickly identify module types, aiding in better understanding their project's architecture and dependency relationships.

Solves #20

🧪 How Has This Been Tested?

Manual tests.
Unit testing is WIP

📦 Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

✅ Checklist

  • My code follows the code style of this project.
  • My change requires updates to the documentation, specifically the sections on graph customization and visualization.
  • I have updated the documentation accordingly.

@iurysza iurysza added the enhancement New feature or request label Apr 17, 2024
@iurysza iurysza linked an issue Apr 17, 2024 that may be closed by this pull request
@iurysza iurysza marked this pull request as ready for review April 20, 2024 20:30
@iurysza iurysza changed the title Implement Plugin-Type Based Styling Implement Module-Type Based Styling Apr 20, 2024
@iurysza iurysza merged commit 37fed2e into main Apr 20, 2024
4 checks passed
@iurysza iurysza deleted the identify-module-by-plugin-type branch April 20, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add different color for different kinds of modules
1 participant