jfs-components 0.0.69 → 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 +20 -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 +28 -31
- 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 +29 -32
- 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 +17 -13
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +3 -2
- package/src/components/MediaCard/GlassFill.tsx +89 -0
- package/src/components/MediaCard/GlassFill.web.tsx +53 -0
- package/src/components/MediaCard/MediaCard.tsx +29 -48
- package/src/icons/registry.ts +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { View, StyleSheet, Platform } from 'react-native';
|
|
5
|
+
import { BlurView } from '@react-native-community/blur';
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
const DEFAULT_FALLBACK_DARK = '#1414174a';
|
|
8
|
+
const DEFAULT_FALLBACK_LIGHT = '#ffffff66';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Glass / frosted surface for native (iOS + Android).
|
|
12
|
+
*
|
|
13
|
+
* Why this lives in its own platform-split file:
|
|
14
|
+
* - `@react-native-community/blur` is a native-only module. Importing it on
|
|
15
|
+
* web throws because the JS shim references native components that aren't
|
|
16
|
+
* registered there. By using Metro's platform-extension resolution
|
|
17
|
+
* (`GlassFill.tsx` for native, `GlassFill.web.tsx` for web), we keep the
|
|
18
|
+
* web bundle free of any native-only imports.
|
|
19
|
+
* - Centralizes the `intensity` (0–100) -> `blurAmount` (0–32) mapping so
|
|
20
|
+
* callers can keep the Figma token semantics they already know.
|
|
21
|
+
*
|
|
22
|
+
* On iOS this is a real `UIVisualEffectView` (true OS-level live blur).
|
|
23
|
+
* On Android this uses the community blur view (RealtimeBlurView). On devices
|
|
24
|
+
* where realtime blur is unavailable, `reducedTransparencyFallbackColor` (and
|
|
25
|
+
* the explicit `overlayColor`) ensure the surface still renders as a
|
|
26
|
+
* translucent tinted scrim instead of disappearing.
|
|
27
|
+
*/
|
|
28
|
+
function GlassFill({
|
|
29
|
+
tint = 'dark',
|
|
30
|
+
intensity = 50,
|
|
31
|
+
overlayColor,
|
|
32
|
+
style
|
|
33
|
+
}) {
|
|
34
|
+
const blurType = tint === 'light' ? 'light' : 'dark';
|
|
35
|
+
const blurAmount = Math.max(0, Math.min(32, Math.round(intensity * 0.32)));
|
|
36
|
+
const fallbackColor = overlayColor ?? (tint === 'light' ? DEFAULT_FALLBACK_LIGHT : DEFAULT_FALLBACK_DARK);
|
|
37
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
38
|
+
style: [StyleSheet.absoluteFill, style],
|
|
39
|
+
pointerEvents: "none",
|
|
40
|
+
children: [/*#__PURE__*/_jsx(BlurView, {
|
|
41
|
+
style: StyleSheet.absoluteFill,
|
|
42
|
+
blurType: blurType,
|
|
43
|
+
blurAmount: blurAmount,
|
|
44
|
+
reducedTransparencyFallbackColor: fallbackColor
|
|
45
|
+
}), overlayColor != null ? /*#__PURE__*/_jsx(View, {
|
|
46
|
+
style: [StyleSheet.absoluteFill, {
|
|
47
|
+
backgroundColor: overlayColor
|
|
48
|
+
}]
|
|
49
|
+
}) : null, Platform.OS === 'android' ? /*#__PURE__*/_jsx(View, {
|
|
50
|
+
style: [StyleSheet.absoluteFill, {
|
|
51
|
+
backgroundColor: 'rgba(255,255,255,0.03)',
|
|
52
|
+
opacity: 0.6
|
|
53
|
+
}]
|
|
54
|
+
}) : null]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export default GlassFill;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { View, StyleSheet } from 'react-native';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const DEFAULT_FALLBACK_DARK = '#1414174a';
|
|
7
|
+
const DEFAULT_FALLBACK_LIGHT = '#ffffff66';
|
|
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
|
+
function GlassFill({
|
|
19
|
+
tint = 'dark',
|
|
20
|
+
intensity = 50,
|
|
21
|
+
overlayColor,
|
|
22
|
+
style
|
|
23
|
+
}) {
|
|
24
|
+
// Approximate mapping: intensity 0-100 -> ~0-30px CSS blur. Keeps parity
|
|
25
|
+
// with the native blur strength so the component looks roughly the same
|
|
26
|
+
// across platforms.
|
|
27
|
+
const blurPx = Math.max(0, Math.min(30, Math.round(intensity * 0.3)));
|
|
28
|
+
const tintColor = overlayColor ?? (tint === 'light' ? DEFAULT_FALLBACK_LIGHT : DEFAULT_FALLBACK_DARK);
|
|
29
|
+
return /*#__PURE__*/_jsx(View, {
|
|
30
|
+
style: [StyleSheet.absoluteFill, {
|
|
31
|
+
backgroundColor: tintColor
|
|
32
|
+
},
|
|
33
|
+
// backdrop-filter is a web-only CSS property; ignored by RN
|
|
34
|
+
// on native (we never bundle this file there anyway).
|
|
35
|
+
// @ts-ignore web-only style
|
|
36
|
+
{
|
|
37
|
+
backdropFilter: `blur(${blurPx}px)`,
|
|
38
|
+
WebkitBackdropFilter: `blur(${blurPx}px)`
|
|
39
|
+
}, style],
|
|
40
|
+
pointerEvents: "none"
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export default GlassFill;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { createContext, useContext } from 'react';
|
|
4
|
-
import { View, Text, StyleSheet
|
|
5
|
-
import { BlurView } from 'expo-blur';
|
|
4
|
+
import { View, Text, StyleSheet } from 'react-native';
|
|
6
5
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
7
6
|
import Image from '../Image/Image';
|
|
7
|
+
import GlassFill from './GlassFill';
|
|
8
8
|
import { EMPTY_MODES } from '../../utils/react-utils';
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
const MediaCardContext = /*#__PURE__*/createContext({});
|
|
@@ -124,20 +124,24 @@ export function Title({
|
|
|
124
124
|
* Glass Footer — pinned to the bottom of the card, **always** on top of the
|
|
125
125
|
* Header (`zIndex: 2`).
|
|
126
126
|
*
|
|
127
|
-
* Glass implementation
|
|
128
|
-
* - **iOS
|
|
129
|
-
*
|
|
130
|
-
* `
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* - **Web:** `BlurView` on web is implemented as `backdrop-filter: blur()`,
|
|
138
|
-
* which already worked in the previous version. Same component, same API.
|
|
127
|
+
* Glass implementation:
|
|
128
|
+
* - **iOS / Android:** `<GlassFill>` (this folder) wraps
|
|
129
|
+
* `@react-native-community/blur`'s `BlurView`. iOS gets a real
|
|
130
|
+
* `UIVisualEffectView` (live OS blur); Android gets the community
|
|
131
|
+
* `RealtimeBlurView` with a token-driven tinted scrim fallback for
|
|
132
|
+
* devices where realtime blur is unavailable.
|
|
133
|
+
* - **Web:** the platform-extension file `GlassFill.web.tsx` renders a
|
|
134
|
+
* translucent View with `backdrop-filter: blur()` — Metro picks the
|
|
135
|
+
* correct file automatically, so the web bundle never imports the
|
|
136
|
+
* native-only blur module.
|
|
139
137
|
*
|
|
140
|
-
*
|
|
138
|
+
* Why we don't use `expo-blur`: it requires Expo Modules autolinking on the
|
|
139
|
+
* consumer side (`use_expo_modules!` / `ExpoModulesPackage`), which silently
|
|
140
|
+
* breaks bare React Native apps that just install this library and run
|
|
141
|
+
* `pod install`. `@react-native-community/blur` is a regular RN native
|
|
142
|
+
* module — autolinking handles it with no additional setup.
|
|
143
|
+
*
|
|
144
|
+
* Tokens still drive the tint color, blur intensity and inner spacing.
|
|
141
145
|
*/
|
|
142
146
|
export function Footer({
|
|
143
147
|
children,
|
|
@@ -151,10 +155,14 @@ export function Footer({
|
|
|
151
155
|
const paddingVertical = parseFloat(getVariableByName('cardMedia/footer/padding/vertical', modes) || '12');
|
|
152
156
|
|
|
153
157
|
// Figma tokens:
|
|
154
|
-
// blur/minimal/background -> tint laid over the
|
|
155
|
-
//
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
+
// blur/minimal/background -> tint laid over the live blur, also used
|
|
159
|
+
// as the iOS reduced-transparency fallback.
|
|
160
|
+
// blur/minimal -> blur radius (px). The community BlurView
|
|
161
|
+
// uses `blurAmount` (~0-32). `GlassFill`
|
|
162
|
+
// accepts a 0-100 "intensity" (kept compat
|
|
163
|
+
// with the previous expo-blur scale) and
|
|
164
|
+
// maps it internally — here we convert the
|
|
165
|
+
// token's radius to that intensity scale.
|
|
158
166
|
const glassBgColor = getVariableByName('blur/minimal/background', modes) || '#1414174a';
|
|
159
167
|
const blurRadius = parseFloat(getVariableByName('blur/minimal', modes) || '29');
|
|
160
168
|
const intensity = Math.max(0, Math.min(100, Math.round(blurRadius * 1.7)));
|
|
@@ -175,22 +183,11 @@ export function Footer({
|
|
|
175
183
|
zIndex: 2
|
|
176
184
|
}, style],
|
|
177
185
|
pointerEvents: "box-none",
|
|
178
|
-
children: [/*#__PURE__*/_jsx(
|
|
179
|
-
style: StyleSheet.absoluteFill,
|
|
186
|
+
children: [/*#__PURE__*/_jsx(GlassFill, {
|
|
180
187
|
tint: tint,
|
|
181
188
|
intensity: intensity,
|
|
182
|
-
|
|
189
|
+
overlayColor: glassBgColor
|
|
183
190
|
}), /*#__PURE__*/_jsx(View, {
|
|
184
|
-
style: [StyleSheet.absoluteFill, {
|
|
185
|
-
backgroundColor: glassBgColor
|
|
186
|
-
}]
|
|
187
|
-
}), Platform.OS === 'android' ? /*#__PURE__*/_jsx(View, {
|
|
188
|
-
style: [StyleSheet.absoluteFill, {
|
|
189
|
-
backgroundColor: 'rgba(255,255,255,0.03)',
|
|
190
|
-
opacity: 0.6
|
|
191
|
-
}],
|
|
192
|
-
pointerEvents: "none"
|
|
193
|
-
}) : null, /*#__PURE__*/_jsx(View, {
|
|
194
191
|
style: {
|
|
195
192
|
flexDirection: 'row',
|
|
196
193
|
alignItems: 'center',
|