-
Notifications
You must be signed in to change notification settings - Fork 14
Refactor icon pack generator to use iconpack model for nested packs #379
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
6 changes: 6 additions & 0 deletions
6
...erator/common/src/main/kotlin/io/github/composegears/valkyrie/generator/model/IconPack.kt
This file contains hidden or 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,6 @@ | ||
package io.github.composegears.valkyrie.generator.model | ||
|
||
data class IconPack( | ||
val name: String, | ||
val nested: List<IconPack> = emptyList(), | ||
) |
24 changes: 24 additions & 0 deletions
24
...tor/common/src/main/kotlin/io/github/composegears/valkyrie/generator/model/IconPackDsl.kt
This file contains hidden or 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,24 @@ | ||
package io.github.composegears.valkyrie.generator.model | ||
|
||
@DslMarker | ||
annotation class IconPackDsl | ||
|
||
@IconPackDsl | ||
fun iconpack(name: String, init: PackBuilder.() -> Unit = {}): IconPack { | ||
val builder = PackBuilder(name) | ||
builder.init() | ||
return builder.build() | ||
} | ||
|
||
@IconPackDsl | ||
class PackBuilder(private val name: String) { | ||
private val nestedPacks = mutableListOf<IconPack>() | ||
|
||
fun pack(name: String, init: PackBuilder.() -> Unit = {}) { | ||
val builder = PackBuilder(name) | ||
builder.init() | ||
nestedPacks.add(builder.build()) | ||
} | ||
|
||
internal fun build(): IconPack = IconPack(name, nestedPacks) | ||
} |
69 changes: 69 additions & 0 deletions
69
...common/src/test/kotlin/io/github/composegears/valkyrie/generator/model/IconPackDslTest.kt
This file contains hidden or 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,69 @@ | ||
package io.github.composegears.valkyrie.generator.model | ||
|
||
import assertk.assertThat | ||
import assertk.assertions.hasSize | ||
import assertk.assertions.isEqualTo | ||
import org.junit.jupiter.api.Test | ||
|
||
class IconPackDslTest { | ||
|
||
@Test | ||
fun `simple iconpack`() { | ||
val iconPack = iconpack(name = "ValkyrieIcons") | ||
|
||
assertThat(iconPack.name).isEqualTo("ValkyrieIcons") | ||
assertThat(iconPack.nested).hasSize(0) | ||
} | ||
|
||
@Test | ||
fun `pack with one level of nesting`() { | ||
val iconPack = iconpack(name = "ValkyrieIcons") { | ||
pack(name = "Outlined") | ||
pack(name = "Filled") | ||
} | ||
|
||
assertThat(iconPack.name).isEqualTo("ValkyrieIcons") | ||
assertThat(iconPack.nested).hasSize(2) | ||
assertThat(iconPack.nested[0].name).isEqualTo("Outlined") | ||
assertThat(iconPack.nested[1].name).isEqualTo("Filled") | ||
} | ||
|
||
@Test | ||
fun `iconpack with multiple nested levels`() { | ||
val iconPack = iconpack(name = "ValkyrieIcons") { | ||
pack(name = "Material") { | ||
pack(name = "Rounded") { | ||
pack(name = "Filled") | ||
} | ||
pack(name = "Sharp") { | ||
pack(name = "Outlined") | ||
} | ||
} | ||
pack(name = "Custom") { | ||
pack(name = "Brand") | ||
} | ||
} | ||
|
||
assertThat(iconPack.name).isEqualTo("ValkyrieIcons") | ||
assertThat(iconPack.nested).hasSize(2) | ||
|
||
val material = iconPack.nested[0] | ||
assertThat(material.name).isEqualTo("Material") | ||
assertThat(material.nested).hasSize(2) | ||
|
||
val rounded = material.nested[0] | ||
assertThat(rounded.name).isEqualTo("Rounded") | ||
assertThat(rounded.nested).hasSize(1) | ||
assertThat(rounded.nested[0].name).isEqualTo("Filled") | ||
|
||
val sharp = material.nested[1] | ||
assertThat(sharp.name).isEqualTo("Sharp") | ||
assertThat(sharp.nested).hasSize(1) | ||
assertThat(sharp.nested[0].name).isEqualTo("Outlined") | ||
|
||
val custom = iconPack.nested[1] | ||
assertThat(custom.name).isEqualTo("Custom") | ||
assertThat(custom.nested).hasSize(1) | ||
assertThat(custom.nested[0].name).isEqualTo("Brand") | ||
} | ||
} |
This file contains hidden or 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
5 changes: 3 additions & 2 deletions
5
...k/src/main/kotlin/io/github/composegears/valkyrie/generator/iconpack/IconPackGenerator.kt
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
components/sharedTestResources/iconpack/IconPack.nested.L3.kt
This file contains hidden or 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,13 @@ | ||
package io.github.composegears.valkyrie.icons | ||
|
||
object ValkyrieIcons { | ||
object Rounded { | ||
object Filled | ||
} | ||
|
||
object Sharp { | ||
object Colored | ||
|
||
object Dark | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
components/sharedTestResources/iconpack/IconPack.nested.L4.kt
This file contains hidden or 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,15 @@ | ||
package io.github.composegears.valkyrie.icons | ||
|
||
object ValkyrieIcons { | ||
object Material { | ||
object Rounded { | ||
object Filled | ||
|
||
object Outlined | ||
} | ||
} | ||
|
||
object Custom { | ||
object Brand | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.