@vvedantb/native-ui 0.5.1 → 0.6.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/README.md +13 -4
- package/package.json +1 -1
- package/src/Button.tsx +25 -5
- package/src/ai/icon-button.tsx +1 -1
- package/src/ai/prompt-input.tsx +5 -0
- package/src/brand/AppIcons.tsx +4 -4
- package/src/brand/AppMark.tsx +4 -4
- package/src/brand/GoogleMark.tsx +2 -2
- package/src/entries/button.ts +1 -1
- package/src/entries/primitives.ts +1 -1
- package/src/examples/ParityGallery.tsx +21 -0
- package/src/floating.ts +16 -2
- package/src/index.ts +1 -1
- package/src/primitives/button.tsx +10 -3
- package/src/primitives/switch.tsx +2 -2
package/README.md
CHANGED
|
@@ -60,8 +60,8 @@ The root entry exports everything. It still imports `BottomSheetContainer` and `
|
|
|
60
60
|
| --- | --- | --- |
|
|
61
61
|
| `@vvedantb/native-ui/tab-bar` | `FloatingTabBar`, `FloatingTabBarProps`, `FLOATING_INSET`, `FLOATING_TAB_BAR_HEIGHT`, `FLOATING_TAB_BAR_HEIGHT_LARGE`, `tabBarReserve` | `expo-blur`, `expo-haptics` (loaders) |
|
|
62
62
|
| `@vvedantb/native-ui/brand` | `AppMark`, `AppWordmark`, `GoogleMark` (from 0.3.15), `APP_ICONS`, `IconVibot` and the other `Icon*`, the SVG helpers (`APP_MARKS`, `appMarkSvg`, `appTileSvg` and the rest), `FAMILY_APPS`, `familyApp`, `V_PRO_APP_BENEFITS` | none |
|
|
63
|
-
| `@vvedantb/native-ui/button` | `Button`, `ButtonProps`, `ButtonSize`, `ButtonVariant` | none |
|
|
64
|
-
| `@vvedantb/native-ui/primitives` | `Button`, `Input`, `SearchInput`, `Textarea`, `Label`, `Select`, `Switch`, `LabeledSwitchRow`, `Checkbox`, `Card` and its parts, `Badge`, `StatusDot`, `Avatar`, `Separator`, `Progress`, `Spinner`, `Skeleton`, `EmptyState`, `ListRow`, `Chip`, `HeaderIconButton`, `ThemeToggle` (from 0.3.16), `Tabs`, `PillTabs`, `Dialog`, `AlertDialog`, `ConfirmDialog`, `Sheet`, `toast`, `Toaster`. From 0.5.0: `Text` and `TextClassContext` (only here, not on the root), `ColorSwatches`, `StatGrid`, `SectionLabel`, `SheetRow`, `PageIndicator`, `IconButton`, `CaptureButton`, and the `ListRowProps` and `CardProps` types | `expo-blur`, `expo-haptics` (loaders) |
|
|
63
|
+
| `@vvedantb/native-ui/button` | `Button`, `ButtonProps`, `ButtonShape` (0.6.0), `ButtonSize`, `ButtonVariant` | none |
|
|
64
|
+
| `@vvedantb/native-ui/primitives` | `Button`, `Input`, `SearchInput`, `Textarea`, `Label`, `Select`, `Switch`, `LabeledSwitchRow`, `Checkbox`, `Card` and its parts, `Badge`, `StatusDot`, `Avatar`, `Separator`, `Progress`, `Spinner`, `Skeleton`, `EmptyState`, `ListRow`, `Chip`, `HeaderIconButton`, `ThemeToggle` (from 0.3.16), `Tabs`, `PillTabs`, `Dialog`, `AlertDialog`, `ConfirmDialog`, `Sheet`, `toast`, `Toaster`. From 0.5.0: `Text` and `TextClassContext` (only here, not on the root), `ColorSwatches`, `StatGrid`, `SectionLabel`, `SheetRow`, `PageIndicator`, `IconButton`, `CaptureButton`, and the `ListRowProps` and `CardProps` types. From 0.6.0: the `ButtonShape` type | `expo-blur`, `expo-haptics` (loaders) |
|
|
65
65
|
| `@vvedantb/native-ui/search-input` | `SearchInput`, `SearchInputProps` | none |
|
|
66
66
|
| `@vvedantb/native-ui/page-title` | `PageTitle`, `PageHeader`, `PageTitleProps`, `PageHeaderProps` (from 0.3.13), `StackPageHeader`, `StackPageHeaderProps` (from 0.5.0; it brings the Tabler package for its chevron) | none |
|
|
67
67
|
| `@vvedantb/native-ui/toast` | `toast`, `Toaster`, `ToastOptions`, `ToastVariant` | none (from 0.3.12) |
|
|
@@ -154,13 +154,13 @@ import { NativeUiProvider, Button, Card } from "@vvedantb/native-ui";
|
|
|
154
154
|
|
|
155
155
|
**Switch the scheme through NativeWind only.** Call `useColorScheme().setColorScheme("dark"|"light")` (or use `ThemeToggle`). That updates `useScheme` and, with `darkMode: "class"`, the `<html>` class together. Do **not** toggle `document.documentElement.classList` (or a page-level CSS `.dark` rule) by hand while leaving NativeWind on light: the page background can go dark while every token-styled part stays on the light set. That dual-owner fault is an app bug, not a native-ui colour bug.
|
|
156
156
|
|
|
157
|
-
`useLargerText()` steps type and tap targets up. Without it, `Button`, `Input`, `Textarea` and the `Select` trigger have the web sizes (`Button` 32 / 40 / 44 high, fields 40); with it they keep the larger 0.3.2 sizes. `accentColor` tints FABs, card icons and progress bars (checked checkboxes use the palette primary, as on the web). Surfaces use the tokens in `src/tokens.ts` for fill, radius (card 24,
|
|
157
|
+
`useLargerText()` steps type and tap targets up. Without it, `Button`, `Input`, `Textarea` and the `Select` trigger have the web sizes (`Button` 32 / 40 / 44 high, fields 40); with it they keep the larger 0.3.2 sizes. `accentColor` tints FABs, card icons and progress bars (checked checkboxes use the palette primary, as on the web). Surfaces use the tokens in `src/tokens.ts` for fill, radius (card 24, field 10, pill 999; rows 20) and spacing (16). `Button` is a pill (999) by default, and 16 with `shape="rounded"`.
|
|
158
158
|
|
|
159
159
|
## Components (0.3.0)
|
|
160
160
|
|
|
161
161
|
| Area | Exports |
|
|
162
162
|
| --- | --- |
|
|
163
|
-
| Actions and fields | `Button` (`default`/`primary`, `secondary`, `outline`, `destructive`, `ghost`, `link`, `tinted`; `sm`/`small`, `default`/`medium`, `lg`/`large`, `icon`), `IconButton` (0.5.0), `CaptureButton` (0.5.0), `Input`, `SearchInput` (0.3.9), `Textarea`, `Label`, `Select`, `Switch`, `Checkbox`, `LabeledSwitchRow`, `ColorSwatches` (0.5.0), `DateTimeField` (date-only, empty and clearable from 0.5.0) |
|
|
163
|
+
| Actions and fields | `Button` (`default`/`primary`, `secondary`, `outline`, `destructive`, `ghost`, `link`, `tinted`; `sm`/`small`, `default`/`medium`, `lg`/`large`, `icon`; `shape` `pill`/`rounded` from 0.6.0), `IconButton` (0.5.0), `CaptureButton` (0.5.0), `Input`, `SearchInput` (0.3.9), `Textarea`, `Label`, `Select`, `Switch`, `Checkbox`, `LabeledSwitchRow`, `ColorSwatches` (0.5.0), `DateTimeField` (date-only, empty and clearable from 0.5.0) |
|
|
164
164
|
| Display | `Card` (+ `CardHeader`, `CardTitle`, `CardDescription`, `CardContent`, `CardFooter`; `onPress` from 0.5.0), `Badge`, `StatusDot` (`info` from 0.5.0), `Avatar` (+ `AvatarImage`, `AvatarFallback`, `initials()`), `Separator`, `Progress`, `Spinner`, `CenteredSpinner`, `Skeleton`, `EmptyState` (+ `EmptyState.Root` and parts), `ListRow` (`leading`, `titleEnd`, `control`, `onLongPress` from 0.5.0), `StatGrid` (0.5.0), `SectionLabel` (0.5.0), `Chip`, `Text` (0.5.0, `/primitives` only) |
|
|
165
165
|
| Navigation | `Tabs` (+ `TabsList`, `TabsTrigger`, `TabsContent`), `PillTabs`, `PageIndicator` (0.5.0), `FloatingTabBar`, `FloatingFAB`, `HeaderIconButton`, `ThemeToggle` (0.3.16), `StackPageHeader` (0.5.0) |
|
|
166
166
|
| Overlays | `Dialog`, `AlertDialog`, `ConfirmDialog`, `Sheet` (RN `Modal`, each with the web part names), `SheetRow` (0.5.0), `BottomSheetContainer` (`@gorhom/bottom-sheet`) |
|
|
@@ -168,6 +168,15 @@ import { NativeUiProvider, Button, Card } from "@vvedantb/native-ui";
|
|
|
168
168
|
| Brand and upgrade | `APP_ICONS`, `IconVibot` and the other `Icon*`, `AppMark`, `AppWordmark`, `GoogleMark` (0.3.15), `FAMILY_APPS`, `V_PRO_APP_BENEFITS`, `UpgradeToProCard`, `PricingModal` |
|
|
169
169
|
| Settings and layout | `PageTitle`, `PageHeader` (0.3.13), `SettingsSection`, `SettingsField`, `SettingsToggleRow`, `SettingsStack`, `ScreenContainer`, `SafeAreaContainer`, `FloatingSurface`, `AmbientBackground` |
|
|
170
170
|
|
|
171
|
+
**`Button` `shape` (0.6.0).** `Button` is a pill by default, as the web `Button` from `@vvedantb/ui` 0.31.0: `shape="pill"` is fully round (`tokens.radius.pill`, web `rounded-full`) for every variant and size, so `size="icon"` is a circle. `shape="rounded"` keeps the radius from before 0.6.0: 16 at every size (web `rounded-lg`). The web `rounded` is 14 (`rounded-md`) on `xs` and `icon-xs`; native has neither size. The radius is a style, so a `style` radius such as `style={{ borderRadius: 8 }}` wins over either shape; a `className` radius does not.
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
<Button>Save</Button> {/* pill */}
|
|
175
|
+
<Button shape="rounded">Save</Button> {/* radius 16, the 0.5.1 look */}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Parts that render `Button` are pills too. As on the web: `AlertDialogAction`, `AlertDialogCancel` and so the `ConfirmDialog` buttons (also full width in the compact sheet), the `PricingModal` CTA, and in `/ai` `MessageAction`, `CodeBlockCopyButton` and `ConversationScrollButton`. `PromptInputSubmit` and `PromptInputButton` are pills as well, so they are circles at 32 and at 44 with larger text. The web keeps them `shape="rounded"`, but its 16 radius on their 32 size draws the same circle. `AlertDialogAction`, `AlertDialogCancel` and `PromptInputButton` pass `shape` on; `MessageAction`, `CodeBlockCopyButton`, `ConversationScrollButton` and `PromptInputSubmit` take no `shape` and stay round. Components that do not render `Button`, such as `IconButton`, `HeaderIconButton`, `CaptureButton`, `UpgradeToProCard`, inputs, cards, dialogs and sheets, keep their radius.
|
|
179
|
+
|
|
171
180
|
Overlays hold their own open state, or take `open` and `onOpenChange`:
|
|
172
181
|
|
|
173
182
|
```tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar, AI chat parts and the family app marks.",
|
|
6
6
|
"type": "module",
|
package/src/Button.tsx
CHANGED
|
@@ -16,9 +16,12 @@ import { useScheme } from "./useScheme";
|
|
|
16
16
|
/** `sm`, `default` and `lg` are the web names for `small`, `medium` and `large`. `icon` is a square button. */
|
|
17
17
|
type ButtonSize = "small" | "medium" | "large" | "sm" | "default" | "lg" | "icon";
|
|
18
18
|
|
|
19
|
+
/** The web `shape`. `"pill"` (default) is fully round; `"rounded"` is radius 16, the look before 0.6.0. */
|
|
20
|
+
type ButtonShape = "pill" | "rounded";
|
|
21
|
+
|
|
19
22
|
interface ButtonProps extends Omit<
|
|
20
23
|
React.ComponentPropsWithoutRef<typeof PrimitiveButton>,
|
|
21
|
-
"variant" | "size" | "children" | "onPress"
|
|
24
|
+
"variant" | "size" | "shape" | "children" | "onPress"
|
|
22
25
|
> {
|
|
23
26
|
onPress?: () => void;
|
|
24
27
|
variant?: ButtonVariant;
|
|
@@ -30,6 +33,13 @@ interface ButtonProps extends Omit<
|
|
|
30
33
|
endContent?: React.ReactNode;
|
|
31
34
|
loading?: boolean;
|
|
32
35
|
size?: ButtonSize;
|
|
36
|
+
/**
|
|
37
|
+
* Default `"pill"`: fully round at every size and variant, so `icon` is a
|
|
38
|
+
* circle (web `rounded-full`). `"rounded"`: radius 16 at every size, the
|
|
39
|
+
* look before 0.6.0 (web `shape="rounded"`, `rounded-lg`). A `style`
|
|
40
|
+
* radius wins over either.
|
|
41
|
+
*/
|
|
42
|
+
shape?: ButtonShape;
|
|
33
43
|
/**
|
|
34
44
|
* Default `true`. In the stacked footer of a compact dialog the button fills
|
|
35
45
|
* the width whatever this says, as on the web.
|
|
@@ -84,8 +94,16 @@ const HIT_SLOP = {
|
|
|
84
94
|
larger: { small: 8, medium: undefined, large: undefined, icon: 8 },
|
|
85
95
|
};
|
|
86
96
|
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
// The web `shape` (from @vvedantb/ui 0.31.0). `pill` is `rounded-full`:
|
|
98
|
+
// `tokens.radius.pill` (999), far more than half the tallest minimum height
|
|
99
|
+
// (72), so the ends are half circles. `rounded` is `rounded-lg` (`--radius`, 16). The web
|
|
100
|
+
// `rounded` is `rounded-md` on `xs` and `icon-xs`, sizes native does not have,
|
|
101
|
+
// so here it is 16 at every size. Styles, because apps' NativeWind themes set
|
|
102
|
+
// their own `rounded-lg`.
|
|
103
|
+
const RADIUS: Record<ButtonShape, number> = {
|
|
104
|
+
pill: tokens.radius.pill,
|
|
105
|
+
rounded: tokens.radius.lg,
|
|
106
|
+
};
|
|
89
107
|
|
|
90
108
|
// Colours come from `buttonColors` as styles, except `tinted`, which keeps
|
|
91
109
|
// the pink classes that `outline` used before 0.3.0.
|
|
@@ -110,7 +128,7 @@ const PRIMITIVE_VARIANT = {
|
|
|
110
128
|
tinted: "secondary",
|
|
111
129
|
} as const;
|
|
112
130
|
|
|
113
|
-
export type { ButtonProps, ButtonSize, ButtonVariant };
|
|
131
|
+
export type { ButtonProps, ButtonShape, ButtonSize, ButtonVariant };
|
|
114
132
|
|
|
115
133
|
export function Button({
|
|
116
134
|
onPress,
|
|
@@ -121,6 +139,7 @@ export function Button({
|
|
|
121
139
|
endContent,
|
|
122
140
|
loading,
|
|
123
141
|
size = "medium",
|
|
142
|
+
shape = "pill",
|
|
124
143
|
fullWidth = true,
|
|
125
144
|
children,
|
|
126
145
|
shadowType = "flat",
|
|
@@ -136,7 +155,7 @@ export function Button({
|
|
|
136
155
|
const elevate =
|
|
137
156
|
shadowType === "shadow" && (variant === "primary" || variant === "default");
|
|
138
157
|
const baseStyle = [
|
|
139
|
-
{ borderRadius: RADIUS },
|
|
158
|
+
{ borderRadius: RADIUS[shape] },
|
|
140
159
|
elevate ? floatingShadow : null,
|
|
141
160
|
colors
|
|
142
161
|
? { backgroundColor: colors.backgroundColor, borderColor: colors.borderColor }
|
|
@@ -159,6 +178,7 @@ export function Button({
|
|
|
159
178
|
<PrimitiveButton
|
|
160
179
|
onPress={onPress}
|
|
161
180
|
variant={PRIMITIVE_VARIANT[variant]}
|
|
181
|
+
shape={shape}
|
|
162
182
|
hitSlop={HIT_SLOP[scale][resolvedSize]}
|
|
163
183
|
accessibilityRole="button"
|
|
164
184
|
className={cn(
|
package/src/ai/icon-button.tsx
CHANGED
|
@@ -22,6 +22,7 @@ export type ChatIconButtonProps = Omit<ButtonProps, "children" | "size" | "icon"
|
|
|
22
22
|
* A round `Button` at the web `icon-sm` size (32), with the slop to 44. With
|
|
23
23
|
* larger text it is painted 44 with a 20 icon. The message
|
|
24
24
|
* actions, the composer tools and its send button, and the code copy button.
|
|
25
|
+
* Round from the `Button` pill default; `shape="rounded"` gives radius 16.
|
|
25
26
|
*/
|
|
26
27
|
export function ChatIconButton({
|
|
27
28
|
icon: Icon,
|
|
@@ -42,7 +43,6 @@ export function ChatIconButton({
|
|
|
42
43
|
accessibilityLabel={label}
|
|
43
44
|
hitSlop={touchSlop(size)}
|
|
44
45
|
className={cn(largerText ? "h-11 w-11" : "h-8 w-8", className)}
|
|
45
|
-
style={{ borderRadius: size / 2 }}
|
|
46
46
|
{...props}
|
|
47
47
|
>
|
|
48
48
|
<Icon size={largerText ? 20 : 16} color={color} />
|
package/src/ai/prompt-input.tsx
CHANGED
|
@@ -27,6 +27,11 @@ export type PromptInputSubmitProps = {
|
|
|
27
27
|
testID?: string;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
// The web `PromptInputSubmit` and `PromptInputButton` keep `shape="rounded"`
|
|
31
|
+
// (`rounded-lg`, 16) as field addons. At the 32 `icon-sm` size 16 is half the
|
|
32
|
+
// side, so the web draws a circle. These stay pills: the same circle at 32, and
|
|
33
|
+
// still a circle at 44 with larger text, where 16 would draw a rounded square.
|
|
34
|
+
|
|
30
35
|
/**
|
|
31
36
|
* Send, or stop while the AI answers: the web `default` `icon-sm` button
|
|
32
37
|
* (32, round, slop to 44). Send is an up arrow on the primary fill, and the
|
package/src/brand/AppIcons.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Platform, type
|
|
2
|
-
import Svg, { G, Path } from "react-native-svg";
|
|
1
|
+
import { Platform, type ViewProps } from "react-native";
|
|
2
|
+
import Svg, { G, Path, type GProps } from "react-native-svg";
|
|
3
3
|
import { svgA11yProps } from "../svgA11y";
|
|
4
4
|
import { tokens } from "../tokens";
|
|
5
5
|
import { useScheme } from "../useScheme";
|
|
@@ -26,7 +26,7 @@ export type AppIconProps = {
|
|
|
26
26
|
align?: "center" | "start";
|
|
27
27
|
/** Set as `data-testid` on web, where `Svg` does not map `testID`. */
|
|
28
28
|
testID?: string;
|
|
29
|
-
style?:
|
|
29
|
+
style?: ViewProps["style"];
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export type AppIconComponent = ((props: AppIconProps) => React.JSX.Element) & {
|
|
@@ -54,7 +54,7 @@ function createAppIcon(app: AppName, displayName: string): AppIconComponent {
|
|
|
54
54
|
stroke === undefined
|
|
55
55
|
? markStrokeWidth(app)
|
|
56
56
|
: stroke * (viewBoxSide(app) / size);
|
|
57
|
-
const glyphProps =
|
|
57
|
+
const glyphProps: GProps =
|
|
58
58
|
kind === "fill"
|
|
59
59
|
? { fill }
|
|
60
60
|
: {
|
package/src/brand/AppMark.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Platform, type
|
|
2
|
-
import Svg, { G, Path, Rect } from "react-native-svg";
|
|
1
|
+
import { Platform, type ViewProps } from "react-native";
|
|
2
|
+
import Svg, { G, Path, Rect, type GProps } from "react-native-svg";
|
|
3
3
|
import { svgA11yProps } from "../svgA11y";
|
|
4
4
|
import { APP_ICONS } from "./AppIcons";
|
|
5
5
|
import {
|
|
@@ -23,7 +23,7 @@ export type AppMarkProps = {
|
|
|
23
23
|
title?: string;
|
|
24
24
|
/** Set as `data-testid` on web, where `Svg` does not map `testID`. */
|
|
25
25
|
testID?: string;
|
|
26
|
-
style?:
|
|
26
|
+
style?: ViewProps["style"];
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const TILE_TONES = {
|
|
@@ -50,7 +50,7 @@ export function AppMark({
|
|
|
50
50
|
}
|
|
51
51
|
const { kind, paths } = APP_MARKS[app];
|
|
52
52
|
const tone = TILE_TONES[variant];
|
|
53
|
-
const glyphProps =
|
|
53
|
+
const glyphProps: GProps =
|
|
54
54
|
kind === "fill"
|
|
55
55
|
? { fill: tone.fg }
|
|
56
56
|
: {
|
package/src/brand/GoogleMark.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Platform, type
|
|
1
|
+
import { Platform, type ViewProps } from "react-native";
|
|
2
2
|
import Svg, { Path } from "react-native-svg";
|
|
3
3
|
import { svgA11yProps } from "../svgA11y";
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ export type GoogleMarkProps = {
|
|
|
9
9
|
title?: string;
|
|
10
10
|
/** Set as `data-testid` on web, where `Svg` does not map `testID`. */
|
|
11
11
|
testID?: string;
|
|
12
|
-
style?:
|
|
12
|
+
style?: ViewProps["style"];
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
/** The four paths of the Google "G" on the 24 grid, each in its brand colour. */
|
package/src/entries/button.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// `primitives/text` variants (from 0.5.0); they are not on the root entry.
|
|
5
5
|
export { Text, TextClassContext } from "../primitives/text";
|
|
6
6
|
export { Button } from "../Button";
|
|
7
|
-
export type { ButtonProps, ButtonSize, ButtonVariant } from "../Button";
|
|
7
|
+
export type { ButtonProps, ButtonShape, ButtonSize, ButtonVariant } from "../Button";
|
|
8
8
|
export { Input } from "../Input";
|
|
9
9
|
export type { InputProps } from "../Input";
|
|
10
10
|
export { SearchInput } from "../SearchInput";
|
|
@@ -294,6 +294,27 @@ function GalleryScreen() {
|
|
|
294
294
|
<Button size="lg" fullWidth={false}>
|
|
295
295
|
Large
|
|
296
296
|
</Button>
|
|
297
|
+
<Button size="icon" variant="outline" accessibilityLabel="Copy" onPress={() => toast("Copied")}>
|
|
298
|
+
<IconCopy size={16} color={tokens.color.foreground[scheme]} />
|
|
299
|
+
</Button>
|
|
300
|
+
</View>
|
|
301
|
+
{/* Pills by default, as on the web. `shape="rounded"` keeps radius 16, the look before 0.6.0. */}
|
|
302
|
+
<View className="flex-row flex-wrap items-center gap-2">
|
|
303
|
+
<Button shape="rounded" size="sm" fullWidth={false}>
|
|
304
|
+
Rounded
|
|
305
|
+
</Button>
|
|
306
|
+
<Button shape="rounded" variant="secondary" fullWidth={false}>
|
|
307
|
+
Rounded
|
|
308
|
+
</Button>
|
|
309
|
+
<Button
|
|
310
|
+
shape="rounded"
|
|
311
|
+
size="icon"
|
|
312
|
+
variant="outline"
|
|
313
|
+
accessibilityLabel="Copy"
|
|
314
|
+
onPress={() => toast("Copied")}
|
|
315
|
+
>
|
|
316
|
+
<IconCopy size={16} color={tokens.color.foreground[scheme]} />
|
|
317
|
+
</Button>
|
|
297
318
|
</View>
|
|
298
319
|
</Section>
|
|
299
320
|
|
package/src/floating.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Platform
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
2
|
import { tokens } from "./tokens";
|
|
3
3
|
|
|
4
4
|
export const FLOATING_INSET = tokens.spacing.unit;
|
|
@@ -14,7 +14,21 @@ export const FLOATING_PILL_RADIUS = tokens.radius.pill;
|
|
|
14
14
|
|
|
15
15
|
const FLOATING_BOX_SHADOW = "0px 8px 24px rgba(10, 10, 10, 0.12)";
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Only the shadow keys, not `ViewStyle`: an Expo-widened `ViewStyle`
|
|
19
|
+
* (`position: "fixed"`, `backgroundImage`) is not assignable to a React
|
|
20
|
+
* Native 0.88 View `style`. A plain inferred type would be `{}` and lose
|
|
21
|
+
* `floatingShadow.shadowColor` and the rest for callers.
|
|
22
|
+
*/
|
|
23
|
+
type FloatingShadowStyle = {
|
|
24
|
+
shadowColor?: string;
|
|
25
|
+
shadowOffset?: { width: number; height: number };
|
|
26
|
+
shadowOpacity?: number;
|
|
27
|
+
shadowRadius?: number;
|
|
28
|
+
boxShadow?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const floatingShadow: FloatingShadowStyle =
|
|
18
32
|
Platform.select({
|
|
19
33
|
ios: {
|
|
20
34
|
shadowColor: "#0a0a0a",
|
package/src/index.ts
CHANGED
|
@@ -38,7 +38,7 @@ export { FloatingTabBar } from "./FloatingTabBar";
|
|
|
38
38
|
export type { FloatingTabBarProps } from "./FloatingTabBar";
|
|
39
39
|
export { FloatingFAB } from "./FloatingFAB";
|
|
40
40
|
export { Button } from "./Button";
|
|
41
|
-
export type { ButtonProps, ButtonSize, ButtonVariant } from "./Button";
|
|
41
|
+
export type { ButtonProps, ButtonShape, ButtonSize, ButtonVariant } from "./Button";
|
|
42
42
|
export { Input } from "./Input";
|
|
43
43
|
export type { InputProps } from "./Input";
|
|
44
44
|
export { SearchInput } from "./SearchInput";
|
|
@@ -6,7 +6,7 @@ import { Platform, Pressable } from "react-native";
|
|
|
6
6
|
|
|
7
7
|
const buttonVariants = cva(
|
|
8
8
|
cn(
|
|
9
|
-
"group flex-row items-center justify-center gap-2
|
|
9
|
+
"group flex-row items-center justify-center gap-2 shadow-none active:opacity-80",
|
|
10
10
|
Platform.select({
|
|
11
11
|
web: "outline-none transition-all",
|
|
12
12
|
}),
|
|
@@ -39,10 +39,17 @@ const buttonVariants = cva(
|
|
|
39
39
|
lg: "h-11 px-6",
|
|
40
40
|
icon: "h-10 w-10",
|
|
41
41
|
},
|
|
42
|
+
// The web `shape`: `pill` (default) is fully round, `rounded` the radius
|
|
43
|
+
// before 0.6.0. `Button` also sets the radius as a style, which wins.
|
|
44
|
+
shape: {
|
|
45
|
+
pill: "rounded-full",
|
|
46
|
+
rounded: "rounded-lg",
|
|
47
|
+
},
|
|
42
48
|
},
|
|
43
49
|
defaultVariants: {
|
|
44
50
|
variant: "default",
|
|
45
51
|
size: "default",
|
|
52
|
+
shape: "pill",
|
|
46
53
|
},
|
|
47
54
|
},
|
|
48
55
|
);
|
|
@@ -80,13 +87,13 @@ type ButtonProps = React.ComponentPropsWithoutRef<typeof Pressable> &
|
|
|
80
87
|
const Button = React.forwardRef<
|
|
81
88
|
React.ElementRef<typeof Pressable>,
|
|
82
89
|
ButtonProps
|
|
83
|
-
>(({ className, variant, size, ...props }, ref) => {
|
|
90
|
+
>(({ className, variant, size, shape, ...props }, ref) => {
|
|
84
91
|
return (
|
|
85
92
|
<TextClassContext.Provider value={buttonTextVariants({ variant, size })}>
|
|
86
93
|
<Pressable
|
|
87
94
|
ref={ref}
|
|
88
95
|
className={cn(
|
|
89
|
-
buttonVariants({ variant, size }),
|
|
96
|
+
buttonVariants({ variant, size, shape }),
|
|
90
97
|
props.disabled && "opacity-45",
|
|
91
98
|
className,
|
|
92
99
|
)}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as SwitchPrimitives from "@rn-primitives/switch";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { Platform, type ViewStyle } from "react-native";
|
|
3
|
+
import { Platform, type ViewProps, type ViewStyle } from "react-native";
|
|
4
4
|
import { cn } from "../cn";
|
|
5
5
|
|
|
6
6
|
type SwitchProps = React.ComponentPropsWithoutRef<
|
|
@@ -13,7 +13,7 @@ type SwitchProps = React.ComponentPropsWithoutRef<
|
|
|
13
13
|
* which spreads `style`, so these are the only styles applied there.
|
|
14
14
|
*/
|
|
15
15
|
trackStyle?: ViewStyle;
|
|
16
|
-
thumbStyle?:
|
|
16
|
+
thumbStyle?: ViewProps["style"];
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const Switch = React.forwardRef<
|