Skip to content

Commit

Permalink
feat(sdds-acore/theme-builder): Fetching task was created. Theme file…
Browse files Browse the repository at this point in the history
… deserialization was implemented. Color, gradients, typography and dimen tokens generators were implemented for view system.
  • Loading branch information
malilex committed Mar 7, 2024
1 parent fdf3be5 commit 6d9efe3
Show file tree
Hide file tree
Showing 29 changed files with 1,346 additions and 6 deletions.
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ test-robolectric = "4.9"
test-androidX-rules = "1.5.0"
test-androidX-runner = "1.5.2"

kotlinSerialization = "1.4.0"

plugin-androidCacheFix = "3.0.1"
plugin-gradleNexusPublish = "1.3.0"
plugin-gradlePluginPublish = "1.2.1"
Expand All @@ -37,6 +39,7 @@ base-androidX-compose-uiTooling = { module = "androidx.compose.ui:ui-tooling" }
base-androidX-compose-uiTooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }

base-kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "global-kotlin" }
base-kotlin-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinSerialization" }

base-staticAnalysis-ktlint = { module = "com.pinterest:ktlint", version.ref = "staticAnalysis-ktlint" }
base-staticAnalysis-detekt-api = { module = "io.gitlab.arturbosch.detekt:detekt-api", version.ref = "staticAnalysis-detekt" }
Expand Down Expand Up @@ -72,6 +75,7 @@ android-lib = { id = "com.android.library", version.ref = "global-gradle" }
android-app = { id = "com.android.application", version.ref = "global-gradle" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "global-kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "global-kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "global-kotlin" }
paparazzi = { id = "app.cash.paparazzi", version.ref = "test-paparazzi" }
jgp = { id = "java-gradle-plugin" }
android-cache-fix = { id = "org.gradle.android.cache-fix", version.ref= "plugin-androidCacheFix" }
Expand Down
9 changes: 9 additions & 0 deletions playground/theme-builder/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import com.sdds.plugin.themebuilder.ThemeBuilderExtension
import com.sdds.plugin.themebuilder.ThemeBuilderTarget

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("convention.android-lib")
id(libs.plugins.themebuilder.get().pluginId)
}

android {
namespace = "com.sdds.playground.themebuilder"
}

configure<ThemeBuilderExtension> {
themeUrl.set("file://${projectDir.path}/new_theme_scheme.json")
target.set(ThemeBuilderTarget.COMPOSE.value)
}
170 changes: 170 additions & 0 deletions playground/theme-builder/new_theme_scheme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"name" : "theme-name",
"version" : "0.0.1",
"platforms": ["ios", "android", "web"],
"colors" : {
"category": ["text", "surfaces", "backgrounds"],
"mode" : ["dark", "light"],
"subcategory" : ["on-dark", "on-light", "default", "inverse"]
},
"shadows": {
"directions": ["up", "down"],
"kind": ["hard", "soft"],
"sizes": ["l", "m", "s", "xs", "xxs"]
},
"typography": {
"sizes": ["l", "m", "s", "xs", "xxs"],
"kind": ["display", "body", "text", "h1", "h2", "h3", "h4", "h5"],
"screen": ["screen-l", "screen-m", "screen-s"]
},
"tokens": [
{
"displayName": "surfaceAccent",
"name": "dark.inverse.surface.accent",
"platform": "android",
"tags" : [
"dark",
"surface",
"inverse"
],
"type": "sweep-gradient",
"value" : {
"locations": [ 0, 0.3, 0.7, 1 ],
"colors" : ["#000", "#fff"],
"startAngle": 0,
"endAngle" : 360
},
"description": "Цвет текста",
"enabled": true
},
{
"displayName": "surfaceTransparentAccent",
"name": "dark.on-light.surface.transparent-accent",
"platform": "android",
"tags" : [
"dark",
"surface",
"on-light"
],
"type": "color",
"value" : {
"origin": "#FFFFFF1F"
},
"description": "Прозрачная акцентная поверхность",
"enabled": true
},
{
"displayName": "textAccent",
"name": "on-dark.text.accent",
"platform": "web",
"tags": [
"dark",
"on-dark",
"text",
"gradient"
],
"type": "linear-gradient",
"value" : {
"origin": "linear-gradient(122.62deg, #4817C1 0%, #C505D6 100%)"
},
"description": "Цвет текста",
"enabled": true
},
{
"displayName": "downHardL",
"name": "down.hard.l",
"platform": "android",
"tags": [
"down",
"hard",
"l"
],
"type": "shadow",
"value": {
"color": "#000",
"elevation": 16
},
"description": "тень android",
"enabled": true
},
{
"name": "downHardL",
"tags": [
"down",
"hard",
"l",
"ios"
],
"platform": "ios",
"type": "shadow",
"value": {
"color": "#000",
"offset": { "width": 0, "height": 2 },
"opacity": 0.15,
"radius": 1.5
},
"description": "Тень ios",
"enabled": true
},
{
"name": "downHardL",
"platform": "web",
"tags": [
"down",
"hard",
"l",
"web"
],
"type": "shadow",
"value": {
"origin" : "0px 6px 12px rgba(0, 0, 0, 0.12)"
},
"description": "Тень web",
"enabled": true
},
{
"displayName": "displayL",
"name": "screen-l.display.l",
"platform": "android",
"tags": [
"screen-l",
"display",
"l"
],
"type": "typography",
"value": {
"fontFamily": "sans",
"fontWeight": 300,
"fontStyle": "normal",
"textSize": 128,
"letterSpacing": 0.02,
"lineHeight": 128
},
"description": "шрифт android",
"enabled": true
},
{
"displayName": "displayL",
"name": "screen-m.display.l",
"platform": "android",
"tags": [
"screen-m",
"display",
"l"
],
"type": "typography",
"value": {
"fontFamily": "sans",
"fontWeight": 300,
"fontStyle": "normal",
"textSize": 96,
"letterSpacing": 0.02,
"lineHeight": 96
},
"description": "шрифт android",
"enabled": true
}
]
}


4 changes: 4 additions & 0 deletions playground/theme-builder/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

</resources>
139 changes: 139 additions & 0 deletions playground/theme-builder/theme_scheme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"name" : "theme-name",
"version" : "0.0.2",
"platforms": ["ios", "android", "web"],
"colors" : {
"category": ["text", "surfaces", "backgrounds"],
"mode" : ["dark", "light"],
"subcategory" : ["on-dark", "on-light", "default", "inverse"],
"naming": "subcategory.category.name",
"tokens" : [
{
"displayName": "surfaceAccent",
"name": "inverse.surface.accent",
"platform": "ios",
"tags" : [
"dark",
"surface",
"inverse"
],
"value" : {
"type": "angular-gradient",
"locations": [ 0, 0.3, 0.7, 1 ],
"colors" : ["#000", "#fff"],
"startAngle": 0,
"endAngle" : 360
},
"description": "Цвет текста",
"enabled": true
},
{
"displayName": "surfaceTransparentAccent",
"name": "on-light.surface.transparent-accent",
"platform": "ios",
"tags" : [
"dark",
"surface",
"on-light"
],
"value" : {
"origin": "#FFFFFF1F"
},
"description": "Прозрачная акцентная поверхность",
"enabled": true
},
{
"displayName": "textAccent",
"name": "on-dark.text.accent",
"platform": "web",
"tags": [
"dark",
"on-dark",
"text"
],
"value" : "linear-gradient(122.62deg, #4817C1 0%, #C505D6 100%)",
"description": "Цвет текста",
"enabled": true
}
]
},

"shadows": {
"directions": ["up", "down"],
"types": ["hard", "soft"],
"sizes": ["l", "m", "s", "xs", "xxs"],
"tokens" : [
{
"displayName": "downHardL",
"name": "down.hard.l",
"tags": [
"down",
"hard",
"l"
],
"value": {
"color": "#000",
"elevation": 16
},
"description": "тень android",
"enabled": true
},
{
"name": "downHardL",
"tags": [
"down",
"hard",
"l",
"ios"
],
"value": {
"color": "#000",
"offset": { "width": 0, "height": 2 },
"opacity": 0.15,
"radius": 1.5
},
"description": "Тень ios",
"enabled": true
},
{
"name": "downHardL",
"tags": [
"down",
"hard",
"l",
"web"
],
"value": "0px 6px 12px rgba(0, 0, 0, 0.12)",
"description": "Тень web",
"enabled": true
}
]
},

"typography": {
"sizes": ["l", "m", "s", "xs", "xxs"],
"type": ["display", "body", "text", "h1", "h2", "h3", "h4", "h5"],
"screen": ["sceen-l", "screen-m", "screen-s"],
"tokens": [
{
"displayName": "displayL",
"name": "screen-l.display.l",
"platform": "android",
"tags": [
"screen-l",
"display",
"l"
],
"value": {
"font-family": "#000",
"fontSize": 16,
"lineSpacing": 0.02
},
"description": "шрифт android",
"enabled": true
}
]
}
}


12 changes: 8 additions & 4 deletions sdds-core/plugin_theme_builder/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import utils.findPropertyOrDefault
import utils.versionInfo
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
`java-gradle-plugin`
`kotlin-dsl`
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.gradlePluginPublish)
id("convention.detekt")
id("convention.spotless")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
afterEvaluate {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.languageVersion = "1.7"
}
}

group = "io.github.salute-developers"
Expand All @@ -40,7 +43,8 @@ publishing {
}

dependencies {
implementation(libs.base.kotlin.stdlib)
implementation(libs.base.kotlin.serialization.json)
implementation(libs.base.gradle.android)
testImplementation(libs.base.test.unit.jUnit)
testImplementation(libs.base.test.unit.mockk)
}
Loading

0 comments on commit 6d9efe3

Please sign in to comment.