-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[JEWEL-954] Implement ad text in popups #3358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wellingtoncosta
wants to merge
1
commit into
JetBrains:master
Choose a base branch
from
wellingtoncosta:wp/implement-popup-ad-text
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,050
−12
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgePopupAdText.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package org.jetbrains.jewel.bridge.theme | ||
|
|
||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.ui.graphics.takeOrElse | ||
| import androidx.compose.ui.text.TextStyle | ||
| import androidx.compose.ui.text.font.FontFamily | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.sp | ||
| import com.intellij.ui.NewUiValue | ||
| import com.intellij.util.ui.JBUI | ||
| import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified | ||
| import org.jetbrains.jewel.bridge.retrieveInsetsAsPaddingValuesOrNull | ||
| import org.jetbrains.jewel.bridge.toComposeColor | ||
| import org.jetbrains.jewel.ui.component.styling.PopupAdTextColors | ||
| import org.jetbrains.jewel.ui.component.styling.PopupAdTextMetrics | ||
| import org.jetbrains.jewel.ui.component.styling.PopupAdTextStyle | ||
|
|
||
| internal fun readPopupAdTextStyle(): PopupAdTextStyle { | ||
| // Get colors from LaF following JBUI.CurrentTheme.Advertiser pattern | ||
| // Uses Popup.Advertiser.* keys with fallback to SearchEverywhere.Advertiser.* | ||
| val foregroundColor = | ||
| retrieveColorOrUnspecified("Popup.Advertiser.foreground").takeOrElse { | ||
| retrieveColorOrUnspecified("SearchEverywhere.Advertiser.foreground").takeOrElse { | ||
| JBUI.CurrentTheme.Advertiser.foreground().toComposeColor() | ||
| } | ||
| } | ||
|
|
||
| val backgroundColor = | ||
| retrieveColorOrUnspecified("Popup.Advertiser.background").takeOrElse { | ||
| retrieveColorOrUnspecified("SearchEverywhere.Advertiser.background").takeOrElse { | ||
| JBUI.CurrentTheme.Advertiser.background().toComposeColor() | ||
| } | ||
| } | ||
|
|
||
| val colors = PopupAdTextColors(foreground = foregroundColor, background = backgroundColor) | ||
|
|
||
| // Get border insets from LaF following JBUI.CurrentTheme.Advertiser.borderInsets() pattern | ||
| // For new UI: insets(6, 20), for legacy UI: insets(5, 10, 5, 15) | ||
| val borderInsets = | ||
| retrieveInsetsAsPaddingValuesOrNull("Popup.Advertiser.borderInsets") | ||
| ?: if (NewUiValue.isEnabled()) { | ||
| // New UI default | ||
| PaddingValues(horizontal = 20.dp, vertical = 6.dp) | ||
| } else { | ||
| // Legacy UI default | ||
| PaddingValues(start = 10.dp, top = 5.dp, end = 15.dp, bottom = 5.dp) | ||
| } | ||
|
|
||
| // Get font size offset from LaF following JBUI.CurrentTheme.Advertiser.FONT_SIZE_OFFSET | ||
| // Default is -2 (making font slightly smaller) | ||
| val fontSizeOffset = uiDefaults["Popup.Advertiser.fontSizeOffset"] as? Int ?: -2 | ||
|
|
||
| val baseFontSize = uiDefaults.getFont("Label.font")?.size ?: 13 | ||
| val fontSize = (baseFontSize + fontSizeOffset).coerceAtLeast(9) | ||
|
|
||
| val metrics = PopupAdTextMetrics(padding = borderInsets, minHeight = 20.dp, spacerHeight = 4.dp) | ||
|
|
||
| val textStyle = TextStyle(fontSize = fontSize.sp, fontFamily = FontFamily.Default) | ||
|
|
||
| return PopupAdTextStyle(colors = colors, metrics = metrics, textStyle = textStyle) | ||
| } |
Large diffs are not rendered by default.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
...e/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiPopupAdTextStyling.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
| package org.jetbrains.jewel.intui.standalone.styling | ||
|
|
||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.text.TextStyle | ||
| import androidx.compose.ui.unit.Dp | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.sp | ||
| import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme | ||
| import org.jetbrains.jewel.ui.component.styling.PopupAdTextColors | ||
| import org.jetbrains.jewel.ui.component.styling.PopupAdTextMetrics | ||
| import org.jetbrains.jewel.ui.component.styling.PopupAdTextStyle | ||
|
|
||
| public fun PopupAdTextStyle.Companion.light( | ||
| colors: PopupAdTextColors = PopupAdTextColors.light(), | ||
| metrics: PopupAdTextMetrics = PopupAdTextMetrics.light(), | ||
| textStyle: TextStyle = TextStyle(fontSize = 11.sp), | ||
| ): PopupAdTextStyle = PopupAdTextStyle(colors = colors, metrics = metrics, textStyle = textStyle) | ||
|
|
||
| public fun PopupAdTextColors.Companion.light( | ||
| foreground: Color = Color.Gray, | ||
| background: Color = Color(0xFFF2F2F2), | ||
| ): PopupAdTextColors = PopupAdTextColors(foreground = foreground, background = background) | ||
|
|
||
| public fun PopupAdTextMetrics.Companion.light( | ||
| padding: PaddingValues = PaddingValues(horizontal = 20.dp, vertical = 6.dp), | ||
| minHeight: Dp = 20.dp, | ||
| spacerHeight: Dp = 4.dp, | ||
| ): PopupAdTextMetrics = PopupAdTextMetrics(padding = padding, minHeight = minHeight, spacerHeight = spacerHeight) | ||
|
|
||
| public fun PopupAdTextStyle.Companion.dark( | ||
| colors: PopupAdTextColors = PopupAdTextColors.dark(), | ||
| metrics: PopupAdTextMetrics = PopupAdTextMetrics.dark(), | ||
| textStyle: TextStyle = TextStyle(fontSize = 11.sp), | ||
| ): PopupAdTextStyle = PopupAdTextStyle(colors = colors, metrics = metrics, textStyle = textStyle) | ||
|
|
||
| public fun PopupAdTextColors.Companion.dark( | ||
| foreground: Color = Color.LightGray, | ||
| background: Color = IntUiDarkTheme.colors.grayOrNull(2) ?: Color(0xFF2B2B2B), | ||
| ): PopupAdTextColors = PopupAdTextColors(foreground = foreground, background = background) | ||
|
|
||
| public fun PopupAdTextMetrics.Companion.dark( | ||
| padding: PaddingValues = PaddingValues(horizontal = 20.dp, vertical = 6.dp), | ||
| minHeight: Dp = 20.dp, | ||
| spacerHeight: Dp = 4.dp, | ||
| ): PopupAdTextMetrics = PopupAdTextMetrics(padding = padding, minHeight = minHeight, spacerHeight = spacerHeight) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.