@factorialco/f0-react-native 0.35.0 → 0.36.0
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/lib/module/components/exports.js +1 -1
- package/lib/module/components/exports.js.map +1 -1
- package/lib/module/components/primitives/F0Image/F0Image.js +2 -0
- package/lib/module/components/primitives/F0Image/F0Image.js.map +1 -0
- package/lib/module/components/primitives/F0Image/F0Image.md +40 -0
- package/lib/module/components/primitives/F0Image/F0Image.types.js +2 -0
- package/lib/module/components/primitives/F0Image/F0Image.types.js.map +1 -0
- package/lib/module/components/primitives/F0Image/index.js +2 -0
- package/lib/module/components/primitives/F0Image/index.js.map +1 -0
- package/lib/typescript/components/exports.d.ts +1 -0
- package/lib/typescript/components/exports.d.ts.map +1 -1
- package/lib/typescript/components/primitives/F0Image/F0Image.d.ts +11 -0
- package/lib/typescript/components/primitives/F0Image/F0Image.d.ts.map +1 -0
- package/lib/typescript/components/primitives/F0Image/F0Image.types.d.ts +21 -0
- package/lib/typescript/components/primitives/F0Image/F0Image.types.d.ts.map +1 -0
- package/lib/typescript/components/primitives/F0Image/index.d.ts +3 -0
- package/lib/typescript/components/primitives/F0Image/index.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/components/exports.ts +1 -0
- package/src/components/primitives/F0Image/F0Image.md +40 -0
- package/src/components/primitives/F0Image/F0Image.tsx +48 -0
- package/src/components/primitives/F0Image/F0Image.types.ts +23 -0
- package/src/components/primitives/F0Image/__tests__/F0Image.spec.tsx +46 -0
- package/src/components/primitives/F0Image/index.ts +2 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./Activity/ActivityItem";export*from"./Avatars/exports";export*from"./Badge";export*from"./Button";export*from"./F0Button";export*from"./F0Badge";export*from"./Counter";export*from"./ExampleComponent";export{Icon}from"./Icon";export*from"./Navigation/PageHeader";export*from"./OneChip";export*from"./OnePreset";export*from"./Tags/exports";export*from"./experimental/Lists/DataList";export*from"./experimental/Lists/DetailsItem";export*from"./experimental/Lists/DetailsItemsList";export*from"./primitives/F0Text";export*from"./primitives/F0Icon";export*from"./primitives/PressableFeedback";
|
|
1
|
+
export*from"./Activity/ActivityItem";export*from"./Avatars/exports";export*from"./Badge";export*from"./Button";export*from"./F0Button";export*from"./F0Badge";export*from"./Counter";export*from"./ExampleComponent";export{Icon}from"./Icon";export*from"./Navigation/PageHeader";export*from"./OneChip";export*from"./OnePreset";export*from"./Tags/exports";export*from"./experimental/Lists/DataList";export*from"./experimental/Lists/DetailsItem";export*from"./experimental/Lists/DetailsItemsList";export*from"./primitives/F0Text";export*from"./primitives/F0Icon";export*from"./primitives/F0Image";export*from"./primitives/PressableFeedback";
|
|
2
2
|
//# sourceMappingURL=exports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Icon"],"sourceRoot":"../../../src","sources":["components/exports.ts"],"mappings":"AACA,WAAc,yBAAyB,CACvC,WAAc,mBAAmB,CACjC,WAAc,SAAS,CACvB,WAAc,UAAU,CACxB,WAAc,YAAY,CAC1B,WAAc,WAAW,CACzB,WAAc,WAAW,CACzB,WAAc,oBAAoB,CAClC,OAASA,IAAI,KAAwB,QAAQ,CAC7C,WAAc,yBAAyB,CACvC,WAAc,WAAW,CACzB,WAAc,aAAa,CAC3B,WAAc,gBAAgB,CAC9B,WAAc,+BAA+B,CAC7C,WAAc,kCAAkC,CAChD,WAAc,uCAAuC,CAGrD,WAAc,qBAAqB,CACnC,WAAc,qBAAqB,CACnC,WAAc,gCAAgC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Icon"],"sourceRoot":"../../../src","sources":["components/exports.ts"],"mappings":"AACA,WAAc,yBAAyB,CACvC,WAAc,mBAAmB,CACjC,WAAc,SAAS,CACvB,WAAc,UAAU,CACxB,WAAc,YAAY,CAC1B,WAAc,WAAW,CACzB,WAAc,WAAW,CACzB,WAAc,oBAAoB,CAClC,OAASA,IAAI,KAAwB,QAAQ,CAC7C,WAAc,yBAAyB,CACvC,WAAc,WAAW,CACzB,WAAc,aAAa,CAC3B,WAAc,gBAAgB,CAC9B,WAAc,+BAA+B,CAC7C,WAAc,kCAAkC,CAChD,WAAc,uCAAuC,CAGrD,WAAc,qBAAqB,CACnC,WAAc,qBAAqB,CACnC,WAAc,sBAAsB,CACpC,WAAc,gCAAgC","ignoreList":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["source","className","style","contentFit","transition","cachePolicy"];import{Image as ExpoImage}from"expo-image";import React from"react";import{withUniwind}from"uniwind";import{cn}from"../../../lib/utils";import{jsx as _jsx}from"react/jsx-runtime";var UniwindExpoImage=withUniwind(ExpoImage);var F0Image=React.memo(React.forwardRef(function(_ref,ref){var source=_ref.source,className=_ref.className,style=_ref.style,_ref$contentFit=_ref.contentFit,contentFit=_ref$contentFit===void 0?"cover":_ref$contentFit,_ref$transition=_ref.transition,transition=_ref$transition===void 0?150:_ref$transition,_ref$cachePolicy=_ref.cachePolicy,cachePolicy=_ref$cachePolicy===void 0?"memory-disk":_ref$cachePolicy,rest=_objectWithoutProperties(_ref,_excluded);return _jsx(UniwindExpoImage,Object.assign({ref:ref,source:source,className:cn("h-full w-full",className),style:style,contentFit:contentFit,transition:transition,cachePolicy:cachePolicy},rest));}));F0Image.displayName="F0Image";export{F0Image};
|
|
2
|
+
//# sourceMappingURL=F0Image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Image","ExpoImage","React","withUniwind","cn","jsx","_jsx","UniwindExpoImage","F0Image","memo","forwardRef","_ref","ref","source","className","style","_ref$contentFit","contentFit","_ref$transition","transition","_ref$cachePolicy","cachePolicy","rest","_objectWithoutProperties","_excluded","Object","assign","displayName"],"sourceRoot":"../../../../../src","sources":["components/primitives/F0Image/F0Image.tsx"],"mappings":"0KAAA,OAASA,KAAK,GAAI,CAAAC,SAAS,KAAQ,YAAY,CAC/C,MAAO,CAAAC,KAAK,KAAM,OAAO,CACzB,OAASC,WAAW,KAAQ,SAAS,CAErC,OAASC,EAAE,KAAQ,oBAAoB,QAAAC,GAAA,IAAAC,IAAA,yBAIvC,GAAM,CAAAC,gBAAgB,CAAGJ,WAAW,CAACF,SAAS,CAAC,CAO/C,GAAM,CAAAO,OAAO,CAAGN,KAAK,CAACO,IAAI,CACxBP,KAAK,CAACQ,UAAU,CACd,SAAAC,IAAA,CAUEC,GAAG,CACA,IATD,CAAAC,MAAM,CAAAF,IAAA,CAANE,MAAM,CACNC,SAAS,CAAAH,IAAA,CAATG,SAAS,CACTC,KAAK,CAAAJ,IAAA,CAALI,KAAK,CAAAC,eAAA,CAAAL,IAAA,CACLM,UAAU,CAAVA,UAAU,CAAAD,eAAA,UAAG,OAAO,CAAAA,eAAA,CAAAE,eAAA,CAAAP,IAAA,CACpBQ,UAAU,CAAVA,UAAU,CAAAD,eAAA,UAAG,GAAG,CAAAA,eAAA,CAAAE,gBAAA,CAAAT,IAAA,CAChBU,WAAW,CAAXA,WAAW,CAAAD,gBAAA,UAAG,aAAa,CAAAA,gBAAA,CACxBE,IAAI,CAAAC,wBAAA,CAAAZ,IAAA,CAAAa,SAAA,EAIT,MACE,CAAAlB,IAAA,CAACC,gBAAgB,CAAAkB,MAAA,CAAAC,MAAA,EACfd,GAAG,CAAEA,GAAI,CACTC,MAAM,CAAEA,MAAO,CACfC,SAAS,CAAEV,EAAE,CAAC,eAAe,CAAEU,SAAS,CAAE,CAC1CC,KAAK,CAAEA,KAAM,CACbE,UAAU,CAAEA,UAAW,CACvBE,UAAU,CAAEA,UAAW,CACvBE,WAAW,CAAEA,WAAY,EACrBC,IAAI,CACT,CAAC,CAEN,CACF,CACF,CAAC,CAEDd,OAAO,CAACmB,WAAW,CAAG,SAAS,CAE/B,OAASnB,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# F0Image
|
|
2
|
+
|
|
3
|
+
Image primitive for React Native in F0.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`F0Image` is a thin wrapper around `expo-image` with className support and consistent defaults for `contentFit`, `transition`, and `cachePolicy`.
|
|
8
|
+
|
|
9
|
+
`expo-image` is a runtime peer dependency of `@factorialco/f0-react-native`. Ensure your app installs a compatible `expo-image` version.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
<!-- prettier-ignore -->
|
|
14
|
+
```tsx
|
|
15
|
+
import { F0Image } from "@factorialco/f0-react-native"
|
|
16
|
+
|
|
17
|
+
<F0Image
|
|
18
|
+
source={{ uri: "https://example.com/avatar.png" }}
|
|
19
|
+
className="h-8 w-8 rounded-full"
|
|
20
|
+
accessibilityLabel="Profile picture"
|
|
21
|
+
/>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Props
|
|
25
|
+
|
|
26
|
+
| Prop | Type | Default | Description |
|
|
27
|
+
| ------------- | ------------------- | ----------------- | ------------------------------ |
|
|
28
|
+
| `source` | `ImageSource` | required | Image source |
|
|
29
|
+
| `className` | `string` | `"h-full w-full"` | Utility classes for layout |
|
|
30
|
+
| `contentFit` | `ImageContentFit` | `"cover"` | Content fit mode |
|
|
31
|
+
| `transition` | `number \| boolean` | `150` | Transition duration / behavior |
|
|
32
|
+
| `cachePolicy` | `ImageCachePolicy` | `"memory-disk"` | Caching policy |
|
|
33
|
+
|
|
34
|
+
All other supported `expo-image` props are forwarded.
|
|
35
|
+
|
|
36
|
+
## Testing
|
|
37
|
+
|
|
38
|
+
Main tests:
|
|
39
|
+
|
|
40
|
+
- `src/components/primitives/F0Image/__tests__/F0Image.spec.tsx`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["components/primitives/F0Image/F0Image.types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["F0Image"],"sourceRoot":"../../../../../src","sources":["components/primitives/F0Image/index.ts"],"mappings":"AAAA,OAASA,OAAO,KAAQ,WAAW","ignoreList":[]}
|
|
@@ -16,5 +16,6 @@ export * from "./experimental/Lists/DetailsItem";
|
|
|
16
16
|
export * from "./experimental/Lists/DetailsItemsList";
|
|
17
17
|
export * from "./primitives/F0Text";
|
|
18
18
|
export * from "./primitives/F0Icon";
|
|
19
|
+
export * from "./primitives/F0Image";
|
|
19
20
|
export * from "./primitives/PressableFeedback";
|
|
20
21
|
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/components/exports.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC7C,cAAc,yBAAyB,CAAA;AACvC,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,+BAA+B,CAAA;AAC7C,cAAc,kCAAkC,CAAA;AAChD,cAAc,uCAAuC,CAAA;AAGrD,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA"}
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/components/exports.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC7C,cAAc,yBAAyB,CAAA;AACvC,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,+BAA+B,CAAA;AAC7C,cAAc,kCAAkC,CAAA;AAChD,cAAc,uCAAuC,CAAA;AAGrD,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gCAAgC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Image as ExpoImage } from "expo-image";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { F0ImageProps } from "./F0Image.types";
|
|
4
|
+
/**
|
|
5
|
+
* F0Image - Image primitive for React Native in F0.
|
|
6
|
+
*
|
|
7
|
+
* Wraps `expo-image` to provide className support and sane defaults.
|
|
8
|
+
*/
|
|
9
|
+
declare const F0Image: React.MemoExoticComponent<React.ForwardRefExoticComponent<F0ImageProps & React.RefAttributes<ExpoImage>>>;
|
|
10
|
+
export { F0Image };
|
|
11
|
+
//# sourceMappingURL=F0Image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"F0Image.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/F0Image/F0Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAInD;;;;GAIG;AACH,QAAA,MAAM,OAAO,2GA4BZ,CAAA;AAID,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ImageProps as ExpoImageProps } from "expo-image";
|
|
2
|
+
/**
|
|
3
|
+
* Public F0Image props.
|
|
4
|
+
*
|
|
5
|
+
* Thin primitive wrapper around `expo-image` with className support.
|
|
6
|
+
*/
|
|
7
|
+
export interface F0ImageProps extends Omit<ExpoImageProps, "source" | "style"> {
|
|
8
|
+
/**
|
|
9
|
+
* Image source passed to expo-image.
|
|
10
|
+
*/
|
|
11
|
+
source: ExpoImageProps["source"];
|
|
12
|
+
/**
|
|
13
|
+
* Utility classes for sizing/layout.
|
|
14
|
+
*/
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Inline style escape hatch.
|
|
18
|
+
*/
|
|
19
|
+
style?: ExpoImageProps["style"];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=F0Image.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"F0Image.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/F0Image/F0Image.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,YAAY,CAAA;AAE9D;;;;GAIG;AACH,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC5E;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;IAEhC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/F0Image/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@factorialco/f0-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native components for F0 Design System",
|
|
6
6
|
"main": "expo-router/entry",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"license": "MIT",
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"date-fns": "^3.6.0",
|
|
78
|
+
"expo-image": "~3.0.11",
|
|
78
79
|
"react": "*",
|
|
79
80
|
"react-native": "*",
|
|
80
81
|
"react-native-reanimated": "^3.19.4",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# F0Image
|
|
2
|
+
|
|
3
|
+
Image primitive for React Native in F0.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`F0Image` is a thin wrapper around `expo-image` with className support and consistent defaults for `contentFit`, `transition`, and `cachePolicy`.
|
|
8
|
+
|
|
9
|
+
`expo-image` is a runtime peer dependency of `@factorialco/f0-react-native`. Ensure your app installs a compatible `expo-image` version.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
<!-- prettier-ignore -->
|
|
14
|
+
```tsx
|
|
15
|
+
import { F0Image } from "@factorialco/f0-react-native"
|
|
16
|
+
|
|
17
|
+
<F0Image
|
|
18
|
+
source={{ uri: "https://example.com/avatar.png" }}
|
|
19
|
+
className="h-8 w-8 rounded-full"
|
|
20
|
+
accessibilityLabel="Profile picture"
|
|
21
|
+
/>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Props
|
|
25
|
+
|
|
26
|
+
| Prop | Type | Default | Description |
|
|
27
|
+
| ------------- | ------------------- | ----------------- | ------------------------------ |
|
|
28
|
+
| `source` | `ImageSource` | required | Image source |
|
|
29
|
+
| `className` | `string` | `"h-full w-full"` | Utility classes for layout |
|
|
30
|
+
| `contentFit` | `ImageContentFit` | `"cover"` | Content fit mode |
|
|
31
|
+
| `transition` | `number \| boolean` | `150` | Transition duration / behavior |
|
|
32
|
+
| `cachePolicy` | `ImageCachePolicy` | `"memory-disk"` | Caching policy |
|
|
33
|
+
|
|
34
|
+
All other supported `expo-image` props are forwarded.
|
|
35
|
+
|
|
36
|
+
## Testing
|
|
37
|
+
|
|
38
|
+
Main tests:
|
|
39
|
+
|
|
40
|
+
- `src/components/primitives/F0Image/__tests__/F0Image.spec.tsx`
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Image as ExpoImage } from "expo-image"
|
|
2
|
+
import React from "react"
|
|
3
|
+
import { withUniwind } from "uniwind"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../../lib/utils"
|
|
6
|
+
|
|
7
|
+
import type { F0ImageProps } from "./F0Image.types"
|
|
8
|
+
|
|
9
|
+
const UniwindExpoImage = withUniwind(ExpoImage)
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* F0Image - Image primitive for React Native in F0.
|
|
13
|
+
*
|
|
14
|
+
* Wraps `expo-image` to provide className support and sane defaults.
|
|
15
|
+
*/
|
|
16
|
+
const F0Image = React.memo(
|
|
17
|
+
React.forwardRef<React.ElementRef<typeof ExpoImage>, F0ImageProps>(
|
|
18
|
+
(
|
|
19
|
+
{
|
|
20
|
+
source,
|
|
21
|
+
className,
|
|
22
|
+
style,
|
|
23
|
+
contentFit = "cover",
|
|
24
|
+
transition = 150,
|
|
25
|
+
cachePolicy = "memory-disk",
|
|
26
|
+
...rest
|
|
27
|
+
},
|
|
28
|
+
ref
|
|
29
|
+
) => {
|
|
30
|
+
return (
|
|
31
|
+
<UniwindExpoImage
|
|
32
|
+
ref={ref}
|
|
33
|
+
source={source}
|
|
34
|
+
className={cn("h-full w-full", className)}
|
|
35
|
+
style={style}
|
|
36
|
+
contentFit={contentFit}
|
|
37
|
+
transition={transition}
|
|
38
|
+
cachePolicy={cachePolicy}
|
|
39
|
+
{...rest}
|
|
40
|
+
/>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
F0Image.displayName = "F0Image"
|
|
47
|
+
|
|
48
|
+
export { F0Image }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ImageProps as ExpoImageProps } from "expo-image"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Public F0Image props.
|
|
5
|
+
*
|
|
6
|
+
* Thin primitive wrapper around `expo-image` with className support.
|
|
7
|
+
*/
|
|
8
|
+
export interface F0ImageProps extends Omit<ExpoImageProps, "source" | "style"> {
|
|
9
|
+
/**
|
|
10
|
+
* Image source passed to expo-image.
|
|
11
|
+
*/
|
|
12
|
+
source: ExpoImageProps["source"]
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Utility classes for sizing/layout.
|
|
16
|
+
*/
|
|
17
|
+
className?: string
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Inline style escape hatch.
|
|
21
|
+
*/
|
|
22
|
+
style?: ExpoImageProps["style"]
|
|
23
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { render } from "@testing-library/react-native"
|
|
2
|
+
import React from "react"
|
|
3
|
+
|
|
4
|
+
import { F0Image } from "../"
|
|
5
|
+
|
|
6
|
+
describe("F0Image", () => {
|
|
7
|
+
it("renders with a remote source", () => {
|
|
8
|
+
const { getByTestId } = render(
|
|
9
|
+
<F0Image
|
|
10
|
+
source={{ uri: "https://example.com/avatar.png" }}
|
|
11
|
+
testID="f0-image"
|
|
12
|
+
/>
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
expect(getByTestId("f0-image")).toBeTruthy()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it("applies sane defaults", () => {
|
|
19
|
+
const { getByTestId } = render(
|
|
20
|
+
<F0Image
|
|
21
|
+
source={{ uri: "https://example.com/defaults.png" }}
|
|
22
|
+
testID="f0-image-defaults"
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
const image = getByTestId("f0-image-defaults")
|
|
26
|
+
|
|
27
|
+
expect(image.props.contentFit).toBe("cover")
|
|
28
|
+
expect(image.props.transition).toBe(150)
|
|
29
|
+
expect(image.props.cachePolicy).toBe("memory-disk")
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it("accepts className overrides", () => {
|
|
33
|
+
const { getByTestId } = render(
|
|
34
|
+
<F0Image
|
|
35
|
+
source={{ uri: "https://example.com/classname.png" }}
|
|
36
|
+
className="h-8 w-8 rounded-full"
|
|
37
|
+
testID="f0-image-classname"
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
const image = getByTestId("f0-image-classname")
|
|
41
|
+
|
|
42
|
+
expect(image.props.className).toContain("h-8")
|
|
43
|
+
expect(image.props.className).toContain("w-8")
|
|
44
|
+
expect(image.props.className).toContain("rounded-full")
|
|
45
|
+
})
|
|
46
|
+
})
|