Skip to content

Commit d93eb3a

Browse files
authored
Merge pull request #788 from microsoft/dhruvMishra/snackbarTokenAndElevation
[V2 Snackbar] Added Elevation Tokens to Snackbar
2 parents 1f935c4 + 5574dab commit d93eb3a

File tree

2 files changed

+18
-1
lines changed
  • fluentui_core/src/main/java/com/microsoft/fluentui/theme/token/controlTokens
  • fluentui_notification/src/main/java/com/microsoft/fluentui/tokenized/notification

2 files changed

+18
-1
lines changed

fluentui_core/src/main/java/com/microsoft/fluentui/theme/token/controlTokens/SnackbarTokens.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import androidx.compose.ui.unit.dp
1111
import com.microsoft.fluentui.theme.FluentTheme.aliasTokens
1212
import com.microsoft.fluentui.theme.token.ControlInfo
1313
import com.microsoft.fluentui.theme.token.FluentAliasTokens
14+
import com.microsoft.fluentui.theme.token.FluentGlobalTokens
1415
import com.microsoft.fluentui.theme.token.IControlToken
1516
import kotlinx.parcelize.Parcelize
1617

@@ -91,6 +92,17 @@ open class SnackBarTokens : IControlToken, Parcelable {
9192
)
9293
}
9394

95+
@Composable
96+
open fun shadowElevationValue(snackBarInfo: SnackBarInfo): Dp {
97+
return when (snackBarInfo.style) {
98+
SnackbarStyle.Neutral -> FluentGlobalTokens.ShadowTokens.Shadow02.value
99+
SnackbarStyle.Contrast -> FluentGlobalTokens.ShadowTokens.Shadow16.value
100+
SnackbarStyle.Accent -> FluentGlobalTokens.ShadowTokens.Shadow04.value
101+
SnackbarStyle.Warning -> FluentGlobalTokens.ShadowTokens.Shadow08.value
102+
SnackbarStyle.Danger -> FluentGlobalTokens.ShadowTokens.Shadow00.value
103+
}
104+
}
105+
94106
@Composable
95107
open fun leftIconSize(snackBarInfo: SnackBarInfo): Dp = 24.dp
96108

fluentui_notification/src/main/java/com/microsoft/fluentui/tokenized/notification/Snackbar.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.compose.runtime.*
1515
import androidx.compose.ui.Alignment
1616
import androidx.compose.ui.Modifier
1717
import androidx.compose.ui.draw.clip
18+
import androidx.compose.ui.draw.shadow
1819
import androidx.compose.ui.graphics.graphicsLayer
1920
import androidx.compose.ui.input.pointer.pointerInput
2021
import androidx.compose.ui.platform.LocalConfiguration
@@ -227,7 +228,7 @@ fun Snackbar(
227228
bottom = 12.dp,
228229
end = 16.dp
229230
) else PaddingValues(start = 16.dp, top = 12.dp, bottom = 12.dp)
230-
231+
val shadowElevationValue = token.shadowElevationValue(snackBarInfo)
231232
NotificationContainer(
232233
notificationMetadata = metadata,
233234
hasIcon = metadata.icon != null,
@@ -257,6 +258,10 @@ fun Snackbar(
257258
.padding(horizontal = 16.dp)
258259
.defaultMinSize(minHeight = 52.dp)
259260
.fillMaxWidth()
261+
.shadow(
262+
elevation = shadowElevationValue,
263+
shape = RoundedCornerShape(8.dp)
264+
)
260265
.clip(RoundedCornerShape(8.dp))
261266
.background(token.backgroundBrush(snackBarInfo))
262267
.semantics {

0 commit comments

Comments
 (0)