Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 11 additions & 12 deletions Documentation/style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,19 @@ Shadows use CSS box-shadow syntax:

Format: `offsetX offsetY blurRadius spreadRadius color`. Set to `"none"` to disable a shadow entirely.

`--multimodal-card-box-shadow` renders as a drop shadow on `ExtendedProductCard`, but only two of the five values are actually applied — Compose's `Modifier.shadow` is elevation-based, not a literal box-shadow renderer:
Both shadow tokens render as CSS-accurate drop shadows: `--input-box-shadow` behind the chat input bar (`ChatInputPanel`) and `--multimodal-card-box-shadow` behind each `ExtendedProductCard` (`cardStyle: productDetail`). On Android 9 (API 28) and above, all five values are applied:

| Token | Consumed? | Effect |
|-------|-----------|--------|
| `offsetX` | ❌ | Parsed but ignored — no horizontal-offset equivalent in Compose's shadow |
| `offsetY` | ❌ | Parsed but ignored — no vertical-offset equivalent either |
| `blurRadius` | ✅ | Becomes the shadow's `elevation` (dp) |
| `spreadRadius` | ❌ | Parsed but ignored — no spread equivalent |
| `color` | ✅ | Used as both `ambientColor` and `spotColor` |
| `offsetX` | ✅ | Horizontal shadow offset (dp) |
| `offsetY` | ✅ | Vertical shadow offset (dp) |
| `blurRadius` | ✅ | Gaussian blur matching CSS (sigma = blur / 2) |
| `spreadRadius` | ✅ | Grows (or, if negative, shrinks) the shadow before blurring |
| `color` | ✅ | Shadow color, including its alpha |

Low alpha values (e.g. `#00000014` ≈ 8%) are barely visible against a white background — increase alpha (e.g. `#00000040`+) for a more visible effect.
As with CSS, the shadow is not drawn underneath the input bar or card itself.

`--input-box-shadow` is parsed into the same shape but isn't rendered by any composable yet (see status table below).
Below API 28 the shadows fall back to Compose's elevation-based `Modifier.shadow`, with `blurRadius` as the elevation. Offset and spread are ignored, and so is `color`: Android only supports custom shadow colors from API 28, so these devices always draw the system's default grey elevation shadow.

### Gradients

Expand Down Expand Up @@ -1439,7 +1439,7 @@ This section documents which properties are fully implemented, partially impleme

**Key Differences from Web/iOS:**
- Hover states (`--button-primary-hover`, `--feedback-icon-btn-hover-background`) are parsed but not applicable on Android
- Box shadows are parsed but not currently rendered
- Box shadows render CSS-accurately on API 28+; older devices use an elevation-based approximation that ignores offset, spread and color
- Most layout dimensions (padding, margins, border radius) are hardcoded rather than theme-driven
- `*.aria` accessibility-label text keys are not parsed by the Android SDK at all — omit them

Expand Down Expand Up @@ -1668,7 +1668,7 @@ Note: The feedback dialog checkbox uses `--color-primary` for the check box fill
| `--input-button-height` | ✅ | Sizes every input-row icon (leading AI-chat icon, clear, mic, send, stop-recording) | `ConciergeStyles.inputRowIconSize` |
| `--input-button-width` | ✅ | Sizes every input-row icon (leading AI-chat icon, clear, mic, send, stop-recording) | `ConciergeStyles.inputRowIconSize` |
| `--input-button-border-radius` | ⚠️ | Parsed but not used in composables | - |
| `--input-box-shadow` | ⚠️ | Parsed but shadows not rendered | - |
| `--input-box-shadow` | ✅ | Input bar drop shadow (offset, blur, spread and color on API 28+; elevation-based fallback below) | `ChatInputPanel` |
| `--message-border-radius` | ✅ | Corner radius for all message bubbles; applies to both user and agent bubbles | `ChatMessageItem` |
| `--message-padding` | ✅ | Agent bubble text and sources only, with or without a company icon. Unset keeps the previous layout; user bubbles keep 12dp. | `ConciergeStyles`, `ChatMessageItem` |
| `--message-max-width` | ⚠️ | Parsed but not used in composables | - |
Expand All @@ -1680,7 +1680,7 @@ Note: The feedback dialog checkbox uses `--color-primary` for the check box fill
| `--chat-history-bottom-padding` | ⚠️ | Parsed but not used in composables | - |
| `--message-blocker-height` | ⚠️ | Parsed but not used in composables | - |
| `--border-radius-card` | ✅ | Corner radius of the privacy notice card | `PrivacyNoticeView` |
| `--multimodal-card-box-shadow` | ✅ | Card drop shadow (blur radius → elevation, color → ambient/spot shadow color) | `ExtendedProductCard` |
| `--multimodal-card-box-shadow` | ✅ | Card drop shadow (offset, blur, spread and color on API 28+; elevation-based fallback below) | `ExtendedProductCard` |
| `--product-card-width` | ✅ | Extended product card width | `ExtendedProductCard`, `ProductCarousel` |
| `--product-card-min-height` | ✅ | Minimum card height; card grows with content | `ExtendedProductCard` |
| `--product-card-max-height` | ✅ | Maximum card height; content beyond this scrolls internally | `ExtendedProductCard` |
Expand Down Expand Up @@ -1850,7 +1850,6 @@ When creating themes for the Android SDK, focus on these **actively used** prope
These properties are parsed but **not currently used** and can be omitted without affecting the UI:

- Hover states (all `*-hover` properties)
- Box shadows (all `*-box-shadow` properties)
- Most layout dimensions (padding, margins, border radius) - currently hardcoded
- Disabled button states
- Accessibility labels (`*.aria` text keys are not parsed by the Android SDK at all)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,38 @@ class ExtendedProductCardTest {
)
}

@Test
fun extendedProductCard_shadowHonorsVerticalOffset() {
val themeData = ConciergeThemeData(
config = ConciergeThemeConfig(),
tokens = ConciergeThemeTokens(
cssLayout = ConciergeLayout(
multimodalCardBoxShadow = mapOf(
"offsetX" to 0.0,
"offsetY" to 8.0,
"blurRadius" to 4.0,
"spreadRadius" to 0.0,
"color" to Color.Black
)
)
)
)

renderCardOnWhiteBackground(themeData)
composeTestRule.waitForIdle()
val bitmap = composeTestRule.onRoot().captureToImage().asAndroidBitmap()
val density = composeTestRule.density.density
val outerPaddingPx = shadowOuterPadding.value * density
val sampleX = (outerPaddingPx + 40.dp.value * density).toInt()
val aboveY = (outerPaddingPx - 4.dp.value * density).toInt()
val belowY = (outerPaddingPx + (cardMaxHeight.value + 4.dp.value) * density).toInt()
val redAbove = android.graphics.Color.red(bitmap.getPixel(sampleX, aboveY))
val redBelow = android.graphics.Color.red(bitmap.getPixel(sampleX, belowY))

assertTrue("Expected no shadow above a downward-offset card, but found red=$redAbove", redAbove >= 250)
assertTrue("Expected a shadow below a downward-offset card, but found red=$redBelow", redBelow < 250)
}

@Test
fun extendedProductCard_noShadowBeyondCardBounds_whenThemeHasNoBoxShadow() {
renderCardOnWhiteBackground(themeData = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@

package com.adobe.marketing.mobile.concierge.ui.components.input

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toPixelMap
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertHeightIsEqualTo
Expand All @@ -27,9 +30,12 @@ import androidx.compose.ui.test.hasContentDescription
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performClick
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.adobe.marketing.mobile.concierge.ui.state.UserInputState
import com.adobe.marketing.mobile.concierge.ui.theme.CSSValueConverter
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeGradientColors
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeInputColors
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeLayout
Expand Down Expand Up @@ -571,4 +577,81 @@ class ChatInputPanelTest {
composeTestRule.waitForIdle()
composeTestRule.onNodeWithTag("ChatInputLeadingIcon").assertDoesNotExist()
}

// -----------------------------------------------------------------------
// Drop shadow rendering (--input-box-shadow)
// -----------------------------------------------------------------------

private val shadowOuterPadding = 40.dp

private fun renderPanelOnWhiteBackground(inputBoxShadow: String?) {
val themeData = ConciergeThemeData(
config = ConciergeThemeConfig(),
tokens = ConciergeThemeTokens(
cssLayout = ConciergeLayout(
inputBoxShadow = inputBoxShadow?.let { CSSValueConverter.parseBoxShadow(it) }
)
)
)

composeTestRule.setContent {
ConciergeTheme(theme = themeData) {
Box(
modifier = Modifier
.background(Color.White)
.padding(shadowOuterPadding)
) {
ChatInputPanel(
modifier = Modifier.width(240.dp).testTag("ShadowPanel"),
text = "",
onTextChange = {},
inputState = UserInputState.Empty,
onMicPressed = {},
onSend = {}
)
}
}
}
composeTestRule.waitForIdle()
}

/** Red channels of the root pixels [distance] above and below the panel, horizontally centered. */
private fun sampleAboveAndBelowPanel(distance: Dp = 4.dp): Pair<Int, Int> {
val bounds = composeTestRule.onNodeWithTag("ShadowPanel").getUnclippedBoundsInRoot()
val pixels = composeTestRule.onRoot().captureToImage().toPixelMap()
val density = composeTestRule.density.density
val x = (((bounds.left + bounds.right) / 2).value * density).toInt()
val above = ((bounds.top - distance).value * density).toInt()
val below = ((bounds.bottom + distance).value * density).toInt()
return (pixels[x, above].red * 255).toInt() to (pixels[x, below].red * 255).toInt()
}

@Test
fun chatInputPanel_rendersShadowBeyondBounds_whenThemeConfiguresInputBoxShadow() {
renderPanelOnWhiteBackground("0 0 16px 0 #000000")
val (above, below) = sampleAboveAndBelowPanel()

assertTrue("expected a visible shadow above the panel, found red=$above", above < 250)
assertTrue("expected a visible shadow below the panel, found red=$below", below < 250)
}

@Test
fun chatInputPanel_shadowHonorsVerticalOffset() {
renderPanelOnWhiteBackground("0 12px 8px 0 #000000")
val (above, below) = sampleAboveAndBelowPanel()

assertTrue(
"expected the offset shadow to be darker below ($below) than above ($above) the panel",
below < above
)
}

@Test
fun chatInputPanel_noShadowBeyondBounds_whenInputBoxShadowIsNone() {
renderPanelOnWhiteBackground("none")
val (above, below) = sampleAboveAndBelowPanel()

assertTrue("expected no shadow above the panel, found red=$above", above >= 250)
assertTrue("expected no shadow below the panel, found red=$below", below >= 250)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ class ConciergeStylesTest {
}

@Test
fun extendedProductCardStyle_withBoxShadowToken_shadowElevationAndColorReflectBlurAndColor() {
fun extendedProductCardStyle_withBoxShadowToken_boxShadowReflectsAllValues() {
var style: ConciergeStyles.ExtendedProductCardStyle? = null
val themeData = ConciergeThemeData(
config = ConciergeThemeConfig(),
Expand All @@ -1151,12 +1151,20 @@ class ConciergeStylesTest {

composeTestRule.waitForIdle()
assertNotNull(style)
assertEquals(3.dp, style!!.shadowElevation)
assertEquals(Color(0x14000000), style!!.shadowColor)
assertEquals(
ConciergeBoxShadow(
offsetX = 0.dp,
offsetY = 1.dp,
blurRadius = 3.dp,
spreadRadius = 0.dp,
color = Color(0x14000000)
),
style!!.boxShadow
)
}

@Test
fun extendedProductCardStyle_noBoxShadowToken_shadowElevationIsZeroAndColorIsTransparent() {
fun extendedProductCardStyle_noBoxShadowToken_boxShadowIsNull() {
var style: ConciergeStyles.ExtendedProductCardStyle? = null

composeTestRule.setContent {
Expand All @@ -1169,8 +1177,7 @@ class ConciergeStylesTest {
assertNotNull(style)
// Covers both an unset theme and an explicit "none" box-shadow, since parseBoxShadow
// collapses "none" to the same null the token has when it's never set.
assertEquals(0.dp, style!!.shadowElevation)
assertEquals(Color.Transparent, style!!.shadowColor)
assertNull(style!!.boxShadow)
}

// -----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.adobe.marketing.mobile.concierge.ui.chat.ConciergeChatViewModel
import com.adobe.marketing.mobile.concierge.ui.state.ChatEvent
import com.adobe.marketing.mobile.concierge.ui.state.Feedback
import com.adobe.marketing.mobile.concierge.ui.stt.AndroidSpeechCapturing
import com.adobe.marketing.mobile.concierge.ui.theme.CSSValueConverter
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeLayout
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeProductCardBehavior
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeProductCardCtaButtonColors
Expand Down Expand Up @@ -172,7 +173,8 @@ private val demoProductCards = listOf(
/**
* Matches the "Vertical Card - With description" design spec (222x468, 190x190 image, 8dp radius,
* #E3E3E3 outline, subtle drop shadow) and selects the [ProductCardStyle.PRODUCT_DETAIL] extended
* card so the CTA button is exercised.
* card so the CTA button is exercised. The input bar also gets a drop shadow so both box-shadow
* tokens can be inspected on one screen.
*/
private val demoProductCardTheme = ConciergeThemeData(
config = ConciergeThemeConfig(),
Expand All @@ -189,7 +191,9 @@ private val demoProductCardTheme = ConciergeThemeData(
productImageHeight = 190.0,
productCardBorderRadius = 8.0,
productCardOutlineColor = "#E3E3E3",
productCardBackgroundColor = "#FFFFFF"
productCardBackgroundColor = "#FFFFFF",
multimodalCardBoxShadow = CSSValueConverter.parseBoxShadow("0 1px 4px 0 #00000026"),
inputBoxShadow = CSSValueConverter.parseBoxShadow("0 2px 8px 0 #00000026")
),
colors = ConciergeThemeColors(
// Give the chat surfaces real colors so the auto-sent user message bubble renders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.Role
Expand All @@ -53,6 +52,7 @@ import androidx.compose.ui.unit.dp
import com.adobe.marketing.mobile.concierge.network.MultimodalElement
import com.adobe.marketing.mobile.concierge.ui.components.image.AsyncImage
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeStyles
import com.adobe.marketing.mobile.concierge.ui.theme.conciergeBoxShadow

/** Test tag on the [ExtendedProductCard] primary CTA button so UI tests can target it unambiguously. */
internal const val CTA_BUTTON_TEST_TAG = "ExtendedProductCardCtaButton"
Expand Down Expand Up @@ -126,16 +126,7 @@ internal fun ExtendedProductCard(
modifier = modifier
.width(style.cardWidth)
.heightIn(min = style.cardMinHeight, max = style.cardMaxHeight)
.then(
if (style.shadowElevation > 0.dp) {
Modifier.shadow(
elevation = style.shadowElevation,
shape = style.cardShape,
ambientColor = style.shadowColor,
spotColor = style.shadowColor
)
} else Modifier
)
.conciergeBoxShadow(style.boxShadow, style.cardShape)
.clip(style.cardShape)
.then(
if (style.cardOutlineColor != Color.Transparent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.adobe.marketing.mobile.concierge.ui.state.UserInputState
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeStyles
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeGradient
import com.adobe.marketing.mobile.concierge.ui.theme.ConciergeTheme
import com.adobe.marketing.mobile.concierge.ui.theme.conciergeBoxShadow
import com.adobe.marketing.mobile.concierge.ui.theme.conciergeGradientBorder

/**
Expand Down Expand Up @@ -76,6 +77,7 @@ internal fun ChatInputPanel(
Surface(
modifier = modifier
.fillMaxWidth()
.conciergeBoxShadow(style.boxShadow, style.innerShape)
.then(borderModifier),
shape = style.innerShape,
color = style.backgroundColor
Expand Down
Loading
Loading