Skip to content

Commit

Permalink
Second pass for tonal text components
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Jan 22, 2025
1 parent c9d1934 commit 2cfc2fb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,12 @@ public String toString() {
public static final ContainerColorTokensAssociationKind HIGHLIGHT =
new ContainerColorTokensAssociationKind("highlight");

/**
* Highlight visual areas for text components.
*/
public static final ContainerColorTokensAssociationKind HIGHLIGHT_TEXT =
new ContainerColorTokensAssociationKind("highlight_text");

/**
* Visual area of separators.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,13 @@ public static Color getTextBackgroundFill(Component component, ComponentState co
if (overlay != null) {
return overlay;
}
return RadianceColorSchemeUtilities.getColorScheme(component, componentState).getTextBackgroundFillColor();
if (skin instanceof TonalSkin) {
return RadianceColorSchemeUtilities.getContainerTokens(component, componentState,
RadianceThemingSlices.ContainerType.NEUTRAL).getContainerSurfaceLowest();
} else {
return RadianceColorSchemeUtilities.getColorScheme(component, componentState)
.getTextBackgroundFillColor();
}
}

public static Color getTextSelectionBackground(Component component, ComponentState componentState) {
Expand All @@ -1899,8 +1905,15 @@ public static Color getTextSelectionBackground(Component component, ComponentSta
if (overlay != null) {
return overlay;
}
return RadianceColorSchemeUtilities.getColorScheme(
component, RadianceThemingSlices.ColorSchemeAssociationKind.HIGHLIGHT_TEXT, componentState).getSelectionBackgroundColor();
if (skin instanceof TonalSkin) {
return RadianceColorSchemeUtilities.getContainerTokens(component,
RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT_TEXT, componentState,
RadianceThemingSlices.ContainerType.TONAL).getContainerSurfaceLow();
} else {
return RadianceColorSchemeUtilities.getColorScheme(component,
RadianceThemingSlices.ColorSchemeAssociationKind.HIGHLIGHT_TEXT, componentState)
.getSelectionBackgroundColor();
}
}

public static Color getTextSelectionForeground(Component component, ComponentState componentState) {
Expand All @@ -1911,7 +1924,14 @@ public static Color getTextSelectionForeground(Component component, ComponentSta
if (overlay != null) {
return overlay;
}
return RadianceColorSchemeUtilities.getColorScheme(
component, RadianceThemingSlices.ColorSchemeAssociationKind.HIGHLIGHT_TEXT, componentState).getSelectionForegroundColor();
if (skin instanceof TonalSkin) {
return RadianceColorSchemeUtilities.getContainerTokens(component,
RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT_TEXT, componentState,
RadianceThemingSlices.ContainerType.TONAL).getOnContainer();
} else {
return RadianceColorSchemeUtilities.getColorScheme(component,
RadianceThemingSlices.ColorSchemeAssociationKind.HIGHLIGHT_TEXT, componentState)
.getSelectionForegroundColor();
}
}
}

0 comments on commit 2cfc2fb

Please sign in to comment.