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

Task/aa 3297 create awaiting reimbursement item #336

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Changes from 1 commit
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
Next Next commit
[Grapes] - Add GrapesStackLogo and GrapesStackSurface
  • Loading branch information
Scythe14 committed Jan 30, 2024
commit c14741d14215b11cfbf968a00eebe34bd05c4963
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.spendesk.grapes.compose.logo

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.spendesk.grapes.compose.theme.GrapesTheme

/**
* @author : dany
* @since : 30/01/2024, Tue
**/

private const val GrapesStackSurfaceMaxLines = 1

@Composable
fun GrapesStackLogo(
numberOfStack: Int,
modifier: Modifier = Modifier,
) {
GrapesLargeLogoContainer(modifier = modifier) {
GrapesStackSurface(modifier = modifier.align(if (numberOfStack > 1) Alignment.TopStart else Alignment.Center), text = numberOfStack.toString())

if (numberOfStack > 1) {
val highlightIconOffset = GrapesTheme.dimensions.spacing1

Box(
modifier = Modifier
.align(Alignment.TopStart)
.size(GrapesTheme.dimensions.grapesStackSurface)
.offset(x = highlightIconOffset, y = highlightIconOffset),
) {
GrapesStackSurface(text = numberOfStack.toString())
}
}
}
}

@Composable
fun GrapesStackSurface(
modifier: Modifier = Modifier,
text: String? = null
) {
GrapesLargeLogoContainer(
modifier = modifier
.size(GrapesTheme.dimensions.grapesStackSurface)
.border(1.dp, color = GrapesTheme.colors.neutralLighter, shape = GrapesTheme.shapes.shape2)
.clip(GrapesTheme.shapes.shape2)
.background(GrapesTheme.colors.neutralLightest)
) {
text?.let {
Text(
modifier = Modifier.align(Alignment.Center),
text = text,
style = GrapesTheme.typography.titleM,
color = GrapesTheme.colors.neutralDark,
textAlign = TextAlign.Center,
maxLines = GrapesStackSurfaceMaxLines,
overflow = TextOverflow.Ellipsis,
)
}
}
}

@Preview
@Composable
private fun GrapesStackLogoPreview() {
GrapesTheme {
Column(verticalArrangement = Arrangement.spacedBy(GrapesTheme.dimensions.spacing1)) {
GrapesStackSurface(text = "2")
GrapesStackSurface(text = "24")
GrapesStackSurface(text = "24343")
Spacer(modifier = Modifier.size(GrapesTheme.dimensions.spacing3))
GrapesStackLogo(numberOfStack = 5)
GrapesStackLogo(numberOfStack = 1)
}
}
}
Original file line number Diff line number Diff line change
@@ -49,7 +49,9 @@ data class GrapesDimensions(
val sizing7: Dp = 56.dp,

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

val grapesStackSurface: Dp = 36.dp
Copy link
Contributor

Choose a reason for hiding this comment

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

This dimension is not intended to be reused elsewhere than in the composable, so it must stay at the composable level. We should try to keep only these dimensions here : https://www.figma.com/file/fiCb2Cltq1gJuByGKvxLNb/%F0%9F%8D%87--Design-Tokens?type=design&node-id=2978-20087&mode=design&t=AcLTEy1QplJFUZTk-4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

trou

)

internal val LocalGrapesDimensions = staticCompositionLocalOf { GrapesDimensions() }