Skip to content

Commit

Permalink
feat: implement HALF block size
Browse files Browse the repository at this point in the history
  • Loading branch information
d1snin committed Nov 7, 2023
1 parent b0b8aff commit c1d0874
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
14 changes: 12 additions & 2 deletions beam-common/src/commonMain/kotlin/dev/d1s/beam/commons/Block.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ public data class BlockModification(
) : AbstractBlock

public enum class BlockSize {
SMALL, MEDIUM, LARGE, EXTRA_LARGE;
SMALL, MEDIUM, HALF, LARGE, EXTRA_LARGE;

public val level: Int = ordinal + 1
public val level: Int
get() = if (this == HALF) {
HALF_LEVEL
} else {
ordinal + 1
}

public companion object {

public const val HALF_LEVEL: Int = 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ExploreDropdownComponent : Component<Unit>(), KoinComponent {

private fun SimplePanel.setMenuWidth(maxBlockSize: BlockSize) {
val maxBlockSizeValue = sizeOf(maxBlockSize)
val minimizedMaxBlockSize = (maxBlockSizeValue * 0.70).toInt()
val minimizedMaxBlockSize = (maxBlockSizeValue * MENU_WIDTH_RATIO).toInt()

width = minimizedMaxBlockSize.px
}
Expand All @@ -95,4 +95,9 @@ class ExploreDropdownComponent : Component<Unit>(), KoinComponent {
componentToBeVisible.visible = visible
}
}

private companion object {

private const val MENU_WIDTH_RATIO = 0.70
}
}
6 changes: 5 additions & 1 deletion beam-ui/src/jsMain/kotlin/dev/d1s/beam/ui/util/Size.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ object Size {
}

fun sizeOf(blockSize: BlockSize) =
STEP * blockSize.level
if (blockSize == BlockSize.HALF) {
(STEP * MaxBlockSize.level) / 2
} else {
STEP * blockSize.level
}

private fun breakpointOf(blockSize: BlockSize) =
sizeOf(blockSize) + WHITESPACE
Expand Down
2 changes: 1 addition & 1 deletion http/daemon.http
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Content-Type: application/json

{
"index": 0,
"size": "EXTRA_LARGE",
"size": "HALF",
"entities": [
{
"type": "void",
Expand Down

0 comments on commit c1d0874

Please sign in to comment.