Skip to content

Commit

Permalink
BezierBadge 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sodp5 committed Sep 24, 2024
1 parent da0fd48 commit e2581ff
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,22 @@ class ColorSchemes internal constructor(
val fgGreenDark: BezierColor = functionalTokens.fgGreenDark
val fgTealNormal: BezierColor = functionalTokens.fgTealNormal
val fgTealLight: BezierColor = functionalTokens.fgTealLight
val fgTealDark: BezierColor = functionalTokens.fgTealDark
val fgOliveNormal: BezierColor = functionalTokens.fgOliveNormal
val fgOliveLight: BezierColor = functionalTokens.fgOliveLight
val fgOliveDark: BezierColor = functionalTokens.fgOliveDark
val fgYellowNormal: BezierColor = functionalTokens.fgYellowNormal
val fgYellowLight: BezierColor = functionalTokens.fgYellowLight
val fgYellowDark: BezierColor = functionalTokens.fgYellowDark
val fgPinkNormal: BezierColor = functionalTokens.fgPinkNormal
val fgPinkLight: BezierColor = functionalTokens.fgPinkLight
val fgPinkDark: BezierColor = functionalTokens.fgPinkDark
val fgPurpleNormal: BezierColor = functionalTokens.fgPurpleNormal
val fgPurpleLight: BezierColor = functionalTokens.fgPurpleLight
val fgPurpleDark: BezierColor = functionalTokens.fgPurpleDark
val fgNavyNormal: BezierColor = functionalTokens.fgNavyNormal
val fgNavyLight: BezierColor = functionalTokens.fgNavyLight
val fgNavyDark: BezierColor = functionalTokens.fgNavyDark
val fgAbsoluteBlackDark: BezierColor = functionalTokens.fgAbsoluteBlackDark
val fgAbsoluteBlackNormal: BezierColor = functionalTokens.fgAbsoluteBlackNormal
val fgAbsoluteBlackLight: BezierColor = functionalTokens.fgAbsoluteBlackLight
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package io.channel.bezier.compose.component.badge

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
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.foundation.shape.RoundedCornerShape
import androidx.compose.material.Icon
import androidx.compose.material.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.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.channel.bezier.BezierIcon
import io.channel.bezier.BezierIcons
import io.channel.bezier.BezierTheme
import io.channel.bezier.compose.component.badge.properties.BezierBadgeColor
import io.channel.bezier.compose.component.badge.properties.BezierBadgeSize
import io.channel.bezier.icon.CircleSmall

@Composable
fun BezierBadge(
text: String,
size: BezierBadgeSize,
color: BezierBadgeColor,
modifier: Modifier = Modifier,
icon: BezierIcon? = null,
) {
Row(
modifier = modifier
.clip(RoundedCornerShape(size.radius))
.background(color.backgroundColor().color)
.padding(size.backgroundPadding),
horizontalArrangement = Arrangement.spacedBy(size.contentGap),
verticalAlignment = Alignment.CenterVertically,
) {
if (icon != null) {
Icon(
modifier = Modifier.size(size.iconSize),
imageVector = icon.imageVector,
contentDescription = icon.imageVector.name,
tint = color.contentColor().color,
)
}

Text(
modifier = Modifier.padding(size.textPadding),
text = text,
style = size.textStyle(),
color = color.contentColor().color,
)
}
}

@Composable
@Preview(
showBackground = true,
widthDp = 1300,
)
fun BezierBadgePreview() {
BezierTheme {
Column(
modifier = Modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
BezierBadgeSize.entries.forEach { size ->
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
BezierBadgeColor.entries.forEach { color ->
BezierBadge(
text = "Label",
size = size,
color = color,
icon = BezierIcons.CircleSmall,
)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package io.channel.bezier.compose.component.badge.properties

import androidx.compose.runtime.Composable
import io.channel.bezier.BezierTheme
import io.channel.bezier.compose.color_v2.BezierColor

enum class BezierBadgeColor(
val backgroundColor: @Composable () -> BezierColor,
val contentColor: @Composable () -> BezierColor,
) {
Grey(
backgroundColor = { BezierTheme.colorSchemes.bgBlackLighter },
contentColor = { BezierTheme.colorSchemes.fgBlackDarker },
),
DarkGrey(
backgroundColor = { BezierTheme.colorSchemes.bgBlackDarker },
contentColor = { BezierTheme.colorSchemes.fgAbsoluteWhiteDark },
),
Blue(
backgroundColor = { BezierTheme.colorSchemes.bgBlueShadeLight },
contentColor = { BezierTheme.colorSchemes.fgBlackDark },
),
Cobalt(
backgroundColor = { BezierTheme.colorSchemes.bgCobaltShadeLight },
contentColor = { BezierTheme.colorSchemes.fgCobaltDark },
),
Teal(
backgroundColor = { BezierTheme.colorSchemes.bgTealShadeLight },
contentColor = { BezierTheme.colorSchemes.fgTealDark },
),
Green(
backgroundColor = { BezierTheme.colorSchemes.bgGreenShadeLight },
contentColor = { BezierTheme.colorSchemes.successFgDark },
),
Olive(
backgroundColor = { BezierTheme.colorSchemes.bgOliveShadeLight },
contentColor = { BezierTheme.colorSchemes.fgOliveDark },
),
Pink(
backgroundColor = { BezierTheme.colorSchemes.bgPinkShadeLight },
contentColor = { BezierTheme.colorSchemes.fgPinkDark },
),
Navy(
backgroundColor = { BezierTheme.colorSchemes.bgNavyShadeLight },
contentColor = { BezierTheme.colorSchemes.fgNavyDark },
),
Yellow(
backgroundColor = { BezierTheme.colorSchemes.bgYellowShadeLight },
contentColor = { BezierTheme.colorSchemes.fgYellowDark },
),
Orange(
backgroundColor = { BezierTheme.colorSchemes.bgOrangeShadeLight },
contentColor = { BezierTheme.colorSchemes.fgOrangeDark },
),
Red(
backgroundColor = { BezierTheme.colorSchemes.bgRedShadeLight },
contentColor = { BezierTheme.colorSchemes.criticalFgDark },
),
Purple(
backgroundColor = { BezierTheme.colorSchemes.bgPurpleShadeLight },
contentColor = { BezierTheme.colorSchemes.fgPurpleDark },
),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.channel.bezier.compose.component.badge.properties

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import io.channel.bezier.BezierTheme

enum class BezierBadgeSize(
internal val textStyle: @Composable () -> TextStyle,
internal val iconSize: Dp,
internal val backgroundPadding: PaddingValues,
internal val textPadding: PaddingValues,
internal val contentGap: Dp,
internal val radius: Dp,
) {
Small(
textStyle = { BezierTheme.typography.caption3SemiBold },
iconSize = 12.dp,
backgroundPadding = PaddingValues(horizontal = 3.dp, vertical = 1.dp),
textPadding = PaddingValues(horizontal = 2.dp),
contentGap = 0.dp,
radius = 4.dp,
),
Large(
textStyle = { BezierTheme.typography.body2SemiBold },
iconSize = 16.dp,
backgroundPadding = PaddingValues(horizontal = 8.dp, vertical = 3.dp),
textPadding = PaddingValues(horizontal = 3.dp),
contentGap = 3.dp,
radius = 7.dp,
),
}

0 comments on commit e2581ff

Please sign in to comment.