diff --git a/example/storybook-nativewind/src/components/Actionsheet/Actionsheet.tsx b/example/storybook-nativewind/src/components/Actionsheet/Actionsheet.tsx index 593e0d6b4..eb8ee11dc 100644 --- a/example/storybook-nativewind/src/components/Actionsheet/Actionsheet.tsx +++ b/example/storybook-nativewind/src/components/Actionsheet/Actionsheet.tsx @@ -1,6 +1,5 @@ import React from 'react'; import { Button, ButtonText } from '@/components/ui/button'; -import { Center } from '@/components/ui/center'; import { Actionsheet, ActionsheetIcon, @@ -17,44 +16,40 @@ import { ActionsheetVirtualizedList, } from '@/components/ui/actionsheet'; -const ActionsheetBasic = ({ showActionsheetProp, ...props }: any) => { +const ActionsheetBasic = ({ ...props }: any) => { const [showActionsheet, setShowActionsheet] = React.useState(false); const handleClose = () => setShowActionsheet(false); return ( -
+ <> - + - Delete - - - Share + Edit Message - Play + Mark Unread - Favourite + Remind Me - Cancel + Add to Saved Items + + + Delete -
+ ); }; diff --git a/example/storybook-nativewind/src/components/Actionsheet/index.nw.stories.mdx b/example/storybook-nativewind/src/components/Actionsheet/index.nw.stories.mdx index 34143ddcc..b5cf7a0ef 100644 --- a/example/storybook-nativewind/src/components/Actionsheet/index.nw.stories.mdx +++ b/example/storybook-nativewind/src/components/Actionsheet/index.nw.stories.mdx @@ -28,6 +28,7 @@ import { ActionsheetFlatList, ActionsheetSectionList, ActionsheetSectionHeaderText, + ButtonGroup, Button, ButtonText, VStack, @@ -43,13 +44,16 @@ import { HStack, Image, Text, + Heading, Box, Icon, TrashIcon, - ShareIcon, - PlayIcon, - FavouriteIcon, + EyeOffIcon, + ClockIcon, + DownloadIcon, + EditIcon, CloseIcon, + Pressable } from '../../core-components/nativewind'; import { CollapsibleCode, @@ -58,13 +62,10 @@ import { Table, TableContainer, InlineCode, - AddIcon, - InfoIcon, - Alert, Tabs } from '@gluestack/design-system'; import { Platform, KeyboardAvoidingView, } from 'react-native'; -import { CreditCardIcon } from 'lucide-react-native'; +import { CreditCardIcon, UploadCloud, Send, Percent, DollarSign } from 'lucide-react-native'; import { transformedCode } from '../../utils'; import Wrapper from '../../core-components/nativewind/Wrapper'; @@ -76,41 +77,41 @@ This is an illustration of **Actionsheet** component. showArgsController={false} metaData={{ code: ` -function App(){ - const [showActionsheet, setShowActionsheet] = React.useState(false); - const handleClose = () => setShowActionsheet(!showActionsheet); - return ( - - - - - - - - - - Delete - - - Share - - - Play - - - Favourite - - - Cancel - - - - - ); -} -`, + function App(){ + const [showActionsheet, setShowActionsheet] = React.useState(false); + const handleClose = () => setShowActionsheet(!showActionsheet); + return ( + <> + + + + + + + + + Edit Message + + + Mark Unread + + + Remind Me + + + Add to Saved Items + + + Delete + + + + + ); + } + `, transformCode: (code) => { return transformedCode(code, 'function', 'App'); }, @@ -125,7 +126,6 @@ function App(){ ActionsheetItem, ActionsheetItemText, Wrapper, - Box, }, }} /> @@ -509,7 +509,15 @@ We have outlined the various features that ensure the Actionsheet component is a ### Screen Reader -- VoiceOver: When the actionsheet is focused, the screen reader will announce the button group . +- VoiceOver: When the ActionSheet is focused, the screen reader will announce the button name. After entering the ActionSheet, it will read the content of the ActionSheet items. + +#### Keyboard + +- `Space`: Opens the actionsheet. +- `Enter`: Opens/closes the actionsheet. +- `Tab`: Moves focus to the next focusable element. +- `Shift + Tab`: Moves focus to the previous focusable element. +- `Esc`: Closes the actionsheet. ## Examples @@ -531,60 +539,60 @@ Demonstrates a common UI pattern known as keyboard handling or keyboard scrollin const [showActionsheet, setShowActionsheet] = React.useState(false); const handleClose = () => setShowActionsheet(!showActionsheet); return ( - <> + <> - - - - - - - - - - - - - - Mastercard - Card ending in 2345 - - - - - - Confirm security code - - - - - - - - - - - - - - - + + + + + + + + + + + + + + Mastercard + Card ending in 2345 + + + + + + Confirm security code + + + + + + + + + + + + + + + ); } -`, + `, transformCode: (code) => { return transformedCode(code, 'function', 'App'); }, @@ -633,68 +641,68 @@ Demonstrates a common UI pattern known as keyboard handling or keyboard scrollin const [showActionsheet, setShowActionsheet] = React.useState(false); const handleClose = () => setShowActionsheet(!showActionsheet); return ( - <> - - - - - - - - - - - - - - - Mastercard - Card ending in 2345 - - - - - - Confirm security code - - - - - - - - - - - - - - - -);} -`, + + + + + + + + + + + + + + Mastercard + Card ending in 2345 + + + + + + Confirm security code + + + + + + + + + + + + + + + + ) + } + `, transformCode: (code) => { return transformedCode(code, 'function', 'App'); }, @@ -745,52 +753,42 @@ The Actionsheet with Icons is a variation of the Actionsheet component that disp const [showActionsheet, setShowActionsheet] = React.useState(false); const handleClose = () => setShowActionsheet(!showActionsheet); return ( - <> + <> - + - - - - Delete + + Edit Message - - - - Share + + Mark Unread - - - - Play + + Remind Me - - - - Favourite + + Add to Saved Items - - - - - Cancel + + + Delete - - - ); - } - `, + + + ); + } + `, transformCode: (code) => { return transformedCode(code, 'function', 'App'); }, @@ -803,13 +801,12 @@ The Actionsheet with Icons is a variation of the Actionsheet component that disp ActionsheetItem, ActionsheetItemText, ActionsheetIcon, - Icon, Wrapper, TrashIcon, - ShareIcon, - PlayIcon, - FavouriteIcon, - CloseIcon, + EyeOffIcon, + ClockIcon, + DownloadIcon, + EditIcon, Button, ButtonText, }, @@ -982,20 +979,8 @@ The Actionsheet with SectionList is a variation of the Actionsheet component tha const handleClose = () => setShowActionsheet(!showActionsheet); const DATA = [ { - title: 'Main dishes', - data: ['Pizza', 'Burger', 'Risotto'], - }, - { - title: 'Sides', - data: ['French Fries', 'Onion Rings', 'Fried Shrimps'], - }, - { - title: 'Drinks', - data: ['Water', 'Coke', 'Beer'], - }, - { - title: 'Desserts', - data: ['Cheese Cake', 'Ice Cream'], + title: 'Gender', + data: ['Men', 'Women', 'Boy', 'Girl'], }, ]; return ( @@ -1003,7 +988,7 @@ The Actionsheet with SectionList is a variation of the Actionsheet component tha - + @@ -1051,3 +1036,216 @@ The Actionsheet with SectionList is a variation of the Actionsheet component tha }} /> + +### File Upload with Actionsheet + + + setShowActionsheet(!showActionsheet); + return ( + <> + + + + + + + + + + + Upload your latest resume + + JPG, PDF, PNG supported + + + + + + + + No files uploaded yet + + + + + + + + + ); + } + `, + transformCode: (code) => { + return transformedCode(code, 'function', 'App'); + }, + scope: { + Actionsheet, + ActionsheetBackdrop, + ActionsheetContent, + ActionsheetDragIndicator, + ActionsheetDragIndicatorWrapper, + ActionsheetItem, + ActionsheetItemText, + ActionsheetSectionList, + ActionsheetSectionHeaderText, + ButtonGroup, + Button, + ButtonText, + Wrapper, + HStack, + VStack, + Box, + Heading, + Text, + Icon, + CloseIcon, + UploadCloud, + Pressable + }, + argsType: {}, + }} + /> + + +{/* ### Actionsheet with CTA + + + setShowActionsheet(!showActionsheet); + return ( + <> + + + + + + + + + + See what all new features are available in this updated + + + + + + + + + + + + + Simplified navigation + + + Usage of app was never that easy: all important things at your + fingertips + + + + + + + + + Special offer + + Get new offers and discounts every week right in the app + + + + + + + + + New cashback + + Get daily cashback from every purchase you make and even more + when you shop at our partners + + + + + + + + + ); + } + `, + transformCode: (code) => { + return transformedCode(code, 'function', 'App'); + }, + scope: { + Actionsheet, + ActionsheetBackdrop, + ActionsheetContent, + ActionsheetDragIndicator, + ActionsheetDragIndicatorWrapper, + ActionsheetItem, + ActionsheetIcon, + ActionsheetItemText, + ActionsheetSectionList, + ActionsheetSectionHeaderText, + Button, + ButtonText, + Wrapper, + HStack, + VStack, + Box, + Text, + Icon, + CloseIcon, + Send, + Percent, + DollarSign, + Pressable + }, + argsType: {}, + }} + /> + */} diff --git a/example/storybook-nativewind/src/components/Actionsheet/index.nw.storiesold.mdx b/example/storybook-nativewind/src/components/Actionsheet/index.nw.storiesold.mdx deleted file mode 100644 index fbeaab145..000000000 --- a/example/storybook-nativewind/src/components/Actionsheet/index.nw.storiesold.mdx +++ /dev/null @@ -1,572 +0,0 @@ ---- -title: Actionsheet | gluestack-ui | Installation, Usage, and API - -description: The Actionsheet component presents a set of options to the user, overlaid on top of the app's content, allowing them to take quick actions without leaving the current page or view. - -pageTitle: Actionsheet - -pageDescription: The Actionsheet component presents a set of options to the user, overlaid on top of the app's content, allowing them to take quick actions without leaving the current page or view. - -showHeader: true - -tag: beta ---- - -import { Meta } from '@storybook/addon-docs'; - - - -import { - Actionsheet, - ActionsheetBackdrop, - ActionsheetContent, - ActionsheetDragIndicator, - ActionsheetDragIndicatorWrapper, - ActionsheetItem, - ActionsheetItemText, - ActionsheetIcon, - ActionsheetScrollView, - ActionsheetVirtualizedList, - ActionsheetFlatList, - ActionsheetSectionList, - ActionsheetSectionHeaderText, - Button, - ButtonText, - Box, -} from './Actionsheet'; -import { - VStack, - Input, - InputIcon, - InputSlot, - InputField, - FormControl, - FormControlLabel, - FormControlLabelText, - FormControlHelper, - FormControlHelperText, - HStack, - KeyboardAvoidingView, - Platform, -} from '@gluestack-ui/themed'; -import { LeadingIcon, IconRoot } from '@gluestack-ui/themed'; -import { Image, Text } from '@gluestack-ui/themed'; -import { Icon, TrashIcon, ShareIcon } from '@gluestack-ui/themed'; -import { PlayIcon, FavouriteIcon, CloseIcon } from '@gluestack-ui/themed'; -import { transformedCode } from '../../utils'; -import { - AppProvider, - CodePreview, - Table, - TableContainer, - InlineCode, - AddIcon, - InfoIcon, - Alert, -} from '@gluestack/design-system'; -import { config } from '@gluestack-ui/config'; -import Wrapper from '../../core-components/nativewind/Wrapper'; -import { CollapsibleCode } from '@gluestack/design-system'; - -This is an illustration of **Actionsheet** component. - -< Wrapper config = { config } > - setShowActionsheet(!showActionsheet); - return ( - - - - - - - - - - Delete - - - Share - - - Play - - - Favourite - - - Cancel - - - - - ); -} -`, - transformCode: (code) => { - return transformedCode(code, 'function', 'App'); - }, - scope: { - Button, - ButtonText, - ButtonText, - Actionsheet, - ActionsheetBackdrop, - ActionsheetContent, - ActionsheetDragIndicator, - ActionsheetDragIndicatorWrapper, - ActionsheetItem, - ActionsheetItemText, - Wrapper, - Box, - }, - } -} -/> - - -
- -## Installation - -### Step 1: Install the following dependencies: - -```bash - -npm i @gluestack-ui/actionsheet - -``` - -### Step 2: Copy and paste the following code into your project. - - - -```jsx -%%-- File: core-components/nativewind/actionsheet/index.tsx --%% -``` - - - -### Step 3: Update the import paths to match your project setup. - -## API Reference - -To use this component in your project, include the following import statement in your file. - -```jsx -import { Actionsheet } from '@/components/ui/actionsheet'; -``` - -```jsx -export default () => ( - - - - - - - - - - - -); -``` - -### Component Props - -This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration. - -#### Actionsheet - -It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component. - - - - - - - - Prop - - - Type - - - Default - - - Description - - - - - - - - isOpen - - - - boolean - - - - - - - {`If true, the Actionsheet will open. Useful for controllable state behavior.`} - - - - - - onClose - - - - {`() => any`} - - - - - - - - {`Callback invoked when the Actionsheet is closed.`} - - - - - - - onOpen - - - - {`() => any`} - - - - - - - - {`Callback invoked when the Actionsheet is opened.`} - - - - - - - useRNModal - - - - boolean - - - false - - - {`If true, renders react-native native modal.`} - - - - - - defaultIsOpen - - - - boolean - - - - - - - {`Specifies the default open state of the Actionsheet`} - - - - - - initialFocusRef - - - - {`React.RefObject`} - - - - - - - {`The ref of element to receive focus when the Actionsheet opens.`} - - - - - - finalFocusRef - - - - {`React.RefObject`} - - - - - - - {`The ref of element to receive focus when the Actionsheet closes`} - - - - - - closeOnOverlayClick - - - - boolean - - - - - - - {`If true, the Actionsheet will close when the overlay is clicked.`} - - - - - - isKeyboardDismissable - - - - boolean - - - - - - - {`If true, the keyboard can dismiss the Actionsheet`} - - - - - - trapFocus - - - - boolean - - - {`true`} - - - {`If true, creates a focus scope containing all elements within the Actionsheet content.`} - - - - - - children - - - - any - - - - - - - {`The content to display inside the Actionsheet`} - - - - - - snapPoints - - - - {`Array`} - - - {`[50]`} - - - - {`The snap points for the Actionsheet The Actionsheet will snap to the point closest to its current position. The default value is 50% of the screen height. The value should be between 0 and 100. Currently, only one snap point is supported. We plan to support multiple snap points in the future.`} - - - - -
-
-
- -#### ActionsheetBackdrop - -It is React Native's [Pressable](https://reactnative.dev/docs/pressable) component, created using [@legendapp/motion's](https://legendapp.com/open-source/motion/) `createMotionAnimatedComponent` function to add animation to the component. You can use any declarative animation library you prefer. - -#### ActionsheetContent - -It inherits all the properties of [@legendapp/motion's](https://legendapp.com/open-source/motion/) [Motion.View](https://legendapp.com/open-source/motion/overview/) component. With this Actionsheet component, you have the flexibility to use any declarative animation library that suits your needs. - -**Descendants Styling Props** -Props to style child components. - - - - - - - - Sx Prop - - - Description - - - - - - - - _sectionHeaderText - - - - {`Prop to style ActionsheetSectionHeaderText Component`} - - - -
-
-
- -#### ActionsheetDragIndicatorWrapper - -It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component. - -#### ActionsheetDragIndicator - -It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component. - -#### ActionsheetItem - -It inherits all the properties of React Native's [Pressable](https://reactnative.dev/docs/pressable) component. - -**Descendants Styling Props** -Props to style child components. - - - - - - - - Sx Prop - - - Description - - - - - - - - _text - - - - {`Prop to style ActionsheetItemText Component`} - - - - - - _icon - - - - {`Prop to style ActionsheetIcon Component`} - - - -
-
-
- -#### ActionsheetItemText - -It inherits all the properties of React Native's [Text](https://reactnative.dev/docs/text) component. - -#### ActionsheetIcon - -It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component. - -#### ActionsheetScrollView - -It inherits all the properties of React Native's [ScrollView](https://reactnative.dev/docs/scrollview) component. - -#### ActionsheetVirtualizedList - -It inherits all the properties of React Native's [VirtualizedList](https://reactnative.dev/docs/virtualizedlist) component. - -#### ActionsheetFlatList - -It inherits all the properties of React Native's [FlatList](https://reactnative.dev/docs/flatlist) component. - -#### ActionsheetSectionList - -It inherits all the properties of React Native's [SectionList](https://reactnative.dev/docs/sectionlist) component. - -#### ActionsheetSectionHeaderText - -It inherits all the properties of React Native's [Text](https://reactnative.dev/docs/text) component. - -> Note: While our Actionsheet component supports both ActionsheetScrollView and ActionsheetVirtualizedList, we recommend using VirtualizedList for better performance on large lists of items. The ScrollView option may cause performance issues on lists with many items. - -### Features - -- Actionsheet has aria-modal set to true. -- Actionsheet has role set to dialog. -- When the Actionsheet opens, focus is trapped within it. -- Pressing Esc closes the Actionsheet -- Clicking on the overlay closes the Actionsheet -- Scrolling is blocked on the elements behind the Actionsheet - -### Accessibility - -We have outlined the various features that ensure the Actionsheet component is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards. - -#### Keyboard - -- `Tab + Enter`: Triggers the actionsheet action. - -### Screen Reader - -- VoiceOver: When the actionsheet is focused, the screen reader will announce the button group . - -## Spec Doc - -Explore the comprehensive details of the Actionsheet in this document, including its implementation details, checklist, and potential future additions. Dive into the thought process behind the component and gain insights into its development journey. - -