### Start the example app packager Source: https://github.com/duongdev/phosphor-react-native/blob/main/CONTRIBUTING.md Starts the development server for the example application. ```sh yarn example start ``` -------------------------------- ### Run example app on Web Source: https://github.com/duongdev/phosphor-react-native/blob/main/CONTRIBUTING.md Builds and runs the example application in a web browser. ```sh yarn example web ``` -------------------------------- ### Install dependencies Source: https://github.com/duongdev/phosphor-react-native/blob/main/CONTRIBUTING.md Run this command in the root directory to install required dependencies. ```sh yarn ``` -------------------------------- ### Installation Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/README.md Install the phosphor-react-native library along with react-native-svg for icon rendering. ```APIDOC ## Installation ```bash npm install phosphor-react-native react-native-svg ``` ``` -------------------------------- ### Run example app on Android Source: https://github.com/duongdev/phosphor-react-native/blob/main/CONTRIBUTING.md Builds and runs the example application on an Android device or emulator. ```sh yarn example android ``` -------------------------------- ### Run example app on iOS Source: https://github.com/duongdev/phosphor-react-native/blob/main/CONTRIBUTING.md Builds and runs the example application on an iOS device or simulator. ```sh yarn example ios ``` -------------------------------- ### Install Phosphor React Native Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/README.md Install the library and its peer dependency react-native-svg using npm. ```bash npm install phosphor-react-native react-native-svg ``` -------------------------------- ### Importing from 'phosphor-react-native' Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/05-module-exports.md Demonstrates how to import types, context, and example icon components from the 'phosphor-react-native' package. ```typescript import { // Types type Icon, type IconProps, type IconWeight, // Context IconContext, // Icon components (examples) HeartIcon, StarIcon, BellIcon, // ... plus 600+ additional icons } from 'phosphor-react-native'; ``` -------------------------------- ### Install phosphor-react-native dependencies Source: https://github.com/duongdev/phosphor-react-native/blob/main/README.md Install the package and its required peer dependency using yarn or npm. ```bash yarn add phosphor-react-native react-native-svg ``` ```bash npm install --save phosphor-react-native react-native-svg ``` -------------------------------- ### Size Format Examples for Icons Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/09-quick-reference.md Icons support various units for size, including numbers (logical pixels), strings without units, pixels, em, rem, points, and percentages. ```typescript // All valid size values // Number (logical pixels) // String without units // With pixel unit // Em units // Rem units // Points // Percentage ``` -------------------------------- ### Tree-Shaking Example Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/08-architecture.md Illustrates how importing only specific icons, like `HeartIcon`, allows bundlers to remove all other unused icon definitions and their associated code. ```typescript // Only Heart imported import { HeartIcon } from 'phosphor-react-native'; // Bundler can remove: // - Star icon and its defs // - Bell icon and its defs // - All other unused icons ``` -------------------------------- ### Icon Weight Selection UI Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/07-patterns-best-practices.md Create a user interface for selecting an icon's weight. This example displays an icon and a row of pressable elements, each representing a different weight. ```typescript import { useState } from 'react'; import { View, Pressable, Text } from 'react-native'; import { HeartIcon, type IconWeight } from 'phosphor-react-native'; export function WeightSelector() { const [weight, setWeight] = useState('regular'); const weights: IconWeight[] = ['thin', 'light', 'regular', 'bold', 'fill', 'duotone']; return ( {weights.map((w) => ( setWeight(w)} style={{ padding: 8, marginHorizontal: 4, backgroundColor: weight === w ? 'blue' : 'lightgray', borderRadius: 4, }}> {w} ))} ); } ``` -------------------------------- ### Install Phosphor React Native Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/09-quick-reference.md Install the Phosphor React Native library and its peer dependency react-native-svg using npm or yarn. ```bash npm install phosphor-react-native react-native-svg # or yarn add phosphor-react-native react-native-svg ``` -------------------------------- ### Render and Test an Icon Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/09-quick-reference.md Demonstrates how to render an icon component and assert its presence using testing utilities. Ensure '@testing-library/react-native' is installed for this functionality. ```typescript import { render } from '@testing-library/react-native'; import { HeartIcon } from 'phosphor-react-native'; test('renders icon', () => { const { getByTestId } = render(); const icon = getByTestId('phosphor-react-native-heart-regular'); expect(icon).toBeTruthy(); }); ``` -------------------------------- ### Color Format Examples for Icons Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/09-quick-reference.md Icons can accept colors in various formats including hex, named colors, RGB(A), and HSL. All provided formats are equivalent. ```typescript // All equivalent ways to specify colors // Hex // Hex shorthand // Named color // RGB // RGBA // HSL ``` -------------------------------- ### Generated Icon Component Optimization Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/08-architecture.md Shows an example of a generated icon component that is automatically wrapped with `React.memo`, ensuring performance benefits without manual intervention. ```typescript const I: Icon = React.memo(({ ...props }: IconProps) => ( )); ``` -------------------------------- ### Named Imports with Tree-Shaking Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/05-module-exports.md Recommended for tree-shakeable imports, this method only includes the specified icons in your bundle. This example shows importing and using HeartIcon and StarIcon. ```typescript import { HeartIcon, StarIcon } from 'phosphor-react-native'; export function IconDemo() { return ( <> ); } ``` -------------------------------- ### Interactive Icon with onPress Prop Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/04-icon-base.md Example of an interactive icon component that accepts an 'onPress' prop for handling click events. ```typescript console.log('Clicked!')} color="red" /> ``` -------------------------------- ### Build Output Structure Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/06-configuration.md Illustrates the directory structure after a successful build using 'bob build'. Shows organized output for commonjs, module, and typescript formats. ```text ``` lib/ ├── commonjs/ │ ├── index.js │ ├── index.d.ts │ ├── lib/ │ ├── icons/ │ ├── defs/ │ └── package.json ├── module/ │ ├── index.js │ ├── lib/ │ ├── icons/ │ └── defs/ └── typescript/ ├── index.d.ts ├── lib/ ├── icons/ └── defs/ ``` ``` -------------------------------- ### Demonstrate Icon Properties Usage Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/02-types.md Illustrates various ways to utilize the `IconProps` to customize icon appearance and behavior. This includes setting colors, sizes, weights, mirroring for RTL, duotone specifics, and accessibility attributes. ```typescript import { CubeIcon } from 'phosphor-react-native'; export function IconPropsDemo() { return ( <> {/* Basic color and size */} {/* Different weight styles */} {/* RTL mirrored variant */} {/* Duotone with custom secondary color and opacity */} {/* With accessibility labels and test ID */} {/* With inline styles */} ); } ``` -------------------------------- ### Basic Icon Usage Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/00-index.md Demonstrates how to import and render a basic icon with custom color and size. ```typescript import { HeartIcon } from 'phosphor-react-native'; export function FavoriteIcon() { return ; } ``` -------------------------------- ### Primary Entry Point Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/05-module-exports.md The main entry point exports all types, context, and icon components from the `phosphor-react-native` package. ```APIDOC ## Primary Entry Point **File:** `src/index.tsx` (generated) The main entry point exports all types, context, and icon components: ```typescript export { type Icon, type IconProps, IconContext, type IconWeight } from './lib'; export * from './icons/[AllIconComponents]'; ``` ``` -------------------------------- ### Icon Rendering Pipeline Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/08-architecture.md Illustrates the step-by-step process of rendering an icon component, from initial props to the final SVG output. ```markdown ↓ HeartIcon component (from src/icons/Heart.tsx) ↓ ↓ Read from IconContext for defaults ↓ Resolve props: props > context > defaults ↓ {weightsMap.get('bold')} // ``` -------------------------------- ### Publish new version Source: https://github.com/duongdev/phosphor-react-native/blob/main/CONTRIBUTING.md Uses release-it to handle version bumping and publishing to npm. ```sh yarn release ``` -------------------------------- ### Demonstrate Icon Weight Variants Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/02-types.md Shows how to render the same icon using different `IconWeight` variants. Each variant applies a distinct visual style to the icon. ```typescript import { HorseIcon } from 'phosphor-react-native'; // Each weight renders the same icon with different styles export function IconWeightDemo() { return ( <> {/* Thin lines */} {/* Light lines */} {/* Regular (default) */} {/* Bold lines */} {/* Solid filled */} {/* Two colors */} ); } ``` -------------------------------- ### Run unit tests Source: https://github.com/duongdev/phosphor-react-native/blob/main/CONTRIBUTING.md Executes the project's unit test suite. ```sh yarn test ``` -------------------------------- ### Named Exports from Main Entry Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/05-module-exports.md Demonstrates how to import various components, types, and context from the `phosphor-react-native` package. ```APIDOC ## Named Exports from Main Entry ### From 'phosphor-react-native' ```typescript import { // Types type Icon, type IconProps, type IconWeight, // Context IconContext, // Icon components (examples) HeartIcon, StarIcon, BellIcon, // ... plus 600+ additional icons } from 'phosphor-react-native'; ``` ``` -------------------------------- ### Simple Icon Weight Toggle Source: https://github.com/duongdev/phosphor-react-native/blob/main/_autodocs/07-patterns-best-practices.md Toggle the weight of an icon dynamically using React's useState hook. This example cycles through available weights on button press. ```typescript import { useState } from 'react'; import { Button } from 'react-native'; import { HeartIcon, type IconWeight } from 'phosphor-react-native'; export function WeightToggle() { const [weight, setWeight] = useState('regular'); const nextWeight = (): IconWeight => { const weights: IconWeight[] = ['thin', 'light', 'regular', 'bold', 'fill', 'duotone']; const idx = weights.indexOf(weight); return weights[(idx + 1) % weights.length]; }; return ( <>