Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GroupHeaderStyle refactor, simplify other styling
Browse files Browse the repository at this point in the history
rock3r committed Oct 20, 2023

Verified

This commit was signed with the committer’s verified signature.
rock3r Sebastiano Poggi
1 parent 911481a commit 9ebe952
Showing 8 changed files with 251 additions and 310 deletions.
Original file line number Diff line number Diff line change
@@ -4,25 +4,33 @@ import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import org.jetbrains.jewel.GenerateDataFunctions

@Immutable
interface GroupHeaderStyle {
@GenerateDataFunctions
class GroupHeaderStyle(
val colors: GroupHeaderColors,
val metrics: GroupHeaderMetrics,
) {

val colors: GroupHeaderColors
val metrics: GroupHeaderMetrics
companion object
}

@Immutable
interface GroupHeaderColors {
@GenerateDataFunctions
class GroupHeaderColors(val divider: Color) {

val divider: Color
companion object
}

@Immutable
interface GroupHeaderMetrics {
@GenerateDataFunctions
class GroupHeaderMetrics(
val dividerThickness: Dp,
val indent: Dp,
) {

val dividerThickness: Dp
val indent: Dp
companion object
}

val LocalGroupHeaderStyle = staticCompositionLocalOf<GroupHeaderStyle> {
Original file line number Diff line number Diff line change
@@ -23,9 +23,6 @@ import com.intellij.util.ui.NamedColorUtil
import com.intellij.util.ui.StatusText
import org.jetbrains.jewel.IntelliJComponentStyling
import org.jetbrains.jewel.intui.core.IntUiThemeDefinition
import org.jetbrains.jewel.intui.standalone.styling.IntUiGroupHeaderColors
import org.jetbrains.jewel.intui.standalone.styling.IntUiGroupHeaderMetrics
import org.jetbrains.jewel.intui.standalone.styling.IntUiGroupHeaderStyle
import org.jetbrains.jewel.intui.standalone.styling.IntUiHorizontalProgressBarColors
import org.jetbrains.jewel.intui.standalone.styling.IntUiHorizontalProgressBarMetrics
import org.jetbrains.jewel.intui.standalone.styling.IntUiHorizontalProgressBarStyle
@@ -91,6 +88,9 @@ import org.jetbrains.jewel.styling.DropdownColors
import org.jetbrains.jewel.styling.DropdownIcons
import org.jetbrains.jewel.styling.DropdownMetrics
import org.jetbrains.jewel.styling.DropdownStyle
import org.jetbrains.jewel.styling.GroupHeaderColors
import org.jetbrains.jewel.styling.GroupHeaderMetrics
import org.jetbrains.jewel.styling.GroupHeaderStyle
import org.jetbrains.jewel.styling.InputFieldStyle
import org.jetbrains.skiko.DependsOnJBR
import javax.swing.UIManager
@@ -447,11 +447,11 @@ private fun readUndecoratedDropdownStyle(
)
}

private fun readGroupHeaderStyle() = IntUiGroupHeaderStyle(
colors = IntUiGroupHeaderColors(
private fun readGroupHeaderStyle() = GroupHeaderStyle(
colors = GroupHeaderColors(
divider = retrieveColorOrUnspecified("Separator.separatorColor"),
),
metrics = IntUiGroupHeaderMetrics(
metrics = GroupHeaderMetrics(
dividerThickness = 1.dp, // see DarculaSeparatorUI
indent = 1.dp, // see DarculaSeparatorUI
),
Original file line number Diff line number Diff line change
@@ -20,8 +20,6 @@ import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme
import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme
import org.jetbrains.jewel.intui.standalone.IntUiTheme.defaultComponentStyling
import org.jetbrains.jewel.intui.standalone.styling.Default
import org.jetbrains.jewel.intui.standalone.styling.Defaults
import org.jetbrains.jewel.intui.standalone.styling.IntUiGroupHeaderStyle
import org.jetbrains.jewel.intui.standalone.styling.IntUiHorizontalProgressBarStyle
import org.jetbrains.jewel.intui.standalone.styling.IntUiIconButtonStyle
import org.jetbrains.jewel.intui.standalone.styling.IntUiLabelledTextFieldStyle
@@ -36,6 +34,8 @@ import org.jetbrains.jewel.intui.standalone.styling.IntUiTextFieldStyle
import org.jetbrains.jewel.intui.standalone.styling.IntUiTooltipStyle
import org.jetbrains.jewel.intui.standalone.styling.Outlined
import org.jetbrains.jewel.intui.standalone.styling.Undecorated
import org.jetbrains.jewel.intui.standalone.styling.dark
import org.jetbrains.jewel.intui.standalone.styling.light
import org.jetbrains.jewel.painter.LocalPainterHintsProvider
import org.jetbrains.jewel.styling.ButtonStyle
import org.jetbrains.jewel.styling.CheckboxStyle
@@ -90,15 +90,15 @@ object IntUiTheme : BaseIntUiTheme {

@Composable
fun darkComponentStyling(
checkboxStyle: CheckboxStyle = CheckboxStyle.Defaults.dark(),
chipStyle: ChipStyle = ChipStyle.Defaults.dark(),
circularProgressStyle: CircularProgressStyle = CircularProgressStyle.Defaults.dark(),
checkboxStyle: CheckboxStyle = CheckboxStyle.dark(),
chipStyle: ChipStyle = ChipStyle.dark(),
circularProgressStyle: CircularProgressStyle = CircularProgressStyle.dark(),
defaultButtonStyle: ButtonStyle = ButtonStyle.Default.dark(),
defaultTabStyle: TabStyle = IntUiTabStyle.Default.dark(),
dividerStyle: DividerStyle = DividerStyle.Defaults.dark(),
dividerStyle: DividerStyle = DividerStyle.dark(),
dropdownStyle: DropdownStyle = DropdownStyle.Default.dark(),
editorTabStyle: TabStyle = IntUiTabStyle.Editor.dark(),
groupHeaderStyle: GroupHeaderStyle = IntUiGroupHeaderStyle.dark(),
groupHeaderStyle: GroupHeaderStyle = GroupHeaderStyle.dark(),
horizontalProgressBarStyle: HorizontalProgressBarStyle = IntUiHorizontalProgressBarStyle.dark(),
iconButtonStyle: IconButtonStyle = IntUiIconButtonStyle.dark(),
labelledTextFieldStyle: LabelledTextFieldStyle = IntUiLabelledTextFieldStyle.dark(),
@@ -139,15 +139,15 @@ object IntUiTheme : BaseIntUiTheme {

@Composable
fun lightComponentStyling(
checkboxStyle: CheckboxStyle = CheckboxStyle.Defaults.light(),
chipStyle: ChipStyle = ChipStyle.Defaults.light(),
circularProgressStyle: CircularProgressStyle = CircularProgressStyle.Defaults.light(),
checkboxStyle: CheckboxStyle = CheckboxStyle.light(),
chipStyle: ChipStyle = ChipStyle.light(),
circularProgressStyle: CircularProgressStyle = CircularProgressStyle.light(),
defaultButtonStyle: ButtonStyle = ButtonStyle.Default.light(),
defaultTabStyle: TabStyle = IntUiTabStyle.Default.light(),
dividerStyle: DividerStyle = DividerStyle.Defaults.light(),
dividerStyle: DividerStyle = DividerStyle.light(),
dropdownStyle: DropdownStyle = DropdownStyle.Default.light(),
editorTabStyle: TabStyle = IntUiTabStyle.Editor.light(),
groupHeaderStyle: GroupHeaderStyle = IntUiGroupHeaderStyle.light(),
groupHeaderStyle: GroupHeaderStyle = GroupHeaderStyle.light(),
horizontalProgressBarStyle: HorizontalProgressBarStyle = IntUiHorizontalProgressBarStyle.light(),
iconButtonStyle: IconButtonStyle = IntUiIconButtonStyle.light(),
labelledTextFieldStyle: LabelledTextFieldStyle = IntUiLabelledTextFieldStyle.light(),
Original file line number Diff line number Diff line change
@@ -16,45 +16,33 @@ import org.jetbrains.jewel.styling.CheckboxIcons
import org.jetbrains.jewel.styling.CheckboxMetrics
import org.jetbrains.jewel.styling.CheckboxStyle

val CheckboxStyle.Companion.Defaults: IntUiCheckboxStyleFactory
get() = IntUiCheckboxStyleFactory
@Composable
fun CheckboxStyle.Companion.light(
colors: CheckboxColors = CheckboxColors.light(),
metrics: CheckboxMetrics = CheckboxMetrics.defaults(),
icons: CheckboxIcons = CheckboxIcons.light(),
) = CheckboxStyle(colors, metrics, icons)

object IntUiCheckboxStyleFactory {
@Composable
fun CheckboxStyle.Companion.dark(
colors: CheckboxColors = CheckboxColors.dark(),
metrics: CheckboxMetrics = CheckboxMetrics.defaults(),
icons: CheckboxIcons = CheckboxIcons.dark(),
) = CheckboxStyle(colors, metrics, icons)

@Composable
fun light(
colors: CheckboxColors = CheckboxColors.Defaults.light(),
metrics: CheckboxMetrics = CheckboxMetrics.defaults(),
icons: CheckboxIcons = CheckboxIcons.Defaults.light(),
) = CheckboxStyle(colors, metrics, icons)
@Composable
fun CheckboxColors.Companion.light(
content: Color = Color.Unspecified,
contentDisabled: Color = IntUiLightTheme.colors.grey(8),
contentSelected: Color = content,
) = CheckboxColors(content, contentDisabled, contentSelected)

@Composable
fun dark(
colors: CheckboxColors = CheckboxColors.Defaults.dark(),
metrics: CheckboxMetrics = CheckboxMetrics.defaults(),
icons: CheckboxIcons = CheckboxIcons.Defaults.dark(),
) = CheckboxStyle(colors, metrics, icons)
}

val CheckboxColors.Companion.Defaults: IntUiCheckboxColorsFactory
get() = IntUiCheckboxColorsFactory

object IntUiCheckboxColorsFactory {

@Composable
fun light(
content: Color = Color.Unspecified,
contentDisabled: Color = IntUiLightTheme.colors.grey(8),
contentSelected: Color = content,
) = CheckboxColors(content, contentDisabled, contentSelected)

@Composable
fun dark(
content: Color = Color.Unspecified,
contentDisabled: Color = IntUiDarkTheme.colors.grey(7),
contentSelected: Color = content,
) = CheckboxColors(content, contentDisabled, contentSelected)
}
@Composable
fun CheckboxColors.Companion.dark(
content: Color = Color.Unspecified,
contentDisabled: Color = IntUiDarkTheme.colors.grey(7),
contentSelected: Color = content,
) = CheckboxColors(content, contentDisabled, contentSelected)

fun CheckboxMetrics.Companion.defaults(
checkboxSize: DpSize = DpSize(19.dp, 19.dp),
@@ -64,22 +52,16 @@ fun CheckboxMetrics.Companion.defaults(
iconContentGap: Dp = 5.dp,
) = CheckboxMetrics(checkboxSize, checkboxCornerSize, outlineSize, outlineOffset, iconContentGap)

val CheckboxIcons.Companion.Defaults: IntUiCheckboxIconsFactory
get() = IntUiCheckboxIconsFactory

object IntUiCheckboxIconsFactory {

@Composable
fun light(
checkbox: PainterProvider = checkbox("com/intellij/ide/ui/laf/icons/intellij/checkBox.svg"),
) = CheckboxIcons(checkbox)
@Composable
fun CheckboxIcons.Companion.light(
checkbox: PainterProvider = checkbox("com/intellij/ide/ui/laf/icons/intellij/checkBox.svg"),
) = CheckboxIcons(checkbox)

@Composable
fun dark(
checkbox: PainterProvider = checkbox("com/intellij/ide/ui/laf/icons/darcula/checkBox.svg"),
) = CheckboxIcons(checkbox)
@Composable
fun CheckboxIcons.Companion.dark(
checkbox: PainterProvider = checkbox("com/intellij/ide/ui/laf/icons/darcula/checkBox.svg"),
) = CheckboxIcons(checkbox)

@Composable
private fun checkbox(basePath: String): PainterProvider =
standalonePainterProvider(basePath)
}
@Composable
private fun checkbox(basePath: String): PainterProvider =
standalonePainterProvider(basePath)
Original file line number Diff line number Diff line change
@@ -14,159 +14,147 @@ import org.jetbrains.jewel.styling.ChipColors
import org.jetbrains.jewel.styling.ChipMetrics
import org.jetbrains.jewel.styling.ChipStyle

val ChipStyle.Companion.Defaults: IntUiChipStyleFactory
get() = IntUiChipStyleFactory
@Composable
fun ChipStyle.Companion.light(
colors: ChipColors = ChipColors.light(),
metrics: ChipMetrics = ChipMetrics.defaults(),
) = ChipStyle(colors, metrics)

object IntUiChipStyleFactory {
@Composable
fun ChipStyle.Companion.dark(
colors: ChipColors = ChipColors.dark(),
metrics: ChipMetrics = ChipMetrics.defaults(),
) = ChipStyle(colors, metrics)

@Composable
fun light(
colors: ChipColors = ChipColors.Defaults.light(),
metrics: ChipMetrics = ChipMetrics.defaults(),
) = ChipStyle(colors, metrics)
@Composable
fun ChipColors.Companion.light(
background: Brush = SolidColor(IntUiLightTheme.colors.grey(14)),
backgroundDisabled: Brush = SolidColor(IntUiLightTheme.colors.grey(12)),
backgroundFocused: Brush = background,
backgroundPressed: Brush = SolidColor(IntUiLightTheme.colors.grey(13)),
backgroundHovered: Brush = background,
backgroundSelected: Brush = background,
backgroundSelectedDisabled: Brush = backgroundDisabled,
backgroundSelectedFocused: Brush = background,
backgroundSelectedPressed: Brush = background,
backgroundSelectedHovered: Brush = background,
content: Color = IntUiLightTheme.colors.grey(1),
contentDisabled: Color = IntUiLightTheme.colors.grey(8),
contentFocused: Color = content,
contentPressed: Color = content,
contentHovered: Color = content,
contentSelected: Color = content,
contentSelectedDisabled: Color = contentDisabled,
contentSelectedFocused: Color = content,
contentSelectedPressed: Color = content,
contentSelectedHovered: Color = content,
border: Color = IntUiLightTheme.colors.grey(9),
borderDisabled: Color = IntUiLightTheme.colors.grey(6),
borderFocused: Color = IntUiLightTheme.colors.blue(4),
borderPressed: Color = IntUiLightTheme.colors.grey(7),
borderHovered: Color = IntUiLightTheme.colors.grey(8),
borderSelected: Color = IntUiLightTheme.colors.blue(4),
borderSelectedDisabled: Color = borderSelected,
borderSelectedFocused: Color = borderSelected,
borderSelectedPressed: Color = borderSelected,
borderSelectedHovered: Color = borderSelected,
) = ChipColors(
background,
backgroundDisabled,
backgroundFocused,
backgroundPressed,
backgroundHovered,
backgroundSelected,
backgroundSelectedDisabled,
backgroundSelectedPressed,
backgroundSelectedFocused,
backgroundSelectedHovered,
content,
contentDisabled,
contentFocused,
contentPressed,
contentHovered,
contentSelected,
contentSelectedDisabled,
contentSelectedPressed,
contentSelectedFocused,
contentSelectedHovered,
border,
borderDisabled,
borderFocused,
borderPressed,
borderHovered,
borderSelected,
borderSelectedDisabled,
borderSelectedPressed,
borderSelectedFocused,
borderSelectedHovered,
)

@Composable
fun dark(
colors: ChipColors = ChipColors.Defaults.dark(),
metrics: ChipMetrics = ChipMetrics.defaults(),
) = ChipStyle(colors, metrics)
}

val ChipColors.Companion.Defaults: IntUiChipColorsFactory
get() = IntUiChipColorsFactory

object IntUiChipColorsFactory {

@Composable
fun light(
background: Brush = SolidColor(IntUiLightTheme.colors.grey(14)),
backgroundDisabled: Brush = SolidColor(IntUiLightTheme.colors.grey(12)),
backgroundFocused: Brush = background,
backgroundPressed: Brush = SolidColor(IntUiLightTheme.colors.grey(13)),
backgroundHovered: Brush = background,
backgroundSelected: Brush = background,
backgroundSelectedDisabled: Brush = backgroundDisabled,
backgroundSelectedFocused: Brush = background,
backgroundSelectedPressed: Brush = background,
backgroundSelectedHovered: Brush = background,
content: Color = IntUiLightTheme.colors.grey(1),
contentDisabled: Color = IntUiLightTheme.colors.grey(8),
contentFocused: Color = content,
contentPressed: Color = content,
contentHovered: Color = content,
contentSelected: Color = content,
contentSelectedDisabled: Color = contentDisabled,
contentSelectedFocused: Color = content,
contentSelectedPressed: Color = content,
contentSelectedHovered: Color = content,
border: Color = IntUiLightTheme.colors.grey(9),
borderDisabled: Color = IntUiLightTheme.colors.grey(6),
borderFocused: Color = IntUiLightTheme.colors.blue(4),
borderPressed: Color = IntUiLightTheme.colors.grey(7),
borderHovered: Color = IntUiLightTheme.colors.grey(8),
borderSelected: Color = IntUiLightTheme.colors.blue(4),
borderSelectedDisabled: Color = borderSelected,
borderSelectedFocused: Color = borderSelected,
borderSelectedPressed: Color = borderSelected,
borderSelectedHovered: Color = borderSelected,
) = ChipColors(
background,
backgroundDisabled,
backgroundFocused,
backgroundPressed,
backgroundHovered,
backgroundSelected,
backgroundSelectedDisabled,
backgroundSelectedPressed,
backgroundSelectedFocused,
backgroundSelectedHovered,
content,
contentDisabled,
contentFocused,
contentPressed,
contentHovered,
contentSelected,
contentSelectedDisabled,
contentSelectedPressed,
contentSelectedFocused,
contentSelectedHovered,
border,
borderDisabled,
borderFocused,
borderPressed,
borderHovered,
borderSelected,
borderSelectedDisabled,
borderSelectedPressed,
borderSelectedFocused,
borderSelectedHovered,
)

@Composable
fun dark(
background: Brush = SolidColor(IntUiDarkTheme.colors.grey(2)),
backgroundDisabled: Brush = SolidColor(IntUiDarkTheme.colors.grey(5)),
backgroundFocused: Brush = background,
backgroundPressed: Brush = background,
backgroundHovered: Brush = background,
backgroundSelected: Brush = background,
backgroundSelectedDisabled: Brush = backgroundDisabled,
backgroundSelectedFocused: Brush = background,
backgroundSelectedPressed: Brush = background,
backgroundSelectedHovered: Brush = background,
content: Color = IntUiDarkTheme.colors.grey(12),
contentDisabled: Color = IntUiDarkTheme.colors.grey(8),
contentFocused: Color = content,
contentPressed: Color = content,
contentHovered: Color = content,
contentSelected: Color = content,
contentSelectedDisabled: Color = contentDisabled,
contentSelectedFocused: Color = content,
contentSelectedPressed: Color = content,
contentSelectedHovered: Color = content,
border: Color = IntUiDarkTheme.colors.grey(5),
borderDisabled: Color = IntUiDarkTheme.colors.grey(6),
borderFocused: Color = IntUiDarkTheme.colors.blue(6),
borderPressed: Color = IntUiDarkTheme.colors.grey(7),
borderHovered: Color = borderPressed,
borderSelected: Color = IntUiDarkTheme.colors.blue(6),
borderSelectedDisabled: Color = borderSelected,
borderSelectedFocused: Color = borderSelected,
borderSelectedPressed: Color = borderSelected,
borderSelectedHovered: Color = borderSelected,
) = ChipColors(
background,
backgroundDisabled,
backgroundFocused,
backgroundPressed,
backgroundHovered,
backgroundSelected,
backgroundSelectedDisabled,
backgroundSelectedPressed,
backgroundSelectedFocused,
backgroundSelectedHovered,
content,
contentDisabled,
contentFocused,
contentPressed,
contentHovered,
contentSelected,
contentSelectedDisabled,
contentSelectedPressed,
contentSelectedFocused,
contentSelectedHovered,
border,
borderDisabled,
borderFocused,
borderPressed,
borderHovered,
borderSelected,
borderSelectedDisabled,
borderSelectedPressed,
borderSelectedFocused,
borderSelectedHovered,
)
}
@Composable
fun ChipColors.Companion.dark(
background: Brush = SolidColor(IntUiDarkTheme.colors.grey(2)),
backgroundDisabled: Brush = SolidColor(IntUiDarkTheme.colors.grey(5)),
backgroundFocused: Brush = background,
backgroundPressed: Brush = background,
backgroundHovered: Brush = background,
backgroundSelected: Brush = background,
backgroundSelectedDisabled: Brush = backgroundDisabled,
backgroundSelectedFocused: Brush = background,
backgroundSelectedPressed: Brush = background,
backgroundSelectedHovered: Brush = background,
content: Color = IntUiDarkTheme.colors.grey(12),
contentDisabled: Color = IntUiDarkTheme.colors.grey(8),
contentFocused: Color = content,
contentPressed: Color = content,
contentHovered: Color = content,
contentSelected: Color = content,
contentSelectedDisabled: Color = contentDisabled,
contentSelectedFocused: Color = content,
contentSelectedPressed: Color = content,
contentSelectedHovered: Color = content,
border: Color = IntUiDarkTheme.colors.grey(5),
borderDisabled: Color = IntUiDarkTheme.colors.grey(6),
borderFocused: Color = IntUiDarkTheme.colors.blue(6),
borderPressed: Color = IntUiDarkTheme.colors.grey(7),
borderHovered: Color = borderPressed,
borderSelected: Color = IntUiDarkTheme.colors.blue(6),
borderSelectedDisabled: Color = borderSelected,
borderSelectedFocused: Color = borderSelected,
borderSelectedPressed: Color = borderSelected,
borderSelectedHovered: Color = borderSelected,
) = ChipColors(
background,
backgroundDisabled,
backgroundFocused,
backgroundPressed,
backgroundHovered,
backgroundSelected,
backgroundSelectedDisabled,
backgroundSelectedPressed,
backgroundSelectedFocused,
backgroundSelectedHovered,
content,
contentDisabled,
contentFocused,
contentPressed,
contentHovered,
contentSelected,
contentSelectedDisabled,
contentSelectedPressed,
contentSelectedFocused,
contentSelectedHovered,
border,
borderDisabled,
borderFocused,
borderPressed,
borderHovered,
borderSelected,
borderSelectedDisabled,
borderSelectedPressed,
borderSelectedFocused,
borderSelectedHovered,
)

fun ChipMetrics.Companion.defaults(
cornerSize: CornerSize = CornerSize(100),
Original file line number Diff line number Diff line change
@@ -7,18 +7,12 @@ import org.jetbrains.jewel.styling.CircularProgressStyle
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds

val CircularProgressStyle.Companion.Defaults: IntUiCircularProgressStyleFactory
get() = IntUiCircularProgressStyleFactory
fun CircularProgressStyle.Companion.dark(
frameTime: Duration = 125.milliseconds,
color: Color = Color(0xFF6F737A),
) = CircularProgressStyle(frameTime, color)

object IntUiCircularProgressStyleFactory {

fun dark(
frameTime: Duration = 125.milliseconds,
color: Color = Color(0xFF6F737A),
) = CircularProgressStyle(frameTime, color)

fun light(
frameTime: Duration = 125.milliseconds,
color: Color = Color(0xFFA8ADBD),
) = CircularProgressStyle(frameTime, color)
}
fun CircularProgressStyle.Companion.light(
frameTime: Duration = 125.milliseconds,
color: Color = Color(0xFFA8ADBD),
) = CircularProgressStyle(frameTime, color)
Original file line number Diff line number Diff line change
@@ -9,23 +9,17 @@ import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme
import org.jetbrains.jewel.styling.DividerMetrics
import org.jetbrains.jewel.styling.DividerStyle

val DividerStyle.Companion.Defaults: IntUiDividerStyleFactory
get() = IntUiDividerStyleFactory
@Composable
fun DividerStyle.Companion.light(
color: Color = IntUiLightTheme.colors.grey(12),
metrics: DividerMetrics = DividerMetrics.defaults(),
) = DividerStyle(color, metrics)

object IntUiDividerStyleFactory {

@Composable
fun light(
color: Color = IntUiLightTheme.colors.grey(12),
metrics: DividerMetrics = DividerMetrics.defaults(),
) = DividerStyle(color, metrics)

@Composable
fun dark(
color: Color = IntUiDarkTheme.colors.grey(1),
metrics: DividerMetrics = DividerMetrics.defaults(),
) = DividerStyle(color, metrics)
}
@Composable
fun DividerStyle.Companion.dark(
color: Color = IntUiDarkTheme.colors.grey(1),
metrics: DividerMetrics = DividerMetrics.defaults(),
) = DividerStyle(color, metrics)

fun DividerMetrics.Companion.defaults(
thickness: Dp = 1.dp,
Original file line number Diff line number Diff line change
@@ -1,63 +1,38 @@
package org.jetbrains.jewel.intui.standalone.styling

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.GenerateDataFunctions
import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme
import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme
import org.jetbrains.jewel.styling.GroupHeaderColors
import org.jetbrains.jewel.styling.GroupHeaderMetrics
import org.jetbrains.jewel.styling.GroupHeaderStyle

@Immutable
@GenerateDataFunctions
class IntUiGroupHeaderStyle(
override val colors: IntUiGroupHeaderColors,
override val metrics: IntUiGroupHeaderMetrics,
) : GroupHeaderStyle {

companion object {

@Composable
fun light(
colors: IntUiGroupHeaderColors = IntUiGroupHeaderColors.light(),
metrics: IntUiGroupHeaderMetrics = IntUiGroupHeaderMetrics(),
) = IntUiGroupHeaderStyle(colors, metrics)

@Composable
fun dark(
colors: IntUiGroupHeaderColors = IntUiGroupHeaderColors.dark(),
metrics: IntUiGroupHeaderMetrics = IntUiGroupHeaderMetrics(),
) = IntUiGroupHeaderStyle(colors, metrics)
}
}

@Immutable
@GenerateDataFunctions
class IntUiGroupHeaderColors(
override val divider: Color,
) : GroupHeaderColors {

companion object {

@Composable
fun light(
divider: Color = IntUiLightTheme.colors.grey(12),
) = IntUiGroupHeaderColors(divider)

@Composable
fun dark(
divider: Color = IntUiDarkTheme.colors.grey(3),
) = IntUiGroupHeaderColors(divider)
}
}

@Immutable
@GenerateDataFunctions
class IntUiGroupHeaderMetrics(
override val dividerThickness: Dp = 1.dp,
override val indent: Dp = 8.dp,
) : GroupHeaderMetrics
@Composable
fun GroupHeaderStyle.Companion.light(
colors: GroupHeaderColors = GroupHeaderColors.light(),
metrics: GroupHeaderMetrics = GroupHeaderMetrics.defaults(),
) = GroupHeaderStyle(colors, metrics)

@Composable
fun GroupHeaderStyle.Companion.dark(
colors: GroupHeaderColors = GroupHeaderColors.dark(),
metrics: GroupHeaderMetrics = GroupHeaderMetrics.defaults(),
) = GroupHeaderStyle(colors, metrics)

@Composable
fun GroupHeaderColors.Companion.light(
divider: Color = IntUiLightTheme.colors.grey(12),
) = GroupHeaderColors(divider)

@Composable
fun GroupHeaderColors.Companion.dark(
divider: Color = IntUiDarkTheme.colors.grey(3),
) = GroupHeaderColors(divider)

fun GroupHeaderMetrics.Companion.defaults(
dividerThickness: Dp = 1.dp,
indent: Dp = 8.dp,
) = GroupHeaderMetrics(dividerThickness, indent)

0 comments on commit 9ebe952

Please sign in to comment.