jfs-components 0.0.68 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/lib/commonjs/components/MediaCard/GlassFill.js +62 -0
- package/lib/commonjs/components/MediaCard/GlassFill.web.js +48 -0
- package/lib/commonjs/components/MediaCard/MediaCard.js +88 -55
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/MediaCard/GlassFill.js +57 -0
- package/lib/module/components/MediaCard/GlassFill.web.js +43 -0
- package/lib/module/components/MediaCard/MediaCard.js +89 -56
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/MediaCard/GlassFill.d.ts +47 -0
- package/lib/typescript/src/components/MediaCard/GlassFill.web.d.ts +20 -0
- package/lib/typescript/src/components/MediaCard/MediaCard.d.ts +40 -10
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +3 -1
- package/src/components/MediaCard/GlassFill.tsx +89 -0
- package/src/components/MediaCard/GlassFill.web.tsx +53 -0
- package/src/components/MediaCard/MediaCard.tsx +99 -49
- package/src/icons/registry.ts +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ViewStyle, type StyleProp } from 'react-native';
|
|
2
|
+
export type GlassTint = 'dark' | 'light';
|
|
3
|
+
export interface GlassFillProps {
|
|
4
|
+
/**
|
|
5
|
+
* Visual tint of the glass surface. Maps to `BlurView`'s `blurType`
|
|
6
|
+
* (`'dark'` | `'light'`). The library also drives the appropriate
|
|
7
|
+
* `reducedTransparencyFallbackColor` from this so iOS gracefully degrades
|
|
8
|
+
* when "Reduce Transparency" is enabled in system accessibility settings.
|
|
9
|
+
*/
|
|
10
|
+
tint?: GlassTint;
|
|
11
|
+
/**
|
|
12
|
+
* Blur strength as a 0–100 "intensity" value (kept compatible with the
|
|
13
|
+
* previous `expo-blur` API so consumers don't need to relearn the scale).
|
|
14
|
+
* Internally mapped to `@react-native-community/blur`'s `blurAmount`,
|
|
15
|
+
* which is roughly 0–32 on iOS / Android.
|
|
16
|
+
*/
|
|
17
|
+
intensity?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Token-derived color tint laid OVER the live blur (Figma `blur/minimal/background`).
|
|
20
|
+
* Painted as a translucent overlay so the glass keeps the design system
|
|
21
|
+
* color signature even when the platform blur quality varies.
|
|
22
|
+
*/
|
|
23
|
+
overlayColor?: string;
|
|
24
|
+
/** Container style overrides. Defaults to `StyleSheet.absoluteFill`. */
|
|
25
|
+
style?: StyleProp<ViewStyle>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Glass / frosted surface for native (iOS + Android).
|
|
29
|
+
*
|
|
30
|
+
* Why this lives in its own platform-split file:
|
|
31
|
+
* - `@react-native-community/blur` is a native-only module. Importing it on
|
|
32
|
+
* web throws because the JS shim references native components that aren't
|
|
33
|
+
* registered there. By using Metro's platform-extension resolution
|
|
34
|
+
* (`GlassFill.tsx` for native, `GlassFill.web.tsx` for web), we keep the
|
|
35
|
+
* web bundle free of any native-only imports.
|
|
36
|
+
* - Centralizes the `intensity` (0–100) -> `blurAmount` (0–32) mapping so
|
|
37
|
+
* callers can keep the Figma token semantics they already know.
|
|
38
|
+
*
|
|
39
|
+
* On iOS this is a real `UIVisualEffectView` (true OS-level live blur).
|
|
40
|
+
* On Android this uses the community blur view (RealtimeBlurView). On devices
|
|
41
|
+
* where realtime blur is unavailable, `reducedTransparencyFallbackColor` (and
|
|
42
|
+
* the explicit `overlayColor`) ensure the surface still renders as a
|
|
43
|
+
* translucent tinted scrim instead of disappearing.
|
|
44
|
+
*/
|
|
45
|
+
declare function GlassFill({ tint, intensity, overlayColor, style, }: GlassFillProps): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export default GlassFill;
|
|
47
|
+
//# sourceMappingURL=GlassFill.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ViewStyle, type StyleProp } from 'react-native';
|
|
2
|
+
export type GlassTint = 'dark' | 'light';
|
|
3
|
+
export interface GlassFillProps {
|
|
4
|
+
tint?: GlassTint;
|
|
5
|
+
intensity?: number;
|
|
6
|
+
overlayColor?: string;
|
|
7
|
+
style?: StyleProp<ViewStyle>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Web counterpart of `GlassFill`.
|
|
11
|
+
*
|
|
12
|
+
* `@react-native-community/blur` does not ship a web implementation, so for
|
|
13
|
+
* the web bundle we render a translucent `View` with `backdrop-filter: blur()`
|
|
14
|
+
* — which is exactly how 0.0.67 and earlier shipped the glass effect on web.
|
|
15
|
+
* Native bundles pick up `GlassFill.tsx` instead via Metro's platform
|
|
16
|
+
* resolver; the web bundle picks up this file.
|
|
17
|
+
*/
|
|
18
|
+
declare function GlassFill({ tint, intensity, overlayColor, style, }: GlassFillProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export default GlassFill;
|
|
20
|
+
//# sourceMappingURL=GlassFill.web.d.ts.map
|
|
@@ -36,11 +36,20 @@ export interface MediaCardProps {
|
|
|
36
36
|
/**
|
|
37
37
|
* MediaCard component implementation from Figma node 1241:4140.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* the
|
|
43
|
-
*
|
|
39
|
+
* Layout contract (important — read this before editing):
|
|
40
|
+
* - The **background** (image or custom `media`) is the only child in
|
|
41
|
+
* normal flow. It dictates the card's height — typically via
|
|
42
|
+
* `aspectRatio` on the inner `<Image>`. There is no `minHeight`.
|
|
43
|
+
* - `Header` and `Footer` are **absolutely positioned overlays**:
|
|
44
|
+
* - `Header` pinned to top-left/right with safe padding.
|
|
45
|
+
* - `Footer` pinned to bottom-left/right with `zIndex: 2` so it sits
|
|
46
|
+
* on top of the header (and on top of the image). This guarantees
|
|
47
|
+
* the footer never moves no matter how many lines the title wraps
|
|
48
|
+
* to — the title may overflow the header bounds, but the footer's
|
|
49
|
+
* position is a function of the card box, not the title.
|
|
50
|
+
* - `pointerEvents="box-none"` is applied so taps still land on the
|
|
51
|
+
* interactive elements inside the overlays without the wrapper itself
|
|
52
|
+
* capturing them.
|
|
44
53
|
*/
|
|
45
54
|
export declare function MediaCard({ imageSource, ratio, media, children, modes, style, }: MediaCardProps): import("react/jsx-runtime").JSX.Element;
|
|
46
55
|
export declare namespace MediaCard {
|
|
@@ -51,9 +60,11 @@ export declare namespace MediaCard {
|
|
|
51
60
|
var FooterSubtitle: typeof import("./MediaCard").FooterSubtitle;
|
|
52
61
|
}
|
|
53
62
|
/**
|
|
54
|
-
* Header
|
|
55
|
-
*
|
|
56
|
-
*
|
|
63
|
+
* Header overlay — pinned to the top of the card. Title content can wrap to
|
|
64
|
+
* any number of lines without affecting the footer's position; if it grows
|
|
65
|
+
* taller than the card, the card's `overflow: 'hidden'` clips it.
|
|
66
|
+
*
|
|
67
|
+
* Default `padding: 16` matches the Figma "title wrap" spec.
|
|
57
68
|
*/
|
|
58
69
|
export declare function Header({ children, style }: {
|
|
59
70
|
children?: React.ReactNode;
|
|
@@ -69,8 +80,27 @@ export declare function Title({ children, style, modes: propModes }: {
|
|
|
69
80
|
modes?: Record<string, any>;
|
|
70
81
|
}): import("react/jsx-runtime").JSX.Element;
|
|
71
82
|
/**
|
|
72
|
-
* Glass Footer
|
|
73
|
-
*
|
|
83
|
+
* Glass Footer — pinned to the bottom of the card, **always** on top of the
|
|
84
|
+
* Header (`zIndex: 2`).
|
|
85
|
+
*
|
|
86
|
+
* Glass implementation:
|
|
87
|
+
* - **iOS / Android:** `<GlassFill>` (this folder) wraps
|
|
88
|
+
* `@react-native-community/blur`'s `BlurView`. iOS gets a real
|
|
89
|
+
* `UIVisualEffectView` (live OS blur); Android gets the community
|
|
90
|
+
* `RealtimeBlurView` with a token-driven tinted scrim fallback for
|
|
91
|
+
* devices where realtime blur is unavailable.
|
|
92
|
+
* - **Web:** the platform-extension file `GlassFill.web.tsx` renders a
|
|
93
|
+
* translucent View with `backdrop-filter: blur()` — Metro picks the
|
|
94
|
+
* correct file automatically, so the web bundle never imports the
|
|
95
|
+
* native-only blur module.
|
|
96
|
+
*
|
|
97
|
+
* Why we don't use `expo-blur`: it requires Expo Modules autolinking on the
|
|
98
|
+
* consumer side (`use_expo_modules!` / `ExpoModulesPackage`), which silently
|
|
99
|
+
* breaks bare React Native apps that just install this library and run
|
|
100
|
+
* `pod install`. `@react-native-community/blur` is a regular RN native
|
|
101
|
+
* module — autolinking handles it with no additional setup.
|
|
102
|
+
*
|
|
103
|
+
* Tokens still drive the tint color, blur intensity and inner spacing.
|
|
74
104
|
*/
|
|
75
105
|
export declare function Footer({ children, style, modes: propModes }: {
|
|
76
106
|
children?: React.ReactNode;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Auto-generated from SVG files in src/icons/
|
|
5
5
|
* DO NOT EDIT MANUALLY - Run "npm run icons:generate" to regenerate
|
|
6
6
|
*
|
|
7
|
-
* Generated: 2026-04-
|
|
7
|
+
* Generated: 2026-04-23T10:31:30.721Z
|
|
8
8
|
*/
|
|
9
9
|
export declare const iconRegistry: Record<string, {
|
|
10
10
|
path: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jfs-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.70",
|
|
4
4
|
"description": "React Native Jio Finance Components Library",
|
|
5
5
|
"author": "sunshuaiqi@gmail.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
"react-native-worklets": "0.5.1"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
|
+
"@react-native-community/blur": ">=4.4.0",
|
|
98
99
|
"react": "*",
|
|
99
100
|
"react-native": "*"
|
|
100
101
|
},
|
|
@@ -105,6 +106,7 @@
|
|
|
105
106
|
"@babel/preset-react": "^7.28.5",
|
|
106
107
|
"@babel/runtime": "^7.28.4",
|
|
107
108
|
"@babel/traverse": "^7.28.5",
|
|
109
|
+
"@react-native-community/blur": "^4.4.1",
|
|
108
110
|
"@react-native-community/cli": "20.0.2",
|
|
109
111
|
"@react-native-community/cli-platform-android": "20.0.2",
|
|
110
112
|
"@react-native-community/cli-platform-ios": "20.0.2",
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, StyleSheet, Platform, type ViewStyle, type StyleProp } from 'react-native'
|
|
3
|
+
import { BlurView } from '@react-native-community/blur'
|
|
4
|
+
|
|
5
|
+
export type GlassTint = 'dark' | 'light'
|
|
6
|
+
|
|
7
|
+
export interface GlassFillProps {
|
|
8
|
+
/**
|
|
9
|
+
* Visual tint of the glass surface. Maps to `BlurView`'s `blurType`
|
|
10
|
+
* (`'dark'` | `'light'`). The library also drives the appropriate
|
|
11
|
+
* `reducedTransparencyFallbackColor` from this so iOS gracefully degrades
|
|
12
|
+
* when "Reduce Transparency" is enabled in system accessibility settings.
|
|
13
|
+
*/
|
|
14
|
+
tint?: GlassTint
|
|
15
|
+
/**
|
|
16
|
+
* Blur strength as a 0–100 "intensity" value (kept compatible with the
|
|
17
|
+
* previous `expo-blur` API so consumers don't need to relearn the scale).
|
|
18
|
+
* Internally mapped to `@react-native-community/blur`'s `blurAmount`,
|
|
19
|
+
* which is roughly 0–32 on iOS / Android.
|
|
20
|
+
*/
|
|
21
|
+
intensity?: number
|
|
22
|
+
/**
|
|
23
|
+
* Token-derived color tint laid OVER the live blur (Figma `blur/minimal/background`).
|
|
24
|
+
* Painted as a translucent overlay so the glass keeps the design system
|
|
25
|
+
* color signature even when the platform blur quality varies.
|
|
26
|
+
*/
|
|
27
|
+
overlayColor?: string
|
|
28
|
+
/** Container style overrides. Defaults to `StyleSheet.absoluteFill`. */
|
|
29
|
+
style?: StyleProp<ViewStyle>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const DEFAULT_FALLBACK_DARK = '#1414174a'
|
|
33
|
+
const DEFAULT_FALLBACK_LIGHT = '#ffffff66'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Glass / frosted surface for native (iOS + Android).
|
|
37
|
+
*
|
|
38
|
+
* Why this lives in its own platform-split file:
|
|
39
|
+
* - `@react-native-community/blur` is a native-only module. Importing it on
|
|
40
|
+
* web throws because the JS shim references native components that aren't
|
|
41
|
+
* registered there. By using Metro's platform-extension resolution
|
|
42
|
+
* (`GlassFill.tsx` for native, `GlassFill.web.tsx` for web), we keep the
|
|
43
|
+
* web bundle free of any native-only imports.
|
|
44
|
+
* - Centralizes the `intensity` (0–100) -> `blurAmount` (0–32) mapping so
|
|
45
|
+
* callers can keep the Figma token semantics they already know.
|
|
46
|
+
*
|
|
47
|
+
* On iOS this is a real `UIVisualEffectView` (true OS-level live blur).
|
|
48
|
+
* On Android this uses the community blur view (RealtimeBlurView). On devices
|
|
49
|
+
* where realtime blur is unavailable, `reducedTransparencyFallbackColor` (and
|
|
50
|
+
* the explicit `overlayColor`) ensure the surface still renders as a
|
|
51
|
+
* translucent tinted scrim instead of disappearing.
|
|
52
|
+
*/
|
|
53
|
+
function GlassFill({
|
|
54
|
+
tint = 'dark',
|
|
55
|
+
intensity = 50,
|
|
56
|
+
overlayColor,
|
|
57
|
+
style,
|
|
58
|
+
}: GlassFillProps) {
|
|
59
|
+
const blurType: 'light' | 'dark' = tint === 'light' ? 'light' : 'dark'
|
|
60
|
+
const blurAmount = Math.max(0, Math.min(32, Math.round(intensity * 0.32)))
|
|
61
|
+
const fallbackColor = overlayColor ?? (tint === 'light' ? DEFAULT_FALLBACK_LIGHT : DEFAULT_FALLBACK_DARK)
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<View style={[StyleSheet.absoluteFill, style]} pointerEvents="none">
|
|
65
|
+
<BlurView
|
|
66
|
+
style={StyleSheet.absoluteFill}
|
|
67
|
+
blurType={blurType}
|
|
68
|
+
blurAmount={blurAmount}
|
|
69
|
+
reducedTransparencyFallbackColor={fallbackColor}
|
|
70
|
+
/>
|
|
71
|
+
{overlayColor != null ? (
|
|
72
|
+
<View style={[StyleSheet.absoluteFill, { backgroundColor: overlayColor }]} />
|
|
73
|
+
) : null}
|
|
74
|
+
{Platform.OS === 'android' ? (
|
|
75
|
+
<View
|
|
76
|
+
style={[
|
|
77
|
+
StyleSheet.absoluteFill,
|
|
78
|
+
{
|
|
79
|
+
backgroundColor: 'rgba(255,255,255,0.03)',
|
|
80
|
+
opacity: 0.6,
|
|
81
|
+
},
|
|
82
|
+
]}
|
|
83
|
+
/>
|
|
84
|
+
) : null}
|
|
85
|
+
</View>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default GlassFill
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, StyleSheet, type ViewStyle, type StyleProp } from 'react-native'
|
|
3
|
+
|
|
4
|
+
export type GlassTint = 'dark' | 'light'
|
|
5
|
+
|
|
6
|
+
export interface GlassFillProps {
|
|
7
|
+
tint?: GlassTint
|
|
8
|
+
intensity?: number
|
|
9
|
+
overlayColor?: string
|
|
10
|
+
style?: StyleProp<ViewStyle>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const DEFAULT_FALLBACK_DARK = '#1414174a'
|
|
14
|
+
const DEFAULT_FALLBACK_LIGHT = '#ffffff66'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Web counterpart of `GlassFill`.
|
|
18
|
+
*
|
|
19
|
+
* `@react-native-community/blur` does not ship a web implementation, so for
|
|
20
|
+
* the web bundle we render a translucent `View` with `backdrop-filter: blur()`
|
|
21
|
+
* — which is exactly how 0.0.67 and earlier shipped the glass effect on web.
|
|
22
|
+
* Native bundles pick up `GlassFill.tsx` instead via Metro's platform
|
|
23
|
+
* resolver; the web bundle picks up this file.
|
|
24
|
+
*/
|
|
25
|
+
function GlassFill({
|
|
26
|
+
tint = 'dark',
|
|
27
|
+
intensity = 50,
|
|
28
|
+
overlayColor,
|
|
29
|
+
style,
|
|
30
|
+
}: GlassFillProps) {
|
|
31
|
+
// Approximate mapping: intensity 0-100 -> ~0-30px CSS blur. Keeps parity
|
|
32
|
+
// with the native blur strength so the component looks roughly the same
|
|
33
|
+
// across platforms.
|
|
34
|
+
const blurPx = Math.max(0, Math.min(30, Math.round(intensity * 0.3)))
|
|
35
|
+
const tintColor = overlayColor ?? (tint === 'light' ? DEFAULT_FALLBACK_LIGHT : DEFAULT_FALLBACK_DARK)
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View
|
|
39
|
+
style={[
|
|
40
|
+
StyleSheet.absoluteFill,
|
|
41
|
+
{ backgroundColor: tintColor },
|
|
42
|
+
// backdrop-filter is a web-only CSS property; ignored by RN
|
|
43
|
+
// on native (we never bundle this file there anyway).
|
|
44
|
+
// @ts-ignore web-only style
|
|
45
|
+
{ backdropFilter: `blur(${blurPx}px)`, WebkitBackdropFilter: `blur(${blurPx}px)` },
|
|
46
|
+
style,
|
|
47
|
+
]}
|
|
48
|
+
pointerEvents="none"
|
|
49
|
+
/>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default GlassFill
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { createContext, useContext } from 'react'
|
|
2
|
-
import { View, Text, StyleSheet, type ViewStyle, type TextStyle, type StyleProp, type ImageSourcePropType
|
|
2
|
+
import { View, Text, StyleSheet, type ViewStyle, type TextStyle, type StyleProp, type ImageSourcePropType } from 'react-native'
|
|
3
3
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
4
4
|
import Image from '../Image/Image'
|
|
5
|
+
import GlassFill, { type GlassTint } from './GlassFill'
|
|
5
6
|
import { EMPTY_MODES } from '../../utils/react-utils'
|
|
6
7
|
|
|
7
8
|
const MediaCardContext = createContext<{ modes?: Record<string, any> }>({})
|
|
@@ -43,11 +44,20 @@ export interface MediaCardProps {
|
|
|
43
44
|
/**
|
|
44
45
|
* MediaCard component implementation from Figma node 1241:4140.
|
|
45
46
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* the
|
|
50
|
-
*
|
|
47
|
+
* Layout contract (important — read this before editing):
|
|
48
|
+
* - The **background** (image or custom `media`) is the only child in
|
|
49
|
+
* normal flow. It dictates the card's height — typically via
|
|
50
|
+
* `aspectRatio` on the inner `<Image>`. There is no `minHeight`.
|
|
51
|
+
* - `Header` and `Footer` are **absolutely positioned overlays**:
|
|
52
|
+
* - `Header` pinned to top-left/right with safe padding.
|
|
53
|
+
* - `Footer` pinned to bottom-left/right with `zIndex: 2` so it sits
|
|
54
|
+
* on top of the header (and on top of the image). This guarantees
|
|
55
|
+
* the footer never moves no matter how many lines the title wraps
|
|
56
|
+
* to — the title may overflow the header bounds, but the footer's
|
|
57
|
+
* position is a function of the card box, not the title.
|
|
58
|
+
* - `pointerEvents="box-none"` is applied so taps still land on the
|
|
59
|
+
* interactive elements inside the overlays without the wrapper itself
|
|
60
|
+
* capturing them.
|
|
51
61
|
*/
|
|
52
62
|
export function MediaCard({
|
|
53
63
|
imageSource,
|
|
@@ -59,20 +69,12 @@ export function MediaCard({
|
|
|
59
69
|
}: MediaCardProps) {
|
|
60
70
|
const radius = parseFloat(getVariableByName('cardMedia/radius', modes) || '24')
|
|
61
71
|
|
|
62
|
-
// No magic minHeight, no aspectRatio on the container. The card simply
|
|
63
|
-
// hugs whatever the background renders at: the <Image> sits in normal
|
|
64
|
-
// flow with `aspectRatio: ratio`, so its rendered height becomes the
|
|
65
|
-
// card's height. Header and Footer are absolutely positioned overlays
|
|
66
|
-
// and don't contribute to layout.
|
|
67
72
|
const containerStyle: ViewStyle = {
|
|
68
73
|
borderRadius: radius,
|
|
69
74
|
overflow: 'hidden',
|
|
70
75
|
position: 'relative',
|
|
71
76
|
}
|
|
72
77
|
|
|
73
|
-
// `media` wins as an escape hatch (gradient/video/etc.). Otherwise we
|
|
74
|
-
// delegate to the shared <Image> for image-source backgrounds. The
|
|
75
|
-
// background renders in normal flow so its height drives the card.
|
|
76
78
|
const background = media ?? (
|
|
77
79
|
imageSource != null ? (
|
|
78
80
|
<Image
|
|
@@ -104,25 +106,28 @@ export function MediaCard({
|
|
|
104
106
|
// ----------------------------------------------------------------------------
|
|
105
107
|
|
|
106
108
|
/**
|
|
107
|
-
* Header
|
|
108
|
-
*
|
|
109
|
-
*
|
|
109
|
+
* Header overlay — pinned to the top of the card. Title content can wrap to
|
|
110
|
+
* any number of lines without affecting the footer's position; if it grows
|
|
111
|
+
* taller than the card, the card's `overflow: 'hidden'` clips it.
|
|
112
|
+
*
|
|
113
|
+
* Default `padding: 16` matches the Figma "title wrap" spec.
|
|
110
114
|
*/
|
|
111
115
|
export function Header({ children, style }: { children?: React.ReactNode; style?: StyleProp<ViewStyle> }) {
|
|
112
|
-
// NOTE: the previous `flex: 1` shorthand expanded on Yoga (Android) to
|
|
113
|
-
// `{ flexGrow: 1, flexShrink: 1, flexBasis: 0 }`. With `flexBasis: 0` the
|
|
114
|
-
// Header has *no intrinsic floor*, so when MediaCard is placed inside a
|
|
115
|
-
// height-unbounded parent — e.g. a Carousel slot whose contentContainer
|
|
116
|
-
// is `alignItems: 'flex-start'` — Yoga's first measurement pass sizes
|
|
117
|
-
// the Header at 0 and the card's overall height becomes non-deterministic.
|
|
118
|
-
// On native this manifests as the card "over-stretching" vertically (the
|
|
119
|
-
// same Yoga foot-gun we fixed in `CardCTA` rightWrap). Web hides it
|
|
120
|
-
// because browsers honor `min-height: auto` on flex items. Use explicit
|
|
121
|
-
// `flexGrow / flexShrink: 0 / flexBasis: 'auto'` so the Header is sized
|
|
122
|
-
// to its content as a floor and only grows to consume the extra space
|
|
123
|
-
// contributed by `MediaCard`'s `minHeight: 308`.
|
|
124
116
|
return (
|
|
125
|
-
<View
|
|
117
|
+
<View
|
|
118
|
+
style={[
|
|
119
|
+
{
|
|
120
|
+
position: 'absolute',
|
|
121
|
+
top: 0,
|
|
122
|
+
left: 0,
|
|
123
|
+
right: 0,
|
|
124
|
+
padding: 16,
|
|
125
|
+
zIndex: 1,
|
|
126
|
+
},
|
|
127
|
+
style,
|
|
128
|
+
]}
|
|
129
|
+
pointerEvents="box-none"
|
|
130
|
+
>
|
|
126
131
|
{children}
|
|
127
132
|
</View>
|
|
128
133
|
)
|
|
@@ -154,8 +159,27 @@ export function Title({ children, style, modes: propModes }: { children?: React.
|
|
|
154
159
|
}
|
|
155
160
|
|
|
156
161
|
/**
|
|
157
|
-
* Glass Footer
|
|
158
|
-
*
|
|
162
|
+
* Glass Footer — pinned to the bottom of the card, **always** on top of the
|
|
163
|
+
* Header (`zIndex: 2`).
|
|
164
|
+
*
|
|
165
|
+
* Glass implementation:
|
|
166
|
+
* - **iOS / Android:** `<GlassFill>` (this folder) wraps
|
|
167
|
+
* `@react-native-community/blur`'s `BlurView`. iOS gets a real
|
|
168
|
+
* `UIVisualEffectView` (live OS blur); Android gets the community
|
|
169
|
+
* `RealtimeBlurView` with a token-driven tinted scrim fallback for
|
|
170
|
+
* devices where realtime blur is unavailable.
|
|
171
|
+
* - **Web:** the platform-extension file `GlassFill.web.tsx` renders a
|
|
172
|
+
* translucent View with `backdrop-filter: blur()` — Metro picks the
|
|
173
|
+
* correct file automatically, so the web bundle never imports the
|
|
174
|
+
* native-only blur module.
|
|
175
|
+
*
|
|
176
|
+
* Why we don't use `expo-blur`: it requires Expo Modules autolinking on the
|
|
177
|
+
* consumer side (`use_expo_modules!` / `ExpoModulesPackage`), which silently
|
|
178
|
+
* breaks bare React Native apps that just install this library and run
|
|
179
|
+
* `pod install`. `@react-native-community/blur` is a regular RN native
|
|
180
|
+
* module — autolinking handles it with no additional setup.
|
|
181
|
+
*
|
|
182
|
+
* Tokens still drive the tint color, blur intensity and inner spacing.
|
|
159
183
|
*/
|
|
160
184
|
export function Footer({ children, style, modes: propModes }: { children?: React.ReactNode; style?: StyleProp<ViewStyle>; modes?: Record<string, any> }) {
|
|
161
185
|
const context = useContext(MediaCardContext)
|
|
@@ -165,28 +189,54 @@ export function Footer({ children, style, modes: propModes }: { children?: React
|
|
|
165
189
|
const paddingHorizontal = parseFloat(getVariableByName('cardMedia/footer/padding/horizontal', modes) || '16')
|
|
166
190
|
const paddingVertical = parseFloat(getVariableByName('cardMedia/footer/padding/vertical', modes) || '12')
|
|
167
191
|
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
//
|
|
192
|
+
// Figma tokens:
|
|
193
|
+
// blur/minimal/background -> tint laid over the live blur, also used
|
|
194
|
+
// as the iOS reduced-transparency fallback.
|
|
195
|
+
// blur/minimal -> blur radius (px). The community BlurView
|
|
196
|
+
// uses `blurAmount` (~0-32). `GlassFill`
|
|
197
|
+
// accepts a 0-100 "intensity" (kept compat
|
|
198
|
+
// with the previous expo-blur scale) and
|
|
199
|
+
// maps it internally — here we convert the
|
|
200
|
+
// token's radius to that intensity scale.
|
|
172
201
|
const glassBgColor = getVariableByName('blur/minimal/background', modes) || '#1414174a'
|
|
173
202
|
const blurRadius = parseFloat(getVariableByName('blur/minimal', modes) || '29')
|
|
203
|
+
const intensity = Math.max(0, Math.min(100, Math.round(blurRadius * 1.7)))
|
|
174
204
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
paddingHorizontal,
|
|
180
|
-
paddingVertical,
|
|
181
|
-
backgroundColor: glassBgColor,
|
|
182
|
-
// Web-specific backdrop filter for glass effect
|
|
183
|
-
// @ts-ignore
|
|
184
|
-
...(Platform.OS === 'web' ? { backdropFilter: `blur(${blurRadius}px)` } : {}),
|
|
185
|
-
}
|
|
205
|
+
// Pick the iOS/Android material tint from "Contrast Context" mode so the
|
|
206
|
+
// glass adapts to dark/light backgrounds the same way the Figma tokens do.
|
|
207
|
+
const contrast = (modes['Contrast Context'] || 'on dark') as string
|
|
208
|
+
const tint: GlassTint = contrast === 'on light' ? 'light' : 'dark'
|
|
186
209
|
|
|
187
210
|
return (
|
|
188
|
-
<View
|
|
189
|
-
{
|
|
211
|
+
<View
|
|
212
|
+
style={[
|
|
213
|
+
{
|
|
214
|
+
position: 'absolute',
|
|
215
|
+
left: 0,
|
|
216
|
+
right: 0,
|
|
217
|
+
bottom: 0,
|
|
218
|
+
overflow: 'hidden',
|
|
219
|
+
// zIndex 2 ensures Footer always paints above Header,
|
|
220
|
+
// regardless of which is rendered first in the tree.
|
|
221
|
+
zIndex: 2,
|
|
222
|
+
},
|
|
223
|
+
style,
|
|
224
|
+
]}
|
|
225
|
+
pointerEvents="box-none"
|
|
226
|
+
>
|
|
227
|
+
<GlassFill tint={tint} intensity={intensity} overlayColor={glassBgColor} />
|
|
228
|
+
|
|
229
|
+
<View
|
|
230
|
+
style={{
|
|
231
|
+
flexDirection: 'row',
|
|
232
|
+
alignItems: 'center',
|
|
233
|
+
gap,
|
|
234
|
+
paddingHorizontal,
|
|
235
|
+
paddingVertical,
|
|
236
|
+
}}
|
|
237
|
+
>
|
|
238
|
+
{children}
|
|
239
|
+
</View>
|
|
190
240
|
</View>
|
|
191
241
|
)
|
|
192
242
|
}
|
package/src/icons/registry.ts
CHANGED