mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(jetbrains): tune question panel typography
This commit is contained in:
+8
-2
@@ -13,6 +13,7 @@ import java.awt.BorderLayout
|
||||
import java.awt.Color
|
||||
import java.awt.Component
|
||||
import java.awt.Dimension
|
||||
import java.awt.Font
|
||||
import javax.swing.Box
|
||||
import javax.swing.BoxLayout
|
||||
import javax.swing.Icon
|
||||
@@ -48,7 +49,9 @@ class BaseSessionQuestionPanel : RoundedContentPanel(
|
||||
val headerText: JBTextArea = makeText("", UiStyle.Colors.fg(), bold = true)
|
||||
|
||||
// ---- description text ----
|
||||
val descriptionText: JBTextArea = makeText("", UiStyle.Colors.weak(), bold = false)
|
||||
val descriptionText: JBTextArea = makeText("", UiStyle.Colors.weak(), bold = false).apply {
|
||||
border = JBUI.Borders.emptyTop(UiStyle.Gap.sm())
|
||||
}
|
||||
|
||||
private val icon = JBLabel().apply {
|
||||
border = JBUI.Borders.emptyRight(UiStyle.Gap.sm())
|
||||
@@ -215,7 +218,10 @@ class BaseSessionQuestionPanel : RoundedContentPanel(
|
||||
}
|
||||
|
||||
private fun applyFont(area: JBTextArea, bold: Boolean) {
|
||||
val font = if (bold) style.boldUiFont else style.uiFont
|
||||
val base = if (bold) style.boldUiFont else style.uiFont
|
||||
val font = larger(base)
|
||||
if (area.font != font) area.font = font
|
||||
}
|
||||
|
||||
private fun larger(font: Font): Font = font.deriveFont((font.size + 1).toFloat())
|
||||
}
|
||||
|
||||
-2
@@ -151,11 +151,9 @@ class QuestionView(
|
||||
} else {
|
||||
val item = q.items[idx]
|
||||
card.headerText.text = item.question
|
||||
card.headerText.border = JBUI.Borders.emptyBottom(UiStyle.Gap.xs())
|
||||
card.descriptionText.text = KiloBundle.message(
|
||||
if (item.multiple) "session.question.hint.multi" else "session.question.hint.single"
|
||||
)
|
||||
card.descriptionText.border = JBUI.Borders.empty()
|
||||
card.descriptionText.isVisible = true
|
||||
addContent(item, selections[idx])
|
||||
}
|
||||
|
||||
+15
-3
@@ -1,6 +1,7 @@
|
||||
package ai.kilocode.client.session.ui.shared
|
||||
|
||||
import ai.kilocode.client.session.ui.style.SessionEditorStyle
|
||||
import ai.kilocode.client.ui.UiStyle
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||
@@ -280,14 +281,25 @@ class BaseSessionQuestionPanelTest : BasePlatformTestCase() {
|
||||
|
||||
// ------ applyStyle: UI fonts ------
|
||||
|
||||
fun `test applyStyle applies boldUiFont to header and uiFont to description`() {
|
||||
fun `test applyStyle applies enlarged boldUiFont to header and enlarged uiFont to description`() {
|
||||
edt {
|
||||
val panel = BaseSessionQuestionPanel()
|
||||
val style = SessionEditorStyle.create(family = "Courier New", size = 20)
|
||||
panel.applyStyle(style)
|
||||
|
||||
assertEquals("headerText should use boldUiFont", style.boldUiFont, panel.headerText.font)
|
||||
assertEquals("descriptionText should use uiFont", style.uiFont, panel.descriptionText.font)
|
||||
assertEquals("headerText should keep boldUiFont family", style.boldUiFont.name, panel.headerText.font.name)
|
||||
assertEquals("descriptionText should keep uiFont family", style.uiFont.name, panel.descriptionText.font.name)
|
||||
assertEquals("headerText should use next font size", style.boldUiFont.size + 1, panel.headerText.font.size)
|
||||
assertEquals("descriptionText should use next font size", style.uiFont.size + 1, panel.descriptionText.font.size)
|
||||
}
|
||||
}
|
||||
|
||||
fun `test description uses next standard top padding`() {
|
||||
edt {
|
||||
val panel = BaseSessionQuestionPanel()
|
||||
val ins = panel.descriptionText.border.getBorderInsets(panel.descriptionText)
|
||||
|
||||
assertEquals("description top padding should use next standard gap", UiStyle.Gap.sm(), ins.top)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -189,7 +189,7 @@ class LoginRequiredViewTest : BasePlatformTestCase() {
|
||||
"Title font should not use editor font family",
|
||||
title!!.font.name == "Courier New",
|
||||
)
|
||||
assertEquals("Title font size should match editor size", 20, title.font.size)
|
||||
assertEquals("Title font size should use next size", 21, title.font.size)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ class LoginRequiredViewTest : BasePlatformTestCase() {
|
||||
"Description font should not use editor font family",
|
||||
desc!!.font.name == "Courier New",
|
||||
)
|
||||
assertEquals("Description font size should match editor size", 20, desc.font.size)
|
||||
assertEquals("Description font size should use next size", 21, desc.font.size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -387,7 +387,7 @@ class PermissionViewTest : BasePlatformTestCase() {
|
||||
val header = view.headerFontForTest()
|
||||
assertFalse("Permission header should not use editor font family", header.name == "Courier New")
|
||||
assertTrue("Permission header should be bold", header.isBold)
|
||||
assertEquals("Permission header size should match editor size", 18, header.size)
|
||||
assertEquals("Permission header size should use next size", 19, header.size)
|
||||
}
|
||||
|
||||
fun `test command code block retains editor font family`() {
|
||||
|
||||
+4
-2
@@ -195,8 +195,10 @@ class QuestionViewTest : BasePlatformTestCase() {
|
||||
val title = text(view, "Choose approach")
|
||||
val hint = text(view, "Select one answer")
|
||||
|
||||
assertEquals(style.boldUiFont, title.font)
|
||||
assertEquals(style.uiFont, hint.font)
|
||||
assertEquals(style.boldUiFont.name, title.font.name)
|
||||
assertEquals(style.uiFont.name, hint.font.name)
|
||||
assertEquals(style.boldUiFont.size + 1, title.font.size)
|
||||
assertEquals(style.uiFont.size + 1, hint.font.size)
|
||||
}
|
||||
|
||||
// ------ multi-question navigation ------
|
||||
|
||||
Reference in New Issue
Block a user