Skip to content

Commit

Permalink
Use typography APIs in samples, reduce duplication in bridge (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r authored Mar 11, 2024
1 parent 6bb2c45 commit 5c34de8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal class SwingBridgeService(scope: CoroutineScope) {
val themeDefinition = createBridgeThemeDefinition(TextStyle.Default)

BridgeThemeData(
themeDefinition = createBridgeThemeDefinition(TextStyle.Default),
themeDefinition = themeDefinition,
componentStyling =
createBridgeComponentStyling(
theme = themeDefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ import com.intellij.util.ui.JBUI
import icons.JewelIcons
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.datetime.toJavaLocalDate
import org.jetbrains.jewel.bridge.medium
import org.jetbrains.jewel.bridge.regular
import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified
import org.jetbrains.jewel.bridge.retrieveTextStyle
import org.jetbrains.jewel.bridge.toComposeColor
import org.jetbrains.jewel.foundation.lazy.SelectableLazyColumn
import org.jetbrains.jewel.foundation.lazy.SelectionMode
Expand All @@ -87,6 +87,7 @@ import org.jetbrains.jewel.ui.component.IconButton
import org.jetbrains.jewel.ui.component.PopupMenu
import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.jewel.ui.component.TextField
import org.jetbrains.jewel.ui.component.Typography
import org.jetbrains.jewel.ui.component.VerticalScrollbar
import org.jetbrains.jewel.ui.component.items
import org.jetbrains.jewel.ui.painter.rememberResourcePainterProvider
Expand Down Expand Up @@ -253,7 +254,7 @@ private fun ItemTag(
) {
Text(
text = text,
fontSize = JBFont.medium().size2D.sp,
style = Typography.medium(),
color = foregroundColor,
modifier = modifier
.background(backgroundColor, shape)
Expand Down Expand Up @@ -506,24 +507,15 @@ private fun ItemDetailsText(selectedItem: ContentItem) {
Modifier.padding(horizontal = 20.dp, vertical = 12.dp),
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
Text(
selectedItem.displayText,
style = runBlocking {
retrieveTextStyle(
key = "Label.font",
bold = true,
size = JBFont.h1().size2D.sp,
)
},
)
Text(selectedItem.displayText, style = Typography.h1TextStyle())

val formatter =
remember(Locale.current) { DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM) }
val releaseDate = selectedItem.releaseDate
if (releaseDate != null) {
Text(
text = "Released on ${formatter.format(releaseDate.toJavaLocalDate())}",
fontSize = getCommentFontSize(),
style = Typography.medium(),
color = JBUI.CurrentTheme.Label.disabledForeground().toComposeColor(),
)
}
Expand Down Expand Up @@ -558,7 +550,7 @@ private fun AndroidStudioReleaseDetails(item: ContentItem.AndroidStudio) {
private fun TextWithLabel(labelText: String, valueText: String) {
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Text(labelText)
Text(valueText, fontWeight = FontWeight.W600)
Text(valueText, style = Typography.regular().copy(fontWeight = FontWeight.Bold))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.jetbrains.jewel.foundation.modifier.trackActivation
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.StandaloneSampleIcons
Expand All @@ -26,6 +25,7 @@ import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.SelectableIconButton
import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.jewel.ui.component.Tooltip
import org.jetbrains.jewel.ui.component.Typography
import org.jetbrains.jewel.ui.component.styling.LocalIconButtonStyle
import org.jetbrains.jewel.ui.painter.hints.Size
import org.jetbrains.jewel.ui.painter.hints.Stroke
Expand Down Expand Up @@ -64,7 +64,7 @@ fun ComponentsToolBar() {
@Composable
fun ComponentView(view: ViewInfo) {
Column(Modifier.fillMaxSize().padding(24.dp), verticalArrangement = Arrangement.spacedBy(24.dp)) {
Text(view.title, fontSize = 20.sp)
Text(view.title, style = Typography.h1TextStyle())
view.content()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.jetbrains.jewel.foundation.modifier.trackActivation
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.IntUiThemes
Expand All @@ -26,6 +25,7 @@ import org.jetbrains.jewel.ui.component.CheckboxRow
import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.RadioButtonChip
import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.jewel.ui.component.Typography
import org.jetbrains.jewel.ui.component.styling.LocalCheckboxStyle
import org.jetbrains.jewel.ui.painter.hints.Selected
import org.jetbrains.jewel.ui.painter.rememberResourcePainterProvider
Expand All @@ -51,7 +51,7 @@ fun WelcomeView() {
contentScale = ContentScale.Crop,
)

Text("Meet Jewel", fontSize = 20.sp)
Text("Meet Jewel", style = Typography.h1TextStyle())

Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Text("Theme:")
Expand Down

0 comments on commit 5c34de8

Please sign in to comment.