@butternutbox/pawprint-native 0.7.0 → 0.9.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.
@@ -1,5 +1,6 @@
1
1
  import React from "react"
2
2
  import { View, StyleSheet } from "react-native"
3
+ import { Home } from "@butternutbox/pawprint-icons/core"
3
4
  import { TabNavigation } from "./TabNavigation"
4
5
  import type { TabNavigationProps } from "./TabNavigation"
5
6
  import { Typography } from "../../atoms/Typography"
@@ -149,6 +150,40 @@ export const States = {
149
150
  )
150
151
  }
151
152
 
153
+ const DOG_PHOTO_URL = "https://placedog.net/200/200"
154
+
155
+ export const WithIconsAndAvatars = {
156
+ name: "With Icons & Avatars",
157
+ render: () => (
158
+ <View style={styles.container}>
159
+ <TabNavigation defaultValue="home" layout="fixed">
160
+ <TabNavigation.List>
161
+ <TabNavigation.Tab value="home" icon={Home}>
162
+ Home
163
+ </TabNavigation.Tab>
164
+ <TabNavigation.Tab
165
+ value="dog"
166
+ avatar={{
167
+ src: DOG_PHOTO_URL,
168
+ alt: "Your dog",
169
+ size: "sm",
170
+ border: "sm"
171
+ }}
172
+ >
173
+ Your dog
174
+ </TabNavigation.Tab>
175
+ </TabNavigation.List>
176
+ <TabNavigation.Panel value="home">
177
+ <PanelBody>A leading icon sits before the label.</PanelBody>
178
+ </TabNavigation.Panel>
179
+ <TabNavigation.Panel value="dog">
180
+ <PanelBody>The Avatar atom can lead the label too.</PanelBody>
181
+ </TabNavigation.Panel>
182
+ </TabNavigation>
183
+ </View>
184
+ )
185
+ }
186
+
152
187
  export const AnimatedContent = {
153
188
  name: "Animated Content (fade)",
154
189
  render: () => (
@@ -10,6 +10,8 @@ import styled from "@emotion/native"
10
10
  import { useTheme } from "@emotion/react"
11
11
  import * as TabsPrimitive from "@rn-primitives/tabs"
12
12
  import { Typography, type TypographyProps } from "../../atoms/Typography"
13
+ import { Icon, type PawprintIcon } from "../../atoms/Icon"
14
+ import { Avatar, type AvatarProps } from "../../atoms/Avatar"
13
15
  import { Animated, type AnimatedVariant } from "../Animated"
14
16
 
15
17
  type TabNavigationLayout = "fixed" | "intrinsic"
@@ -64,6 +66,8 @@ export type TabNavigationListProps = TabNavigationListOwnProps &
64
66
  type TabNavigationTabOwnProps = {
65
67
  value: string
66
68
  disabled?: boolean
69
+ icon?: PawprintIcon
70
+ avatar?: AvatarProps
67
71
  children: React.ReactNode
68
72
  }
69
73
 
@@ -169,12 +173,18 @@ TabNavigationList.displayName = "TabNavigation.List"
169
173
  * disabled state). Unlike the web version there are no hover or focus-visible
170
174
  * states (not applicable on mobile).
171
175
  *
176
+ * Optionally renders a leading `Avatar` and/or `Icon` before the label, matching
177
+ * the Figma design. The icon colour tracks the tab's label colour (brand when
178
+ * active/idle, muted when disabled); the avatar is rendered as-is from its props.
179
+ *
172
180
  * @param {string} value - Unique identifier; matches the `value` of a `TabNavigation.Panel`.
173
181
  * @param {boolean} [disabled=false] - Whether this tab is disabled.
182
+ * @param {PawprintIcon} [icon] - Optional leading icon from `@butternutbox/pawprint-icons`.
183
+ * @param {AvatarProps} [avatar] - Optional leading `Avatar`; props are forwarded to the `Avatar` atom.
174
184
  * @param {React.ReactNode} children - Tab label (and optional leading content).
175
185
  */
176
186
  const TabNavigationTab = React.forwardRef<View, TabNavigationTabProps>(
177
- ({ value, disabled = false, children, ...rest }, ref) => {
187
+ ({ value, disabled = false, icon, avatar, children, ...rest }, ref) => {
178
188
  const { layout } = useTabNavigationContext()
179
189
  const { value: selectedValue } = TabsPrimitive.useRootContext()
180
190
  const theme = useTheme()
@@ -209,6 +219,10 @@ const TabNavigationTab = React.forwardRef<View, TabNavigationTabProps>(
209
219
  tabFlex={layout === "fixed" ? 1 : undefined}
210
220
  {...rest}
211
221
  >
222
+ {avatar && <Avatar {...avatar} />}
223
+ {icon && (
224
+ <Icon icon={icon} customColour={textColour as string} aria-hidden />
225
+ )}
212
226
  <Typography token={token} color={textColour}>
213
227
  {children}
214
228
  </Typography>