jfs-components 0.0.86 → 0.0.99
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 +8 -0
- package/lib/commonjs/assets.d.js +1 -0
- package/lib/commonjs/components/Drawer/Drawer.js +146 -82
- package/lib/commonjs/components/FullscreenModal/FullscreenModal.js +118 -51
- package/lib/commonjs/components/Icon/Icon.js +112 -0
- package/lib/commonjs/components/Spinner/Spinner.js +5 -1
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/commonjs/skeleton/Skeleton.js +10 -2
- package/lib/module/assets.d.js +1 -0
- package/lib/module/components/Drawer/Drawer.js +148 -84
- package/lib/module/components/FullscreenModal/FullscreenModal.js +120 -53
- package/lib/module/components/Icon/Icon.js +106 -0
- package/lib/module/components/Spinner/Spinner.js +6 -2
- package/lib/module/components/index.js +1 -0
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/module/icons/registry.js +1 -1
- package/lib/module/skeleton/Skeleton.js +11 -3
- package/lib/typescript/src/components/Drawer/Drawer.d.ts +23 -4
- package/lib/typescript/src/components/FullscreenModal/FullscreenModal.d.ts +35 -21
- package/lib/typescript/src/components/Icon/Icon.d.ts +75 -0
- package/lib/typescript/src/components/index.d.ts +2 -1
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/assets.d.ts +24 -0
- package/src/components/Drawer/Drawer.tsx +94 -15
- package/src/components/FullscreenModal/FullscreenModal.tsx +146 -63
- package/src/components/Icon/Icon.tsx +167 -0
- package/src/components/Spinner/Spinner.tsx +2 -2
- package/src/components/index.ts +2 -1
- package/src/design-tokens/Coin Variables-variables-full.json +1 -1
- package/src/icons/registry.ts +1 -1
- package/src/skeleton/Skeleton.tsx +10 -3
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
|
+
import { useTokens } from '../../design-tokens/JFSThemeProvider';
|
|
7
|
+
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils';
|
|
8
|
+
import BaseIcon from '../../icons/Icon';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
function resolveIconTokens(modes) {
|
|
11
|
+
const iconColor = getVariableByName('icon/color', modes) || '#ad8444';
|
|
12
|
+
const iconSize = getVariableByName('icon/size', modes) || 18;
|
|
13
|
+
const paddingLeft = getVariableByName('icon/padding/left', modes) || 0;
|
|
14
|
+
const paddingTop = getVariableByName('icon/padding/top', modes) || 0;
|
|
15
|
+
const paddingRight = getVariableByName('icon/padding/right', modes) || 0;
|
|
16
|
+
const paddingBottom = getVariableByName('icon/padding/bottom', modes) || 0;
|
|
17
|
+
return {
|
|
18
|
+
containerStyle: {
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
overflow: 'hidden',
|
|
23
|
+
paddingLeft,
|
|
24
|
+
paddingTop,
|
|
25
|
+
paddingRight,
|
|
26
|
+
paddingBottom
|
|
27
|
+
},
|
|
28
|
+
iconColor,
|
|
29
|
+
iconSize
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Icon component — a design-token-driven wrapper around a single glyph.
|
|
35
|
+
*
|
|
36
|
+
* It mirrors the Figma "Icon" component: a padded, centered container whose
|
|
37
|
+
* color and size are resolved from the `icon/*` design tokens via `modes`.
|
|
38
|
+
* The glyph itself can be supplied three ways, in order of precedence:
|
|
39
|
+
*
|
|
40
|
+
* 1. `children` — a real slot for any node (custom SVG component, nested
|
|
41
|
+
* `Icon`, etc.). `modes` cascade into the slot automatically.
|
|
42
|
+
* 2. `iconName` — a registry icon in the `ic_something` format.
|
|
43
|
+
* 3. `source` — a {@link UnifiedSource} fallback (remote URI, inline SVG XML,
|
|
44
|
+
* `require()` asset, SVG component, or React element), tinted with the
|
|
45
|
+
* mode-resolved icon color.
|
|
46
|
+
*
|
|
47
|
+
* `color` and `size` props let consumers override the token values per
|
|
48
|
+
* instance without touching `modes`.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* // Built-in registry icon (default path).
|
|
53
|
+
* <Icon iconName="ic_card" modes={{ 'Color Mode': 'Light' }} />
|
|
54
|
+
*
|
|
55
|
+
* // Per-instance overrides.
|
|
56
|
+
* <Icon iconName="ic_ccv" color="#5c00b5" size={24} />
|
|
57
|
+
*
|
|
58
|
+
* // Fallback to an external source when the name isn't in the registry.
|
|
59
|
+
* <Icon source="https://cdn.example.com/glyph.svg" />
|
|
60
|
+
*
|
|
61
|
+
* // Slot: render any node as the icon.
|
|
62
|
+
* <Icon><BrandLogo /></Icon>
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
function Icon({
|
|
66
|
+
iconName,
|
|
67
|
+
source,
|
|
68
|
+
children,
|
|
69
|
+
color,
|
|
70
|
+
size,
|
|
71
|
+
modes: propModes = EMPTY_MODES,
|
|
72
|
+
style: styleProp,
|
|
73
|
+
...rest
|
|
74
|
+
}) {
|
|
75
|
+
const {
|
|
76
|
+
modes: globalModes
|
|
77
|
+
} = useTokens();
|
|
78
|
+
const modes = useMemo(() => globalModes === EMPTY_MODES && propModes === EMPTY_MODES ? EMPTY_MODES : {
|
|
79
|
+
...globalModes,
|
|
80
|
+
...propModes
|
|
81
|
+
}, [globalModes, propModes]);
|
|
82
|
+
const tokens = useMemo(() => resolveIconTokens(modes), [modes]);
|
|
83
|
+
const composedStyle = useMemo(() => styleProp ? [tokens.containerStyle, styleProp] : tokens.containerStyle, [tokens.containerStyle, styleProp]);
|
|
84
|
+
const hasSlot = React.Children.count(children) > 0;
|
|
85
|
+
|
|
86
|
+
// Only fall back to the default glyph when nothing at all is provided so an
|
|
87
|
+
// explicit `source` (without an `iconName`) isn't shadowed by `ic_card`.
|
|
88
|
+
const resolvedName = iconName ?? (source === undefined ? 'ic_card' : undefined);
|
|
89
|
+
const iconColor = color ?? tokens.iconColor;
|
|
90
|
+
const iconSize = size ?? tokens.iconSize;
|
|
91
|
+
return /*#__PURE__*/_jsx(View, {
|
|
92
|
+
style: composedStyle,
|
|
93
|
+
...rest,
|
|
94
|
+
children: hasSlot ? cloneChildrenWithModes(children, modes) : /*#__PURE__*/_jsx(BaseIcon, {
|
|
95
|
+
name: resolvedName,
|
|
96
|
+
...(source !== undefined ? {
|
|
97
|
+
source
|
|
98
|
+
} : {}),
|
|
99
|
+
size: iconSize,
|
|
100
|
+
color: iconColor,
|
|
101
|
+
accessibilityElementsHidden: true,
|
|
102
|
+
importantForAccessibility: "no"
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export default /*#__PURE__*/React.memo(Icon);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useEffect } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { View } from 'react-native';
|
|
5
5
|
import Animated, { Easing, cancelAnimation, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
|
|
6
6
|
import Svg, { Path } from 'react-native-svg';
|
|
7
7
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
@@ -115,7 +115,11 @@ const useSegmentRotation = (clock, index, gravity, spreadMinRad, spreadMaxRad, s
|
|
|
115
115
|
};
|
|
116
116
|
}, [gravity, index, spreadMinRad, spreadMaxRad, spreadOutFrac]);
|
|
117
117
|
const fullSize = {
|
|
118
|
-
|
|
118
|
+
position: 'absolute',
|
|
119
|
+
top: 0,
|
|
120
|
+
left: 0,
|
|
121
|
+
right: 0,
|
|
122
|
+
bottom: 0
|
|
119
123
|
};
|
|
120
124
|
function Spinner({
|
|
121
125
|
size = DEFAULT_SIZE,
|
|
@@ -44,6 +44,7 @@ export { default as MonthlyStatusGrid, CalendarGlyph } from './MonthlyStatusGrid
|
|
|
44
44
|
export { default as Gauge } from './Gauge/Gauge';
|
|
45
45
|
export { default as HoldingsCard } from './HoldingsCard/HoldingsCard';
|
|
46
46
|
export { default as HStack } from './HStack/HStack';
|
|
47
|
+
export { default as Icon } from './Icon/Icon';
|
|
47
48
|
export { default as IconButton } from './IconButton/IconButton';
|
|
48
49
|
export { default as IconCapsule } from './IconCapsule/IconCapsule';
|
|
49
50
|
export { default as Image } from './Image/Image';
|