@startupjs-ui/div 0.1.5 → 0.1.10
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 +11 -0
- package/README.mdx +31 -0
- package/index.tsx +12 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.1.10](https://github.com/startupjs/startupjs-ui/compare/v0.1.9...v0.1.10) (2026-01-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **div:** add automatic Reanimated support for animations and transitions ([#3](https://github.com/startupjs/startupjs-ui/issues/3)) ([043c39a](https://github.com/startupjs/startupjs-ui/commit/043c39aafd332276082bcbe3233ad0355b85e38a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.1.5](https://github.com/startupjs/startupjs-ui/compare/v0.1.4...v0.1.5) (2025-12-29)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @startupjs-ui/div
|
package/README.mdx
CHANGED
|
@@ -187,6 +187,37 @@ styl`
|
|
|
187
187
|
`
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
+
## Animations
|
|
191
|
+
|
|
192
|
+
Div automatically uses React Native Reanimated when a `transition` or `animation` property is detected in the style. This allows you to create smooth animations without any additional setup.
|
|
193
|
+
|
|
194
|
+
**Note:** When using modifier classes to add transitions/animations dynamically, set `animation: none` in the base styles. This ensures Div uses the animated component from the start.
|
|
195
|
+
|
|
196
|
+
```jsx example
|
|
197
|
+
const [isGreen, setIsGreen] = useState(false)
|
|
198
|
+
const boxStyle = {
|
|
199
|
+
width: 50,
|
|
200
|
+
height: 50,
|
|
201
|
+
backgroundColor: isGreen ? 'green' : 'red',
|
|
202
|
+
transitionProperty: 'backgroundColor',
|
|
203
|
+
transitionDuration: 1000
|
|
204
|
+
}
|
|
205
|
+
const buttonStyle = {
|
|
206
|
+
paddingVertical: 8,
|
|
207
|
+
paddingHorizontal: 16,
|
|
208
|
+
backgroundColor: '#2962FF',
|
|
209
|
+
borderRadius: 4
|
|
210
|
+
}
|
|
211
|
+
return (
|
|
212
|
+
<Div row align='left' vAlign='center' gap>
|
|
213
|
+
<Div style={boxStyle} />
|
|
214
|
+
<Div style={buttonStyle} onPress={() => setIsGreen(!isGreen)}>
|
|
215
|
+
<Span style={{ color: 'white' }}>Toggle Color</Span>
|
|
216
|
+
</Div>
|
|
217
|
+
</Div>
|
|
218
|
+
)
|
|
219
|
+
```
|
|
220
|
+
|
|
190
221
|
## Sandbox
|
|
191
222
|
|
|
192
223
|
<Sandbox
|
package/index.tsx
CHANGED
|
@@ -9,11 +9,19 @@ import {
|
|
|
9
9
|
type ViewProps,
|
|
10
10
|
type AccessibilityRole
|
|
11
11
|
} from 'react-native'
|
|
12
|
+
import Animated from 'react-native-reanimated'
|
|
12
13
|
import { pug, observer, u, useDidUpdate } from 'startupjs'
|
|
13
14
|
import { colorToRGBA, getCssVariable, themed } from '@startupjs-ui/core'
|
|
14
15
|
import { useDecorateTooltipProps } from './useTooltip'
|
|
15
16
|
import STYLES from './index.cssx.styl'
|
|
16
17
|
|
|
18
|
+
const AnimatedPressable = Animated.createAnimatedComponent(Pressable)
|
|
19
|
+
|
|
20
|
+
function hasAnimatedProperty (style: any): boolean {
|
|
21
|
+
if (!style) return false
|
|
22
|
+
return Object.keys(style).some(key => key.startsWith('animation') || key.startsWith('transition'))
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
const DEPRECATED_PUSHED_VALUES = ['xs', 'xl', 'xxl']
|
|
18
26
|
const PRESSABLE_PROPS = ['onPress', 'onLongPress', 'onPressIn', 'onPressOut']
|
|
19
27
|
const isWeb = Platform.OS === 'web'
|
|
@@ -166,7 +174,10 @@ function Div ({
|
|
|
166
174
|
|
|
167
175
|
if (!accessible) accessibilityRole = undefined
|
|
168
176
|
|
|
169
|
-
const
|
|
177
|
+
const isAnimated = hasAnimatedProperty(style) || hasAnimatedProperty(pressableStyle)
|
|
178
|
+
const Component = isPressable
|
|
179
|
+
? (isAnimated ? AnimatedPressable : Pressable)
|
|
180
|
+
: (isAnimated ? Animated.View : View)
|
|
170
181
|
const testID = props.testID ?? props['data-testid']
|
|
171
182
|
const divElement = pug`
|
|
172
183
|
Component.root(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs-ui/div",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": "*",
|
|
21
21
|
"react-native": "*",
|
|
22
|
+
"react-native-reanimated": ">=4.0.0",
|
|
22
23
|
"startupjs": "*"
|
|
23
24
|
},
|
|
24
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "1ecb64054dc88294ac0ca801d1241e39052fa47c"
|
|
25
26
|
}
|