Skip to content

Commit

Permalink
Fix Dividers after #699 was merged
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Nov 25, 2024
1 parent 54397bd commit 74e74c6
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -56,7 +55,7 @@ import org.jetbrains.jewel.markdown.MarkdownBlock.Paragraph
import org.jetbrains.jewel.markdown.MarkdownBlock.ThematicBreak
import org.jetbrains.jewel.markdown.WithInlineMarkdown
import org.jetbrains.jewel.markdown.extensions.MarkdownRendererExtension
import org.jetbrains.jewel.ui.Orientation.Horizontal
import org.jetbrains.jewel.ui.Orientation
import org.jetbrains.jewel.ui.component.Divider
import org.jetbrains.jewel.ui.component.HorizontallyScrollableContainer
import org.jetbrains.jewel.ui.component.Text
Expand Down Expand Up @@ -182,7 +181,12 @@ public open class DefaultMarkdownBlockRenderer(

if (underlineWidth > 0.dp && underlineColor.isSpecified) {
Spacer(Modifier.height(underlineGap))
Divider(Horizontal, color = underlineColor, thickness = underlineWidth)
Divider(
Orientation.Horizontal,
Modifier.fillMaxWidth(),
color = underlineColor,
thickness = underlineWidth,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private fun RowScope.ColumnTwo(project: Project) {
Column(Modifier.trackActivation().weight(1f), verticalArrangement = Arrangement.spacedBy(16.dp)) {
MarkdownExample(project)

Divider(Orientation.Horizontal)
Divider(Orientation.Horizontal, Modifier.fillMaxWidth())

var activated by remember { mutableStateOf(false) }
Text("activated: $activated", Modifier.onActivated { activated = it })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import kotlin.time.Duration.Companion.milliseconds
import org.jetbrains.jewel.foundation.modifier.trackActivation
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.viewmodel.ComponentsViewModel
Expand All @@ -30,12 +29,13 @@ import org.jetbrains.jewel.ui.component.styling.TooltipMetrics
import org.jetbrains.jewel.ui.component.styling.TooltipStyle
import org.jetbrains.jewel.ui.painter.hints.Size
import org.jetbrains.jewel.ui.theme.tooltipStyle
import kotlin.time.Duration.Companion.milliseconds

@Composable
fun ComponentsView() {
Row(Modifier.trackActivation().fillMaxSize().background(JewelTheme.globalColors.panelBackground)) {
ComponentsToolBar()
Divider(Orientation.Vertical)
Divider(Orientation.Vertical, Modifier.fillMaxHeight())
ComponentView(ComponentsViewModel.currentView)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ private fun LazyColumnWithScrollbar(style: ScrollbarStyle, modifier: Modifier) {
if (index != LIST_ITEMS.lastIndex) {
Divider(
orientation = Orientation.Horizontal,
modifier = Modifier.fillMaxWidth(),
color = JewelTheme.globalColors.borders.normal,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal fun MarkdownEditor(state: TextFieldState, modifier: Modifier = Modifier
modifier = Modifier.fillMaxWidth().background(JewelTheme.globalColors.panelBackground).padding(8.dp),
onLoadMarkdown = { state.edit { replace(0, length, it) } },
)
Divider(orientation = Orientation.Horizontal)
Divider(orientation = Orientation.Horizontal, Modifier.fillMaxWidth())
Editor(state = state, modifier = Modifier.fillMaxWidth().weight(1f))
}
}
Expand Down
15 changes: 7 additions & 8 deletions ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Divider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.ui.Orientation
import org.jetbrains.jewel.ui.component.styling.DividerStyle
import org.jetbrains.jewel.ui.theme.dividerStyle
import org.jetbrains.jewel.ui.util.thenIf

@Composable
public fun Divider(
Expand All @@ -25,13 +26,6 @@ public fun Divider(
startIndent: Dp = Dp.Unspecified,
style: DividerStyle = JewelTheme.dividerStyle,
) {
val indentModifier =
if (startIndent.value != 0f) {
Modifier.padding(start = startIndent.takeOrElse { style.metrics.startIndent })
} else {
Modifier
}

val actualThickness = thickness.takeOrElse { style.metrics.thickness }
val orientationModifier =
when (orientation) {
Expand All @@ -40,5 +34,10 @@ public fun Divider(
}

val lineColor = color.takeOrElse { style.color }
Box(modifier.then(indentModifier).then(orientationModifier).background(color = lineColor))
Box(
modifier
.thenIf(startIndent.value != 0f) { padding(start = startIndent.takeOrElse { style.metrics.startIndent }) }
.then(orientationModifier)
.background(color = lineColor)
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jetbrains.jewel.ui.component

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -21,6 +22,7 @@ public fun GroupHeader(

Divider(
orientation = Orientation.Horizontal,
modifier = Modifier.fillMaxWidth(),
color = style.colors.divider,
thickness = style.metrics.dividerThickness,
startIndent = style.metrics.indent,
Expand Down

0 comments on commit 74e74c6

Please sign in to comment.