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

Remove deprecated design tokens #362

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fun GrapesBucketHeadline(
style = GrapesTheme.typography.titleM
)
if (action != null && actionColor != null) {
Spacer(modifier = Modifier.size(GrapesTheme.dimensions.paddingMedium))
Spacer(modifier = Modifier.size(GrapesTheme.dimensions.sizing1))
Text(
modifier = Modifier.clickable(onClick = onActionClicked ?: {}, onClickLabel = action, role = Role.Button),
text = action,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ object GrapesGaugeDefaults {

const val GaugeAddDelimiter = true
val GaugeStrippedWidth = 5.dp
val gaugeHeight: Dp = 16.dp
val gaugeDelimiterWidth: Dp = 2.dp
}

sealed class Gauge(open val progress: Float) {
Expand Down Expand Up @@ -109,7 +111,7 @@ private fun GrapesGaugeContainer(
.clip(clipShape)
.background(backgroundColor)
.fillMaxWidth()
.height(GrapesTheme.dimensions.gaugeHeight)
.height(GrapesGaugeDefaults.gaugeHeight)
) {
content()
}
Expand Down Expand Up @@ -161,7 +163,7 @@ private fun GrapesGaugeDelimiter() {
Box(
modifier = Modifier
.fillMaxHeight()
.width(GrapesTheme.dimensions.gaugeDelimiterWidth)
.width(GrapesGaugeDefaults.gaugeDelimiterWidth)
.background(GrapesTheme.colors.mainWhite)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fun SectionItem(
verticalAlignment = Alignment.CenterVertically,
modifier = modifier.padding(
horizontal = GrapesTheme.dimensions.spacing3,
vertical = GrapesTheme.dimensions.paddingMedium,
vertical = GrapesTheme.dimensions.sizing1,
),
) {
icon(Modifier.size(iconSize))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private fun Select(
modifier = modifier,
contentPadding = PaddingValues(
horizontal = GrapesTheme.dimensions.spacing3,
vertical = GrapesTheme.dimensions.paddingMedium,
vertical = GrapesTheme.dimensions.sizing1,
),
icon = {
GrapesSelectIcon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fun GrapesTag(
) {
Surface(
modifier = modifier.wrapContentSize(),
shape = LocalGrapesShapes.current.xSmall,
shape = LocalGrapesShapes.current.shape1,
color = backgroundColor,
border = BorderStroke(GrapesTagDefaults.borderThickness, borderColor),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fun AskTemplate(
@Composable
fun Preview() {
val cta = @Composable {
Column(verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.paddingMedium)) {
Column(verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.sizing1)) {
GrapesButton(
text = "Main button",
buttonStyle = GrapesButtonStyleDefaults.secondary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fun ErrorTemplate(
}

description?.let {
Spacer(modifier = Modifier.height(GrapesTheme.dimensions.paddingMedium))
Spacer(modifier = Modifier.height(GrapesTheme.dimensions.sizing1))
AnimatedVisibility(visible = isVisible, enter = configuration.descriptionEnterAnimation) {
description()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ fun GrapesTextBlockInformativeLabel(
private fun TextBlockOptionalTitlePreview() {
GrapesTheme {
Column(
modifier = Modifier.padding(GrapesTheme.dimensions.paddingLarge),
verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.paddingLarge)
modifier = Modifier.padding(GrapesTheme.dimensions.spacing3),
verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.spacing3)
) {
GrapesTextBlockInformativeLabel("Missing", color = GrapesTheme.colors.warningNormal)
GrapesTextBlockInformativeLabel("Optional", color = GrapesTheme.colors.neutralNormal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ private fun ColoredTextBlockAction(
fun PrimaryTextBlockActionPreview() {
GrapesTheme {
Column(
modifier = Modifier.padding(GrapesTheme.dimensions.paddingLarge),
verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.paddingLarge)
modifier = Modifier.padding(GrapesTheme.dimensions.spacing3),
verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.spacing3)
) {
GrapesPrimaryTextBlockAction("Test", onActionClicked = {})
GrapesPrimaryTextBlockAction("Test disabled", isEnabled = false, onActionClicked = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ fun GrapesRetryTextBlockAction(retryLabel: String, onRetryClicked: () -> Unit, m
fun TextBlockActionPreview() {
GrapesTheme {
Column(
modifier = Modifier.padding(GrapesTheme.dimensions.paddingLarge),
verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.paddingLarge)
modifier = Modifier.padding(GrapesTheme.dimensions.spacing3),
verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.spacing3)
) {
GrapesRetryTextBlockAction("Tap to retry", onRetryClicked = {})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ data class GrapesDimensions(

val borderLarge: Dp = 2.0.dp,

@Deprecated("Grapes dimension deprecated", ReplaceWith("spacing1"))
val paddingXSmall: Dp = 4.dp,
@Deprecated("Grapes dimension deprecated", ReplaceWith("spacing2"))
val paddingSmall: Dp = 8.dp,
@Deprecated("Grapes dimension deprecated, new design shouldn't use 12.dp anymore")
val paddingMedium: Dp = 12.dp,
@Deprecated("Grapes dimension deprecated", ReplaceWith("spacing3"))
val paddingLarge: Dp = 16.dp,
@Deprecated("Grapes dimension deprecated", ReplaceWith("spacing4"))
val paddingXLarge: Dp = 24.dp,

val spacing0: Dp = 0.dp,
val spacing1: Dp = 4.dp,
val spacing2: Dp = 8.dp,
Expand All @@ -47,9 +36,6 @@ data class GrapesDimensions(
val sizing5: Dp = 32.dp,
val sizing6: Dp = 40.dp,
val sizing7: Dp = 56.dp,

val gaugeHeight: Dp = 16.dp,
val gaugeDelimiterWidth: Dp = 2.dp
)

internal val LocalGrapesDimensions = staticCompositionLocalOf { GrapesDimensions() }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.spendesk.grapes.compose.theme

import androidx.compose.foundation.shape.CornerBasedShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.unit.dp
Expand All @@ -17,40 +16,13 @@ data class GrapesShapes(
val shape1: CornerBasedShape = RoundedCornerShape(cornerRadius1Dp),
val shape2: CornerBasedShape = RoundedCornerShape(cornerRadius2Dp),
val shape3: CornerBasedShape = RoundedCornerShape(cornerRadius3Dp),
val shape4: CornerBasedShape = RoundedCornerShape(cornerRadiusRoundedPercent),

@Deprecated("Grapes shape deprecated", ReplaceWith("shape1"))
val xSmall: CornerBasedShape = RoundedCornerShape(XSmallShapeCornerRadius),

/**
* Shape used by small components like [Button] or [Snackbar]. Components like
* [FloatingActionButton], [ExtendedFloatingActionButton] use this shape, but override
* the corner size to be 50%. [TextField] uses this shape with overriding the bottom corners
* to zero.
*/
@Deprecated("Grapes shape deprecated", ReplaceWith("shape2"))
val small: CornerBasedShape = RoundedCornerShape(SmallShapeCornerRadius),
/**
* Shape used by medium components like [Card] or [AlertDialog].
*/
@Deprecated("Grapes shape deprecated - no longer use 12dp border radius.")
val medium: CornerBasedShape = RoundedCornerShape(MediumShapeCornerRadius),
/**
* Shape used by large components like [ModalDrawer] or [ModalBottomSheetLayout].
*/
@Deprecated("Grapes shape deprecated", ReplaceWith("shape0"))
val large: CornerBasedShape = RoundedCornerShape(LargeShapeCornerRadius)
val shape4: CornerBasedShape = RoundedCornerShape(CornerRadiusRoundedPercent),
)

private val cornerRadius0Dp = 0.dp
private val cornerRadius1Dp = 4.dp
private val cornerRadius2Dp = 8.dp
private val cornerRadius3Dp = 16.dp
private const val cornerRadiusRoundedPercent = 50

private val XSmallShapeCornerRadius = 4.dp
private val SmallShapeCornerRadius = 8.dp
private val MediumShapeCornerRadius = 12.dp
private val LargeShapeCornerRadius = 0.dp
private const val CornerRadiusRoundedPercent = 50

internal val LocalGrapesShapes = staticCompositionLocalOf { GrapesShapes() }
Loading