@butternutbox/pawprint-native 0.5.0 → 0.5.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butternutbox/pawprint-native",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "ButternutBox Pawprint Design System - React Native Components",
6
6
  "main": "./dist/index.cjs",
@@ -1,8 +1,9 @@
1
1
  import React from "react"
2
- import { ScrollView, ScrollViewProps } from "react-native"
2
+ import { ScrollView, ScrollViewProps, useWindowDimensions } from "react-native"
3
3
  import styled from "@emotion/native"
4
4
  import { useTheme } from "@emotion/react"
5
5
  import { useDrawerHeaderContext } from "./DrawerHeaderContext"
6
+ import { useDrawerFooterContext } from "./DrawerFooterContext"
6
7
 
7
8
  export type DrawerBodyProps = ScrollViewProps
8
9
 
@@ -12,12 +13,24 @@ const StyledScrollView = styled(ScrollView)<{
12
13
  bodyPaddingHorizontal: number
13
14
  bodyPaddingRight: number
14
15
  bodyGap: number
15
- }>(({ bodyPaddingHorizontal, bodyPaddingRight, bodyGap }) => ({
16
- flex: 1,
17
- paddingLeft: bodyPaddingHorizontal,
18
- paddingRight: bodyPaddingRight,
19
- gap: bodyGap
20
- }))
16
+ bodyMaxHeight: number
17
+ bodyPaddingBottom: number
18
+ }>(
19
+ ({
20
+ bodyPaddingHorizontal,
21
+ bodyPaddingRight,
22
+ bodyGap,
23
+ bodyMaxHeight,
24
+ bodyPaddingBottom
25
+ }) => ({
26
+ flex: 1,
27
+ paddingLeft: bodyPaddingHorizontal,
28
+ paddingRight: bodyPaddingRight,
29
+ gap: bodyGap,
30
+ maxHeight: bodyMaxHeight,
31
+ paddingBottom: bodyPaddingBottom
32
+ })
33
+ )
21
34
 
22
35
  /**
23
36
  * Scrollable content area of the drawer. Grows to fill available space
@@ -30,10 +43,13 @@ export const DrawerBody = React.forwardRef<ScrollView, DrawerBodyProps>(
30
43
  const { buttons } = theme.tokens.components
31
44
  const { content } = spacing
32
45
  const headerContext = useDrawerHeaderContext()
46
+ const footerContext = useDrawerFooterContext()
47
+ const { height: windowHeight } = useWindowDimensions()
33
48
 
34
49
  const gap = parseTokenValue(content.slot.gap)
35
50
  const horizontalPadding = parseTokenValue(content.slot.horizontalPadding)
36
51
  const topPadding = parseTokenValue(content.slot.verticalPadding)
52
+ const bodyMaxHeight = windowHeight - 300
37
53
 
38
54
  // When there's no header the close button floats in the top-right corner.
39
55
  // Reserve space on the right so body content doesn't slide under it.
@@ -43,12 +59,18 @@ export const DrawerBody = React.forwardRef<ScrollView, DrawerBodyProps>(
43
59
  parseTokenValue(buttons.size.sm.height)
44
60
  : horizontalPadding
45
61
 
62
+ const bodyPaddingBottom = !footerContext
63
+ ? parseTokenValue(theme.tokens.semantics.dimensions.spacing["2xl"])
64
+ : 0
65
+
46
66
  return (
47
67
  <StyledScrollView
48
68
  ref={ref}
49
69
  bodyPaddingHorizontal={horizontalPadding}
50
70
  bodyPaddingRight={paddingRight}
51
71
  bodyGap={gap}
72
+ bodyMaxHeight={bodyMaxHeight}
73
+ bodyPaddingBottom={bodyPaddingBottom}
52
74
  contentContainerStyle={[
53
75
  {
54
76
  gap,