@tamagui/image 1.0.1-beta.57 → 1.0.1-beta.61
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/package.json +4 -3
- package/src/Image.tsx +43 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/image",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.61",
|
|
4
4
|
"sideEffects": true,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"module": "dist/esm",
|
|
9
9
|
"module:jsx": "dist/jsx",
|
|
10
10
|
"files": [
|
|
11
|
+
"src",
|
|
11
12
|
"types",
|
|
12
13
|
"dist"
|
|
13
14
|
],
|
|
@@ -18,14 +19,14 @@
|
|
|
18
19
|
"clean:build": "tamagui-build clean:build"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
22
|
+
"@tamagui/core": "^1.0.1-beta.61"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
25
|
"react": "*",
|
|
25
26
|
"react-native": "*"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
29
|
+
"@tamagui/build": "^1.0.1-beta.61",
|
|
29
30
|
"react": "*",
|
|
30
31
|
"react-native": "*"
|
|
31
32
|
},
|
package/src/Image.tsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { GetProps, StackProps, getExpandedShorthands, styled } from '@tamagui/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { Image as RNImage } from 'react-native'
|
|
4
|
+
|
|
5
|
+
React['createElement']
|
|
6
|
+
|
|
7
|
+
const StyledImage = styled(
|
|
8
|
+
RNImage,
|
|
9
|
+
{
|
|
10
|
+
name: 'Image',
|
|
11
|
+
position: 'relative',
|
|
12
|
+
source: { uri: '' },
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
inlineProps: new Set(['src', 'width', 'height']),
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
type StyledImageProps = GetProps<typeof StyledImage>
|
|
20
|
+
|
|
21
|
+
type BaseProps = Omit<StyledImageProps, 'source' | 'width' | 'height' | 'style' | 'onLayout'> & {
|
|
22
|
+
width: number
|
|
23
|
+
height: number
|
|
24
|
+
src: string | StyledImageProps['source']
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type ImageProps = BaseProps & Omit<StackProps, keyof BaseProps>
|
|
28
|
+
|
|
29
|
+
export const Image: React.FC<ImageProps> = StyledImage.extractable((inProps) => {
|
|
30
|
+
const props = getExpandedShorthands(inProps)
|
|
31
|
+
const { src, width = 100, height = 100, ...rest } = props
|
|
32
|
+
const source = typeof src === 'string' ? { uri: src, width, height } : src
|
|
33
|
+
const defaultSource = Array.isArray(source) ? source[0] : source
|
|
34
|
+
|
|
35
|
+
if (!defaultSource) {
|
|
36
|
+
// placeholder with customizability
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// must set defaultSource to allow SSR, default it to the same as src
|
|
41
|
+
// @ts-ignore we pass all react-native-web props down
|
|
42
|
+
return <StyledImage defaultSource={defaultSource} source={source} {...rest} />
|
|
43
|
+
})
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Image'
|