Skip to content
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

[FC-V3] Add V3 typography and colors #7612

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@

package com.stripe.android.financialconnections.ui.theme

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.stripe.android.financialconnections.ui.FinancialConnectionsPreview
import com.stripe.android.financialconnections.ui.theme.FinancialConnectionsTheme.v3Colors
import com.stripe.android.financialconnections.ui.theme.FinancialConnectionsTheme.v3Typography

internal val Info100 = Color(0xffCFF5F6)
internal val Success100 = Color(0xffD7F7C2)
Expand Down Expand Up @@ -36,6 +50,7 @@ internal val Green500 = Color(0xff228403)
* Financial Connections custom Color Palette
*/
@Immutable
@Deprecated("Use FinancialConnectionsV3Colors")
internal data class FinancialConnectionsColors(
// backgrounds
val backgroundSurface: Color,
Expand All @@ -61,3 +76,73 @@ internal data class FinancialConnectionsColors(
val iconSuccess: Color,
val iconAttention: Color
)

@Immutable
internal data class FinancialConnectionsV3Colors(
val textDefault: Color,
val textSubdued: Color,
val textDisabled: Color,
val textWhite: Color,
val textBrand: Color,
val textCritical: Color,
val iconDefault: Color,
val iconSubdued: Color,
val iconWhite: Color,
val iconBrand: Color,
val buttonPrimary: Color,
val buttonPrimaryHover: Color,
val buttonPrimaryPressed: Color,
val buttonSecondary: Color,
val buttonSecondaryHover: Color,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this refer to, given the absence of hovering on mobile?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now just brought the entire color palette from this Figma, need to verify if it'll be used on some instances on mobile (tap ripples, etc)

val buttonSecondaryPressed: Color,
val background: Color,
val backgroundBrand: Color,
val border: Color,
val borderBrand: Color
)

@Preview(group = "Components", name = "Colors", showBackground = true)
@Composable
internal fun ColorsPreview() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

FinancialConnectionsPreview {
Column {
ColorPreview("textDefault", v3Colors.textDefault)
ColorPreview("textSubdued", v3Colors.textSubdued)
ColorPreview("textDisabled", v3Colors.textDisabled)
ColorPreview("textWhite", v3Colors.textWhite)
ColorPreview("textBrand", v3Colors.textBrand)
ColorPreview("textCritical", v3Colors.textCritical)
ColorPreview("iconDefault", v3Colors.iconDefault)
ColorPreview("iconSubdued", v3Colors.iconSubdued)
ColorPreview("iconWhite", v3Colors.iconWhite)
ColorPreview("iconBrand", v3Colors.iconBrand)
ColorPreview("buttonPrimary", v3Colors.buttonPrimary)
ColorPreview("buttonPrimaryHover", v3Colors.buttonPrimaryHover)
ColorPreview("buttonPrimaryPressed", v3Colors.buttonPrimaryPressed)
ColorPreview("buttonSecondary", v3Colors.buttonSecondary)
ColorPreview("buttonSecondaryHover", v3Colors.buttonSecondaryHover)
ColorPreview("buttonSecondaryPressed", v3Colors.buttonSecondaryPressed)
ColorPreview("background", v3Colors.background)
ColorPreview("backgroundBrand", v3Colors.backgroundBrand)
ColorPreview("border", v3Colors.border)
ColorPreview("borderBrand", v3Colors.borderBrand)
}
}
}

@Composable
private fun ColorPreview(colorText: String, color: Color) {
Row {
Box(
Modifier
.size(40.dp)
.background(color)
)
// a text
Text(
text = colorText,
style = v3Typography.bodyMedium,
modifier = Modifier.padding(10.dp)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.DialogWindowProvider
import androidx.core.view.WindowCompat

private val LightColorPalette = FinancialConnectionsColors(
@Deprecated("Use V3Colors instead")
private val Colors = FinancialConnectionsColors(
backgroundSurface = Color.White,
backgroundContainer = Neutral50,
backgroundBackdrop = Neutral200.copy(alpha = .70f),
Expand All @@ -46,6 +47,30 @@ private val LightColorPalette = FinancialConnectionsColors(
iconAttention = Attention400
)

private val V3Colors = FinancialConnectionsV3Colors(
textDefault = Color(0xFF353A44),
textSubdued = Color(0xFF596171),
textDisabled = Color(0xFF818DA0),
textWhite = Color(0xFFFFFFFF),
textBrand = Color(0xFF533AFD),
textCritical = Color(0xFFC0123C),
iconDefault = Color(0xFF474E5A),
iconSubdued = Color(0xFF6C7688),
iconWhite = Color(0xFFFFFFFF),
iconBrand = Color(0xFF675DFF),
buttonPrimary = Color(0xFF675DFF),
buttonPrimaryHover = Color(0xFF857AFE),
buttonPrimaryPressed = Color(0xFF533AFD),
buttonSecondary = Color(0xFFF5F6F8),
buttonSecondaryHover = Color(0xFFF5F6F8),
buttonSecondaryPressed = Color(0xFFEBEEF1),
background = Color(0xFFF5F6F8),
backgroundBrand = Color(0xFFF5F6F8),
border = Color(0xFFD8DEE4),
borderBrand = Color(0xFF675DFF)
)

@Deprecated("Use V3Typography instead")
private val Typography = FinancialConnectionsTypography(
subtitle = TextStyle(
fontSize = 24.sp,
Expand Down Expand Up @@ -134,22 +159,83 @@ private val Typography = FinancialConnectionsTypography(
),
)

private val V3Typography = FinancialConnectionsV3Typography(
headingXLarge = TextStyle(
fontSize = 28.sp,
lineHeight = 32.sp,
letterSpacing = 0.38.sp,
fontWeight = FontWeight.W700
),
headingLarge = TextStyle(
fontSize = 24.sp,
lineHeight = 32.sp,
letterSpacing = 0.30.sp,
fontWeight = FontWeight.W700
),
headingMedium = TextStyle(
fontSize = 20.sp,
lineHeight = 28.sp,
letterSpacing = 0.30.sp,
fontWeight = FontWeight.W700
),
bodyMediumEmphasized = TextStyle(
fontSize = 16.sp,
lineHeight = 24.sp,
fontWeight = FontWeight.W600
),
bodyMedium = TextStyle(
fontSize = 16.sp,
lineHeight = 24.sp,
fontWeight = FontWeight.W400
),
bodySmall = TextStyle(
fontSize = 14.sp,
lineHeight = 20.sp,
fontWeight = FontWeight.W400
),
labelLargeEmphasized = TextStyle(
fontSize = 16.sp,
lineHeight = 24.sp,
fontWeight = FontWeight.W600
),
labelLarge = TextStyle(
fontSize = 16.sp,
lineHeight = 24.sp,
fontWeight = FontWeight.W400
),
labelMediumEmphasized = TextStyle(
fontSize = 14.sp,
lineHeight = 20.sp,
fontWeight = FontWeight.W600
),
labelMedium = TextStyle(
fontSize = 14.sp,
lineHeight = 20.sp,
fontWeight = FontWeight.W400
),
labelSmall = TextStyle(
fontSize = 12.sp,
lineHeight = 16.sp,
fontWeight = FontWeight.W400
),
)

private val TextSelectionColors = TextSelectionColors(
handleColor = LightColorPalette.textBrand,
backgroundColor = LightColorPalette.textBrand.copy(alpha = 0.4f)
handleColor = V3Colors.textBrand,
backgroundColor = V3Colors.textBrand.copy(alpha = 0.4f)
)

@Immutable
private object FinancialConnectionsRippleTheme : RippleTheme {
@Composable
override fun defaultColor() = RippleTheme.defaultRippleColor(
contentColor = LightColorPalette.textBrand,
contentColor = V3Colors.textBrand,
lightTheme = MaterialTheme.colors.isLight
)

@Composable
override fun rippleAlpha() = RippleTheme.defaultRippleAlpha(
contentColor = LightColorPalette.textBrand,
contentColor = V3Colors.textBrand,
lightTheme = MaterialTheme.colors.isLight
)
}
Expand All @@ -158,7 +244,9 @@ private object FinancialConnectionsRippleTheme : RippleTheme {
internal fun FinancialConnectionsTheme(content: @Composable () -> Unit) {
CompositionLocalProvider(
LocalFinancialConnectionsTypography provides Typography,
LocalFinancialConnectionsColors provides LightColorPalette
LocalV3Typography provides V3Typography,
LocalFinancialConnectionsColors provides Colors,
LocalV3Colors provides V3Colors
) {
Comment on lines 244 to 250
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that the V3 colors and typography are going to be the only ones at some point, right? Would it make sense to have a local feature flag here to decide between both?

Suggested change
internal fun FinancialConnectionsTheme(content: @Composable () -> Unit) {
CompositionLocalProvider(
LocalFinancialConnectionsTypography provides Typography,
LocalFinancialConnectionsColors provides LightColorPalette
LocalV3Typography provides V3Typography,
LocalFinancialConnectionsColors provides Colors,
LocalV3Colors provides V3Colors
) {
internal fun FinancialConnectionsTheme(content: @Composable () -> Unit) {
val colors = if (FeatureFlag.v3Theme.isEnabled) V3Colors else Colors
CompositionLocalProvider(
LocalFinancialConnectionsTypography provides Typography,
LocalFinancialConnectionsColors provides LightColorPalette,
) {
}

Thinking further, you could also easily have this be backend-driven and allow switching themes in the sample app.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They'll all go away before merging the integration branch. The approach will be:

  • Introduce all new theme related options
  • Redesign each pane in the flow (on separate PRs)
  • Delete old theme related code.

you could also easily have this be backend-driven and allow switching themes in the sample app.

We currently don't support dark theme / theme customizations, but introducing them on the Manifest fetched at the start of the flow is a great idea - I'll propose it!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will be transitioning to v3 directly, merging the integration branch once all the design changes (colors + fonts + pane redesign) is all ready. Some more info about it:

val view = LocalView.current
val window = findWindow()
Expand Down Expand Up @@ -205,17 +293,37 @@ private val LocalFinancialConnectionsTypography =
error("no FinancialConnectionsTypography provided")
}

private val LocalV3Typography =
staticCompositionLocalOf<FinancialConnectionsV3Typography> {
error("no V3Typography provided")
}

private val LocalV3Colors =
staticCompositionLocalOf<FinancialConnectionsV3Colors> {
error("no V3Colors provided")
}

private val LocalFinancialConnectionsColors = staticCompositionLocalOf<FinancialConnectionsColors> {
error("No FinancialConnectionsColors provided")
}

internal object FinancialConnectionsTheme {

@Deprecated("Use v3Colors instead")
val colors: FinancialConnectionsColors
@Composable
get() = LocalFinancialConnectionsColors.current

@Deprecated("Use v3Typography instead")
val typography: FinancialConnectionsTypography
@Composable
get() = LocalFinancialConnectionsTypography.current
val v3Typography
@Composable
get() = LocalV3Typography.current
val v3Colors
@Composable
get() = LocalV3Colors.current
}

/**
Expand Down
Loading
Loading