Skip to content

Commit

Permalink
Refactor default tab style to specific tab styles
Browse files Browse the repository at this point in the history
This commit refactors the default tab style to include specific tool window and custom tab styles. It also adjusts the corresponding references throughout the project. The aim is to increase flexibility and specificity in styling different types of tabs.
  • Loading branch information
fscarponi committed Dec 19, 2023
1 parent 2077d68 commit f5c24de
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ internal fun createBridgeComponentStyling(

val textFieldStyle = readTextFieldStyle(textFieldTextStyle)
val menuStyle = readMenuStyle()
val defaultTabStyle = readDefaultTabStyle()

return DefaultComponentStyling(
checkboxStyle = readCheckboxStyle(),
chipStyle = readChipStyle(),
circularProgressStyle = readCircularProgressStyle(theme.isDark),
defaultButtonStyle = readDefaultButtonStyle(),
defaultDropdownStyle = readDefaultDropdownStyle(menuStyle, dropdownTextStyle),
defaultTabStyle = readDefaultTabStyle(),
toolWindowTabStyle = readDefaultTabStyle(),
customTabStyle = defaultTabStyle,
dividerStyle = readDividerStyle(),
editorTabStyle = readEditorTabStyle(),
groupHeaderStyle = readGroupHeaderStyle(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public fun ComponentStyling.dark(
circularProgressStyle = circularProgressStyle,
defaultButtonStyle = defaultButtonStyle,
defaultDropdownStyle = dropdownStyle,
defaultTabStyle = defaultTabStyle,
toolWindowTabStyle = defaultTabStyle,
customTabStyle = defaultTabStyle,
dividerStyle = dividerStyle,
editorTabStyle = editorTabStyle,
groupHeaderStyle = groupHeaderStyle,
Expand Down Expand Up @@ -168,7 +169,8 @@ public fun ComponentStyling.light(
circularProgressStyle = circularProgressStyle,
defaultButtonStyle = defaultButtonStyle,
defaultDropdownStyle = dropdownStyle,
defaultTabStyle = defaultTabStyle,
toolWindowTabStyle = defaultTabStyle,
customTabStyle = defaultTabStyle,
dividerStyle = dividerStyle,
editorTabStyle = editorTabStyle,
groupHeaderStyle = groupHeaderStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

package org.jetbrains.jewel.samples.standalone.view.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -54,12 +59,46 @@ fun CustomTabShowcase() {
TabData.Custom(
selected = index == selectedTabIndex,
content = {
val textColor = when {
it.isHovered -> Color.Red
else -> Color.Unspecified
Row(
horizontalArrangement = Arrangement.spacedBy(2.dp),
verticalAlignment = Alignment.CenterVertically
) {
val textColor = when {
it.isHovered -> Color.Red
else -> Color.Unspecified

}
Text(text = "Custom tab $id")
Text(text = "($id)", color = textColor)
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.size(24.dp)
.background(color = Color.Yellow, shape = CircleShape)
.padding(2.dp)
) {
Text(text = 'C'.toString())
}
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.size(24.dp)
.background(color = Color.Green, shape = CircleShape)
.padding(2.dp)
) {
Text(text = 'W'.toString())
}
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.size(24.dp)
.background(color = Color.Magenta, shape = CircleShape)
.padding(2.dp)
) {
Text(text = 'M'.toString())
}

}
Text(text = "Custom tab $id", color = textColor)

},
onClose = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import org.jetbrains.jewel.ui.component.styling.LinkStyle
import org.jetbrains.jewel.ui.component.styling.LocalCheckboxStyle
import org.jetbrains.jewel.ui.component.styling.LocalChipStyle
import org.jetbrains.jewel.ui.component.styling.LocalCircularProgressStyle
import org.jetbrains.jewel.ui.component.styling.LocalCustomTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultDropdownStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalDividerStyle
import org.jetbrains.jewel.ui.component.styling.LocalEditorTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalGroupHeaderStyle
Expand All @@ -37,6 +37,7 @@ import org.jetbrains.jewel.ui.component.styling.LocalScrollbarStyle
import org.jetbrains.jewel.ui.component.styling.LocalSliderStyle
import org.jetbrains.jewel.ui.component.styling.LocalTextAreaStyle
import org.jetbrains.jewel.ui.component.styling.LocalTextFieldStyle
import org.jetbrains.jewel.ui.component.styling.LocalToolWindowTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalTooltipStyle
import org.jetbrains.jewel.ui.component.styling.LocalUndecoratedDropdownStyle
import org.jetbrains.jewel.ui.component.styling.MenuStyle
Expand All @@ -56,9 +57,10 @@ public class DefaultComponentStyling(
public val circularProgressStyle: CircularProgressStyle,
public val defaultButtonStyle: ButtonStyle,
public val defaultDropdownStyle: DropdownStyle,
public val defaultTabStyle: TabStyle,
public val dividerStyle: DividerStyle,
public val toolWindowTabStyle: TabStyle,
public val editorTabStyle: TabStyle,
public val customTabStyle: TabStyle,
public val dividerStyle: DividerStyle,
public val groupHeaderStyle: GroupHeaderStyle,
public val horizontalProgressBarStyle: HorizontalProgressBarStyle,
public val iconButtonStyle: IconButtonStyle,
Expand All @@ -84,7 +86,8 @@ public class DefaultComponentStyling(
LocalContextMenuRepresentation provides ContextMenuRepresentation,
LocalDefaultButtonStyle provides defaultButtonStyle,
LocalDefaultDropdownStyle provides defaultDropdownStyle,
LocalDefaultTabStyle provides defaultTabStyle,
LocalToolWindowTabStyle provides toolWindowTabStyle,
LocalCustomTabStyle provides toolWindowTabStyle,
LocalDividerStyle provides dividerStyle,
LocalEditorTabStyle provides editorTabStyle,
LocalGroupHeaderStyle provides groupHeaderStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private fun <T> TabState.chooseValueIgnoreCompat(
else -> normal
}

public val LocalDefaultTabStyle: ProvidableCompositionLocal<TabStyle> =
public val LocalToolWindowTabStyle: ProvidableCompositionLocal<TabStyle> =
staticCompositionLocalOf {
error("No LocalTabStyle provided. Have you forgotten the theme?")
}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/main/kotlin/org/jetbrains/jewel/ui/theme/JewelTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import org.jetbrains.jewel.ui.component.styling.LocalCircularProgressStyle
import org.jetbrains.jewel.ui.component.styling.LocalCustomTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultButtonStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultDropdownStyle
import org.jetbrains.jewel.ui.component.styling.LocalDefaultTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalDividerStyle
import org.jetbrains.jewel.ui.component.styling.LocalEditorTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalGroupHeaderStyle
Expand All @@ -44,6 +43,7 @@ import org.jetbrains.jewel.ui.component.styling.LocalScrollbarStyle
import org.jetbrains.jewel.ui.component.styling.LocalSliderStyle
import org.jetbrains.jewel.ui.component.styling.LocalTextAreaStyle
import org.jetbrains.jewel.ui.component.styling.LocalTextFieldStyle
import org.jetbrains.jewel.ui.component.styling.LocalToolWindowTabStyle
import org.jetbrains.jewel.ui.component.styling.LocalTooltipStyle
import org.jetbrains.jewel.ui.component.styling.MenuStyle
import org.jetbrains.jewel.ui.component.styling.RadioButtonStyle
Expand Down Expand Up @@ -146,7 +146,7 @@ public val JewelTheme.Companion.treeStyle: LazyTreeStyle
public val JewelTheme.Companion.toolWindowTabStyle: TabStyle
@Composable
@ReadOnlyComposable
get() = LocalDefaultTabStyle.current
get() = LocalToolWindowTabStyle.current

public val JewelTheme.Companion.editorTabStyle: TabStyle
@Composable
Expand Down

0 comments on commit f5c24de

Please sign in to comment.