-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Markdown): Material3 inspired tables
- Loading branch information
Showing
5 changed files
with
111 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
ui/src/commonMain/kotlin/dev/materii/gloom/ui/util/markdown/MarkdownUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dev.materii.gloom.ui.util.markdown | ||
|
||
import androidx.compose.material3.ColorScheme | ||
import dev.materii.gloom.ui.util.hexCode | ||
|
||
object MarkdownUtil { | ||
|
||
/** | ||
* Replaces the color variables in the markdown template with the runtime theme colors | ||
* | ||
* @see `shared/src/commonMain/moko-resources/assets/markdown/markdown.html` | ||
* | ||
* @param markdownTemplate The template text where the color variables are, should be lazy loaded at runtime. | ||
* @param isLight Whether or not the theme is designed to be light. | ||
* @param colorScheme The Material3 color scheme used to theme markdown elements | ||
*/ | ||
// TODO: Add all m3 colors | ||
fun injectAppTheme( | ||
markdownTemplate: String, | ||
isLight: Boolean, | ||
colorScheme: ColorScheme | ||
): String { | ||
return markdownTemplate // Insert theme colors | ||
.replace("\$primary$", "#" + colorScheme.primary.hexCode) | ||
.replace("\$onSurface$", "#" + colorScheme.onSurface.hexCode) | ||
.replace("\$onSurfaceVariant$", "#" + colorScheme.onSurfaceVariant.hexCode) | ||
.replace("\$surfaceContainer$", "#" + colorScheme.surfaceContainer.hexCode) | ||
.replace("\$scrim$", "#" + colorScheme.scrim.hexCode) | ||
.replace("\$outline$", "#" + colorScheme.outline.hexCode) | ||
.replace("\$theme$", if (isLight) "light" else "dark") // Support the old way of theming images | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters