diff --git a/example/storybook-nativewind/.storybook/preview.js b/example/storybook-nativewind/.storybook/preview.js index c67d11297f..cff2a9ea58 100644 --- a/example/storybook-nativewind/.storybook/preview.js +++ b/example/storybook-nativewind/.storybook/preview.js @@ -62,7 +62,7 @@ export const parameters = { 'Disclosure', ['Actionsheet', 'Accordion'], 'Media And Icons', - ['Avatar', 'Image'], + ['Avatar', 'Image', 'Icon'], 'Others', ['Fab'], ], diff --git a/example/storybook-nativewind/src/components-example/nativewind/Icon/index.tsx b/example/storybook-nativewind/src/components-example/nativewind/Icon/index.tsx index c85a661a4d..7fdb902658 100644 --- a/example/storybook-nativewind/src/components-example/nativewind/Icon/index.tsx +++ b/example/storybook-nativewind/src/components-example/nativewind/Icon/index.tsx @@ -1,15 +1,14 @@ import React from 'react'; import { createIcon } from '@gluestack-ui/icon'; import { Path, Svg } from 'react-native-svg'; -import { tva } from '@gluestack-ui/nativewind-utils'; -import { cssInterop } from 'nativewind'; +import { tva, cssInterop } from '@gluestack-ui/nativewind-utils'; export const UIIcon = createIcon({ Root: Svg, }); const iconStyle = tva({ - base: 'color-background-800', + base: 'color-background-800 fill-none', variants: { size: { '2xs': 'h-3 w-3', @@ -26,7 +25,17 @@ const iconStyle = tva({ }); export const Icon = React.forwardRef( - ({ fill = 'none', size, className, ...props }: any, ref) => { + ({ fill = 'none', size, className, as: AsComp, ...props }: any, ref) => { + if (AsComp) { + return ( + + ); + } return ( [0], 'Root'>; + const createIconUI = ({ ...props }: ParameterTypes) => { const UIIcon = createIcon({ Root: Svg, ...props }); @@ -240,7 +250,7 @@ const AddIcon = React.forwardRef(({ className, size, ...props }: any, ref) => { AddIcon.displayName = 'AddIcon'; export { AddIcon }; -export const UIAlertCircleIcon = createIcon({ +const UIAlertCircleIcon = createIcon({ Root: Svg, viewBox: '0 0 24 24', path: ( @@ -283,6 +293,7 @@ const AlertCircleIcon = React.forwardRef( ); AlertCircleIcon.displayName = 'AlertCircleIcon'; +export { AlertCircleIcon }; const UIArrowUpIcon = createIcon({ Root: Svg, @@ -1440,7 +1451,7 @@ GripVerticalIcon.displayName = 'GripVerticalIcon'; export { GripVerticalIcon }; -export const UIHelpCircleIcon = createIcon({ +const UIHelpCircleIcon = createIcon({ Root: Svg, viewBox: '0 0 24 24', path: ( @@ -1483,8 +1494,9 @@ const HelpCircleIcon = React.forwardRef( ); HelpCircleIcon.displayName = 'HelpCircleIcon'; +export { HelpCircleIcon }; -export const UIInfoIcon = createIcon({ +const UIInfoIcon = createIcon({ Root: Svg, viewBox: '0 0 24 24', path: ( @@ -1525,6 +1537,7 @@ const InfoIcon = React.forwardRef(({ className, size, ...props }: any, ref) => { }); InfoIcon.displayName = 'InfoIcon'; +export { InfoIcon }; const UILinkIcon = createIcon({ Root: Svg, @@ -1713,7 +1726,7 @@ MailIcon.displayName = 'MailIcon'; export { MailIcon }; -export const UIMenuIcon = createIcon({ +const UIMenuIcon = createIcon({ Root: Svg, viewBox: '0 0 24 24', path: ( @@ -1754,6 +1767,7 @@ const MenuIcon = React.forwardRef(({ className, size, ...props }: any, ref) => { }); MenuIcon.displayName = 'MenuIcon'; +export { MenuIcon }; const UIMessageCircleIcon = createIcon({ Root: Svg, @@ -1787,7 +1801,7 @@ MessageCircleIcon.displayName = 'MessageCircleIcon'; export { MessageCircleIcon }; -export const UIMoonIcon = createIcon({ +const UIMoonIcon = createIcon({ Root: Svg, viewBox: '0 0 24 24', path: ( @@ -1814,6 +1828,7 @@ const MoonIcon = React.forwardRef(({ className, size, ...props }: any, ref) => { }); MoonIcon.displayName = 'MoonIcon'; +export { MoonIcon }; const UIPaperclipIcon = createIcon({ Root: Svg, @@ -1916,7 +1931,7 @@ PlayIcon.displayName = 'PlayIcon'; export { PlayIcon }; -export const UIRemoveIcon = createIcon({ +const UIRemoveIcon = createIcon({ Root: Svg, viewBox: '0 0 24 24', path: ( @@ -1945,6 +1960,7 @@ const RemoveIcon = React.forwardRef( ); RemoveIcon.displayName = 'RemoveIcon'; +export { RemoveIcon }; const UIRepeatIcon = createIcon({ Root: Svg, @@ -2057,7 +2073,7 @@ Repeat1Icon.displayName = 'Repeat1Icon'; export { RepeatIcon, Repeat1Icon }; -export const UISearchIcon = createIcon({ +const UISearchIcon = createIcon({ Root: Svg, viewBox: '0 0 24 24', path: ( @@ -2093,6 +2109,7 @@ const SearchIcon = React.forwardRef( ); SearchIcon.displayName = 'SearchIcon'; +export { SearchIcon }; const UISettingsIcon = createIcon({ Root: Svg, @@ -2262,7 +2279,7 @@ StarIcon.displayName = 'StarIcon'; export { StarIcon }; -export const UISunIcon = createIcon({ +const UISunIcon = createIcon({ Root: Svg, viewBox: '0 0 24 24', path: ( @@ -2345,6 +2362,7 @@ const SunIcon = React.forwardRef(({ className, size, ...props }: any, ref) => { }); SunIcon.displayName = 'SunIcon'; +export { SunIcon }; const UIThreeDotsIcon = createIcon({ Root: Svg, diff --git a/example/storybook-nativewind/src/components/Icon/Icon.tsx b/example/storybook-nativewind/src/components/Icon/Icon.tsx index 8209b2fb83..78c1e8a962 100644 --- a/example/storybook-nativewind/src/components/Icon/Icon.tsx +++ b/example/storybook-nativewind/src/components/Icon/Icon.tsx @@ -1,69 +1,75 @@ import React from 'react'; -// import { -// Icon, -// AddIcon, -// AlertCircleIcon, -// ArrowUpIcon, -// ArrowDownIcon, -// ArrowRightIcon, -// ArrowLeftIcon, -// AtSignIcon, -// BellIcon, -// CalendarDaysIcon, -// CheckIcon, -// CheckCircleIcon, -// ChevronUpIcon, -// ChevronDownIcon, -// ChevronLeftIcon, -// ChevronRightIcon, -// ChevronsLeftIcon, -// ChevronsRightIcon, -// ChevronsUpDownIcon, -// CircleIcon, -// ClockIcon, -// CloseIcon, -// CloseCircleIcon, -// CopyIcon, -// DownloadIcon, -// EditIcon, -// EyeIcon, -// EyeOffIcon, -// FavouriteIcon, -// GlobeIcon, -// GripVerticalIcon, -// HelpCircleIcon, -// InfoIcon, -// LinkIcon, -// ExternalLinkIcon, -// LoaderIcon, -// LockIcon, -// MailIcon, -// MenuIcon, -// MessageCircleIcon, -// MoonIcon, -// PaperclipIcon, -// PhoneIcon, -// PlayIcon, -// RemoveIcon, -// RepeatIcon, -// Repeat1Icon, -// SearchIcon, -// SettingsIcon, -// ShareIcon, -// SlashIcon, -// StarIcon, -// SunIcon, -// ThreeDotsIcon, -// TrashIcon, -// UnlockIcon, -// createIcon, -// } from '@/components/ui/Icon'; +import { + Icon, + AddIcon, + AlertCircleIcon, + ArrowUpIcon, + ArrowDownIcon, + ArrowRightIcon, + ArrowLeftIcon, + AtSignIcon, + BellIcon, + CalendarDaysIcon, + CheckIcon, + CheckCircleIcon, + ChevronUpIcon, + ChevronDownIcon, + ChevronLeftIcon, + ChevronRightIcon, + ChevronsLeftIcon, + ChevronsRightIcon, + ChevronsUpDownIcon, + CircleIcon, + ClockIcon, + CloseIcon, + CloseCircleIcon, + CopyIcon, + DownloadIcon, + EditIcon, + EyeIcon, + EyeOffIcon, + FavouriteIcon, + GlobeIcon, + GripVerticalIcon, + HelpCircleIcon, + InfoIcon, + LinkIcon, + ExternalLinkIcon, + LoaderIcon, + LockIcon, + MailIcon, + MenuIcon, + MessageCircleIcon, + MoonIcon, + PaperclipIcon, + PhoneIcon, + PlayIcon, + RemoveIcon, + RepeatIcon, + Repeat1Icon, + SearchIcon, + SettingsIcon, + ShareIcon, + SlashIcon, + StarIcon, + SunIcon, + ThreeDotsIcon, + TrashIcon, + UnlockIcon, + createIcon, +} from '@/components/ui/Icon'; +import { HStack } from '@/components/ui/HStack'; +import { VStack } from '@/components/ui/VStack'; -// import { ChromeIcon, InstagramIcon, FacebookIcon } from 'lucide-react-native'; -import { AddIcon } from '@/components/ui/Icon'; +import { + ChromeIcon, + InstagramIcon, + FacebookIcon, + Camera, +} from 'lucide-react-native'; const IconBasic = ({ size, ...props }: any) => { - return ; - // return ; + // return ; + return ; }; IconBasic.description = @@ -71,65 +77,68 @@ IconBasic.description = export default IconBasic; -// export { -// AddIcon, -// CheckIcon, -// CloseIcon, -// InfoIcon, -// ArrowUpIcon, -// ChevronDownIcon, -// ChevronUpIcon, -// ChevronLeftIcon, -// ChevronRightIcon, -// ChevronsLeftIcon, -// ChevronsRightIcon, -// AtSignIcon, -// CheckCircleIcon, -// AlertCircleIcon, -// ChevronsUpDownIcon, -// PaperclipIcon, -// BellIcon, -// MenuIcon, -// ArrowRightIcon, -// ArrowLeftIcon, -// ArrowDownIcon, -// CalendarDaysIcon, -// MessageCircleIcon, -// CopyIcon, -// TrashIcon, -// DownloadIcon, -// GripVerticalIcon, -// EditIcon, -// MailIcon, -// LinkIcon, -// ExternalLinkIcon, -// LockIcon, -// RemoveIcon, -// MoonIcon, -// SlashIcon, -// PhoneIcon, -// HelpCircleIcon, -// RepeatIcon, -// Repeat1Icon, -// SearchIcon, -// SettingsIcon, -// LoaderIcon, -// StarIcon, -// SunIcon, -// ClockIcon, -// UnlockIcon, -// EyeIcon, -// EyeOffIcon, -// CloseCircleIcon, -// ShareIcon, -// CircleIcon, -// FavouriteIcon, -// GlobeIcon, -// ThreeDotsIcon, -// Icon, -// ChromeIcon, -// InstagramIcon, -// FacebookIcon, -// PlayIcon, -// createIcon, -// }; +export { + AddIcon, + CheckIcon, + CloseIcon, + InfoIcon, + ArrowUpIcon, + ChevronDownIcon, + ChevronUpIcon, + ChevronLeftIcon, + ChevronRightIcon, + ChevronsLeftIcon, + ChevronsRightIcon, + AtSignIcon, + CheckCircleIcon, + AlertCircleIcon, + ChevronsUpDownIcon, + PaperclipIcon, + BellIcon, + MenuIcon, + ArrowRightIcon, + ArrowLeftIcon, + ArrowDownIcon, + CalendarDaysIcon, + MessageCircleIcon, + CopyIcon, + TrashIcon, + DownloadIcon, + GripVerticalIcon, + EditIcon, + MailIcon, + LinkIcon, + ExternalLinkIcon, + LockIcon, + RemoveIcon, + MoonIcon, + SlashIcon, + PhoneIcon, + HelpCircleIcon, + RepeatIcon, + Repeat1Icon, + SearchIcon, + SettingsIcon, + LoaderIcon, + StarIcon, + SunIcon, + ClockIcon, + UnlockIcon, + EyeIcon, + EyeOffIcon, + CloseCircleIcon, + ShareIcon, + CircleIcon, + FavouriteIcon, + GlobeIcon, + ThreeDotsIcon, + PlayIcon, + Icon, + VStack, + HStack, + ChromeIcon, + InstagramIcon, + FacebookIcon, + createIcon, + Camera, +}; diff --git a/example/storybook-nativewind/src/components/Icon/index.nw.stories.mdx b/example/storybook-nativewind/src/components/Icon/index.nw.stories.mdx new file mode 100644 index 0000000000..6731ef0bb8 --- /dev/null +++ b/example/storybook-nativewind/src/components/Icon/index.nw.stories.mdx @@ -0,0 +1,230 @@ +--- +title: gluestack-ui Icon Component | Installation, Usage, and API + +description: Icons are often used to enhance the usability and accessibility of digital products by providing users with clear and intuitive visual cues. It serves as an intuitive and easily recognizable way to communicate with users. + +pageTitle: Icon + +pageDescription: Icons are often used to enhance the usability and accessibility of digital products by providing users with clear and intuitive visual cues. It serves as an intuitive and easily recognizable way to communicate with users. + +showHeader: true +--- + +import { Meta } from '@storybook/addon-docs'; + + + +import { + AddIcon, + CheckIcon, + CloseIcon, + InfoIcon, + ArrowUpIcon, + ChevronDownIcon, + ChevronUpIcon, + ChevronLeftIcon, + ChevronRightIcon, + ChevronsLeftIcon, + ChevronsRightIcon, + AtSignIcon, + CheckCircleIcon, + AlertCircleIcon, + ChevronsUpDownIcon, + PaperclipIcon, + BellIcon, + MenuIcon, + ArrowRightIcon, + ArrowLeftIcon, + ArrowDownIcon, + CalendarDaysIcon, + MessageCircleIcon, + CopyIcon, + TrashIcon, + DownloadIcon, + GripVerticalIcon, + EditIcon, + MailIcon, + LinkIcon, + ExternalLinkIcon, + LockIcon, + RemoveIcon, + MoonIcon, + SlashIcon, + PhoneIcon, + HelpCircleIcon, + RepeatIcon, + Repeat1Icon, + SearchIcon, + SettingsIcon, + LoaderIcon, + StarIcon, + SunIcon, + ClockIcon, + UnlockIcon, + EyeIcon, + EyeOffIcon, + CloseCircleIcon, + ShareIcon, + CircleIcon, + FavouriteIcon, + GlobeIcon, + ThreeDotsIcon, + PlayIcon, + Icon, + VStack, + HStack, + ChromeIcon, + InstagramIcon, + FacebookIcon, + createIcon, + Camera, +} from './Icon'; + +import { Path, Rect } from 'react-native-svg'; + +import { transformedCode } from '../../utils'; +import { + AppProvider, + CodePreview, + Table, + TableContainer, + InlineCode, +} from '@gluestack/design-system'; + +import Wrapper from '../../components-example/nativewind/Wrapper'; + +This is an illustration of **Icon** component. + +<> + + `, + transformCode: (code) => { + return transformedCode(code); + }, + scope: { + Wrapper, + Icon, + CalendarDaysIcon, + }, + argsType: { + size: { + control: 'select', + options: ['xs', 'sm', 'md', 'lg', 'xl'], + default: 'md', + }, + }, + }} + /> + + +
+ +## Installation + +### Step 1: Install the following dependencies: + +```bash + +npm i @gluestack-ui/icon + +``` + +### Step 2: Copy and paste the following code into your project. + + + ```jsx %%-- File: components-example/nativewind/Icon/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 { Icon } from '@/components/ui/Icon'; +``` + +```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. + +#### Icon + +Pre built icons provided by gluestack-ui inherits all the properties of React Native SVG's [svg](https://github.com/software-mansion/react-native-svg/tree/main/Example) component. + +The Icon components inherits all the properties that third party library provides and can be directly applied as props. + +### Features + +- support of props on any svg icon + +### Accessibility + +We have outlined the various features that ensure the Icon component is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards. + +Role: img is passed + +### Props + +Icon component is created using AsForwarder component from @gluestack-style/react. It extends all the props supported by [gluestack-ui AsForwarder](https://gluestack.io/style/docs/api/as-forwarder), [utility props](/ui/docs/styling/utility-and-sx-props) and the props mentioned below. + +#### Image + +<> + + + + + + Name + + + Value + + + Default + + + + + + + + size + + + + {'2xs | xs | sm | md | lg | xl'} + + + md + + + +
+
+ + +## Spec Doc + +Explore the comprehensive details of the Icon 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. + +