### Basic Locale Setup Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Demonstrates the basic setup for internationalization using imported locales. This involves providing the locale data to the application's context. ```javascript import { LocaleProvider } from '@eightfold.ai/eightfold-ui'; import enUS from './locales/en-US.json'; ``` -------------------------------- ### Example Clone Command Source: https://github.com/eightfoldai/octuple/blob/main/src/CONTRIBUTING.md An example of the git clone command, showing the typical structure for cloning the Octuple repository from a personal fork. ```bash git clone https://github.com/imadev/octuple.git ``` -------------------------------- ### Multi-Language Support Setup Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/locale-configuration.md Enables multi-language support by dynamically selecting locales based on user preference. This example demonstrates switching between English, Spanish, and French. ```typescript import { ConfigProvider } from '@eightfold.ai/octuple'; import { en_US, es_ES, fr_FR } from '@eightfold.ai/octuple/lib/locale'; import { useState } from 'react'; export function App() { const [language, setLanguage] = useState('en_US'); const localeMap = { en_US, es_ES, fr_FR, }; return ( <> ); } ``` -------------------------------- ### Authentication Flow Setup Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/README.md Wrap your application with AuthGuard and ConfigProvider for authentication and configuration management. ```typescript ``` -------------------------------- ### Grid System Setup Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Import the necessary Grid, Row, and Col components from the Octuple UI library. ```typescript import Grid, { Row, Col } from '@eightfold.ai/octuple'; ``` -------------------------------- ### Layout Component Setup Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Import the main Layout component from the Octuple UI library. ```typescript import Layout from '@eightfold.ai/octuple'; ``` -------------------------------- ### Form Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md A basic example demonstrating how to use the Form component with a ref for instance methods and custom validation messages. Includes a submit handler. ```typescript import Form, { FormInstance } from '@eightfold.ai/octuple'; import { useRef } from 'react'; export function MyForm() { const formRef = useRef(null); const handleSubmit = (values) => { console.log('Form values:', values); }; return (
); } ``` -------------------------------- ### Basic Theme Setup with ConfigProvider Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-configprovider.md Configure the primary theme color for all Octuple components by passing theme options to the ConfigProvider. This snippet demonstrates a minimal setup for theme customization. ```typescript import { ConfigProvider, OcThemeName } from '@eightfold.ai/octuple'; import App from './App'; export function AppRoot() { return ( ); } ``` -------------------------------- ### Importing Locales Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Provides a code example for importing locale data. This is the first step in setting up internationalization. ```javascript import enUS from './locales/en-US.json'; import esES from './locales/es-ES.json'; // Use enUS or esES in your application ``` -------------------------------- ### SearchBox Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-select-inputs.md Example demonstrating how to use the SearchBox component for searching users. It includes state management for the query, results, and loading state, along with an asynchronous search handler. ```typescript import { SearchBox } from '@eightfold.ai/octuple'; import { useState } from 'react'; export function SearchUsers() { const [query, setQuery] = useState(''); const [results, setResults] = useState([]); const [loading, setLoading] = useState(false); const handleSearch = async (q: string) => { if (!q) { setResults([]); return; } setLoading(true); try { const response = await fetch(`/api/users/search?q=${q}`); const data = await response.json(); setResults(data); } finally { setLoading(false); } }; return ( <>
    {results.map((user) => (
  • {user.name}
  • ))}
); } ``` -------------------------------- ### Install Octuple with NPM Source: https://github.com/eightfoldai/octuple/blob/main/README.md Use this command to add the Octuple library to your project if you are using NPM as your package manager. ```bash npm install @eightfold.ai/octuple ``` -------------------------------- ### Stack Component Setup Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Import the Stack component from the Octuple UI library for flexible item arrangement. ```typescript import { Stack } from '@eightfold.ai/octuple'; ``` -------------------------------- ### Table Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Demonstrates how to use the Table component with custom columns and data. Includes basic configuration for size and pagination. ```typescript import Table, { TableSize } from '@eightfold.ai/octuple'; export function DataTable() { const columns = [ { key: 'id', title: 'ID', dataIndex: 'id', width: 100 }, { key: 'name', title: 'Name', dataIndex: 'name' }, { key: 'status', title: 'Status', dataIndex: 'status', render: (status) => }, ]; const data = [ { id: 1, name: 'Alice', status: 'Active' }, { id: 2, name: 'Bob', status: 'Pending' }, ]; return ( ); } ``` -------------------------------- ### Install Octuple with Yarn Source: https://github.com/eightfoldai/octuple/blob/main/README.md Use this command to add the Octuple library to your project if you are using Yarn as your package manager. ```bash yarn add @eightfold.ai/octuple ``` -------------------------------- ### Multi-Language Application Setup Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/README.md Configure multi-language support using ConfigProvider and locale data. Allows runtime language switching. ```typescript ``` -------------------------------- ### Basic Pill Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Demonstrates how to render a list of interactive pills, where each pill can be removed. This example uses the useState hook to manage the list of tags. ```typescript import { Pill, PillSize } from '@eightfold.ai/octuple'; import { useState } from 'react'; export function TagList() { const [tags, setTags] = useState(['React', 'TypeScript', 'Octuple']); return (
{tags.map((tag) => ( setTags(tags.filter((t) => t !== tag))} /> ))}
); } ``` -------------------------------- ### RangePicker Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Provides a usage example for the RangePicker component, which is designed for selecting a start and end date. This is useful for defining time spans. ```javascript import { RangePicker } from '@eightfold.ai/eightfold-ui'; ``` -------------------------------- ### Basic theme setup for ConfigProvider Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Minimal configuration for the ConfigProvider to set up a basic theme. This involves importing ConfigProvider and passing a theme object. ```jsx import { ConfigProvider } from "@octo/config"; import { theme } from "@octo/theme"; {/* Application content */} ``` -------------------------------- ### Creating Custom Locales Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Provides guidance on creating entirely new locale files from scratch. This involves defining the structure and populating it with translations. ```json { "greeting": "Bonjour", "farewell": "Au revoir", "validation": { "required": "Ce champ est requis." } } ``` -------------------------------- ### useMatchMedia Hook Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Demonstrates the usage of the `useMatchMedia` hook for detecting responsive breakpoints. This hook is essential for building adaptive UIs. ```javascript import { useMatchMedia } from '@eightfold.ai/eightfold-ui'; const isMobile = useMatchMedia('(max-width: 768px)'); // Use isMobile to conditionally render components or apply styles ``` -------------------------------- ### Run Storybook Development Server Source: https://github.com/eightfoldai/octuple/blob/main/CLAUDE.md Use this command to start the Storybook development server. It runs on port 2022. ```bash yarn storybook ``` -------------------------------- ### Tooltip Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Shows how to implement a Tooltip component that displays information when hovering over a trigger element. ```typescript import { Tooltip, TooltipTheme } from '@eightfold.ai/octuple'; import { HelpIcon } from '@eightfold.ai/octuple'; export function HelpButton() { return ( ); } ``` -------------------------------- ### Progress Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Demonstrates a dynamic Progress bar that updates its percentage and status based on state. ```typescript import Progress, { ProgressSize } from '@eightfold.ai/octuple'; export function FileUpload() { const [uploadPercent, setUploadPercent] = useState(0); return ( ); } ``` -------------------------------- ### Usage Example for Snackbar Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Provides an example of using the snack function within a component to display success or error messages after an asynchronous operation. ```typescript import { snack } from '@eightfold.ai/octuple'; export function DeleteButton() { const handleDelete = async () => { try { await deleteItem(); snack({ message: 'Item deleted successfully', type: 'success', duration: 3000, }); } catch (error) { snack({ message: 'Failed to delete item', type: 'error', }); } }; return ; } ``` -------------------------------- ### Locale Storage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Demonstrates how to persist the user's selected language preference using local storage. This ensures the chosen locale is remembered across sessions. ```javascript import { useLocale } from '@eightfold.ai/eightfold-ui'; const { locale, setLocale } = useLocale(); const handleLanguageChange = (newLocale) => { setLocale(newLocale); localStorage.setItem('userLocale', JSON.stringify(newLocale)); }; // On app load, check localStorage for 'userLocale' and set it if found. ``` -------------------------------- ### Runtime Language Switching Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Shows how to dynamically switch the application's language at runtime. This typically involves updating the locale context. ```javascript import { useLocale } from '@eightfold.ai/eightfold-ui'; import enUS from './locales/en-US.json'; import esES from './locales/es-ES.json'; const { setLocale } = useLocale(); const switchLanguage = (lang) => { if (lang === 'en') setLocale(enUS); if (lang === 'es') setLocale(esES); }; ``` -------------------------------- ### DialogHelper Confirm Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Shows how to use the DialogHelper.confirm function to display a confirmation dialog with custom text and callbacks. ```typescript DialogHelper.confirm({ title: 'Delete Item?', content: 'This action cannot be undone.', okText: 'Delete', onOk: () => deleteItem(), }); ``` -------------------------------- ### Usage Example for Modal Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Demonstrates how to use the Modal component to create a confirmation dialog. It includes state management for visibility and basic OK/Cancel actions. ```typescript import { Modal, ModalSize } from '@eightfold.ai/octuple'; import { useState } from 'react'; export function ConfirmDialog() { const [visible, setVisible] = useState(false); return ( <> { console.log('Confirmed'); setVisible(false); }} onCancel={() => setVisible(false)} size={ModalSize.Medium} > Are you sure you want to proceed? ); } ``` -------------------------------- ### Skeleton Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Shows a Skeleton component used as a loading placeholder that is replaced by actual content after a delay. ```typescript import { Skeleton, SkeletonVariant } from '@eightfold.ai/octuple'; import { useState, useEffect } from 'react'; export function ContentLoader() { const [loading, setLoading] = useState(true); useEffect(() => { const timer = setTimeout(() => setLoading(false), 2000); return () => clearTimeout(timer); }, []); return loading ? ( ) : ( ); } ``` -------------------------------- ### Usage Example for hasOverflow Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/hooks-reference.md Demonstrates how to use the hasOverflow hook to conditionally render a scroll indicator. ```typescript import { hasOverflow, hasHorizontalOverflow } from '@eightfold.ai/octuple'; export function ScrollableContent() { const contentRef = useRef(null); const hasScroll = hasOverflow(contentRef.current); return (
{hasScroll && }
); } ``` -------------------------------- ### useMatchMedia Hook Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/hooks-reference.md Demonstrates how to use the useMatchMedia hook to conditionally render UI elements based on viewport size. ```typescript import { useMatchMedia, Breakpoints } from '@eightfold.ai/octuple'; export function ResponsiveLayout() { const isMediumOrLarger = useMatchMedia(Breakpoints.Medium); const isLargeScreen = useMatchMedia(Breakpoints.Large); return (
{isMediumOrLarger && }
{isLargeScreen ? : }
); } ``` -------------------------------- ### Primary Library Export Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/project-overview.md Import all components, hooks, and types from the main library entry point. This is the most common way to start using Octuple. ```typescript import { Button, Form, Select, ... } from '@eightfold.ai/octuple'; ``` -------------------------------- ### useGestures Hook Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Demonstrates the `useGestures` hook for tracking pointer gestures like tap, swipe, and pinch. This is useful for implementing interactive elements. ```javascript import { useGestures } from '@eightfold.ai/eightfold-ui'; const gestureHandlers = useGestures({ onTap: () => console.log('Tapped!'), onSwipe: (direction) => console.log(`Swiped ${direction}`), });
Interact here
``` -------------------------------- ### Date and Time Selection Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-date-time-picker.md This example shows how to select both date and time. Configure `showTime` with desired format and step intervals, and set the main `format` property accordingly. ```typescript import DatePicker from '@eightfold.ai/octuple'; import { useState } from 'react'; export function EventScheduler() { const [dateTime, setDateTime] = useState(null); return ( ); } ``` -------------------------------- ### useBoolean Hook Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Shows how to use the `useBoolean` hook for managing boolean state. It simplifies toggling and setting boolean values. ```javascript import { useBoolean } from '@eightfold.ai/eightfold-ui'; const [isOpen, toggleOpen, setOpen] = useBoolean(false); // isOpen: boolean state // toggleOpen: function to toggle the state // setOpen: function to set the state to true or false ``` -------------------------------- ### Input with Prefix and Suffix Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-select-inputs.md An example of a number input with a currency prefix and decimal suffix. Suitable for financial inputs. ```typescript import { TextInput, TextInputWidth } from '@eightfold.ai/octuple'; import { useState } from 'react'; export function CurrencyInput() { const [amount, setAmount] = useState(''); return ( ); } ``` -------------------------------- ### Basic Tabs Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Demonstrates how to set up and use the Tabs and Tab components to create tabbed content navigation. Manages active tab state using useState. ```typescript import { Tabs, Tab } from '@eightfold.ai/octuple'; import { useState } from 'react'; export function TabbedContent() { const [activeKey, setActiveKey] = useState('tab1'); return ( Overview content Details content Settings content ); } ``` -------------------------------- ### Date picker Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Example of using the DatePicker component. Requires the DatePicker component import. The component allows users to select dates. ```jsx import { DatePicker } from "@octo/input"; const MyDatePicker = () => ( console.log(date, dateString)} /> ); ``` -------------------------------- ### Snackbar Serve Example (v2.54+) Source: https://github.com/eightfoldai/octuple/blob/main/src/components/Snackbar/CLAUDE.md Demonstrates how to serve a snackbar with the `closable` prop set to true. Focus is no longer automatically moved to the snackbar in newer versions. ```typescript // Before: Focus moved automatically snack.serve({ content: 'Message', closable: true }); // Focus would move to snackbar // After: Focus stays with user snack.serve({ content: 'Message', closable: true }); // Focus remains where it was // Screen reader still announces via role="status" ``` -------------------------------- ### useGestures Usage Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/hooks-reference.md Demonstrates how to use the useGestures hook to create a draggable element, updating its position based on pointer movement. ```typescript import { useGestures } from '@eightfold.ai/octuple'; import { useRef } from 'react'; export function DraggableElement() { const ref = useRef(null); const { deltaX, deltaY, isPointerDown } = useGestures(ref, true); return (
Drag me
); } ``` -------------------------------- ### Locale Detection Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Shows how to implement browser language detection to automatically set the user's locale. This enhances the initial user experience. ```javascript function detectUserLocale() { const browserLang = navigator.language.split('-')[0]; // Map browserLang to your available locales (e.g., 'en', 'es') // Return the appropriate locale object or a default return enUS; // Example fallback } ``` -------------------------------- ### Snackbar Event Listener Setup Source: https://github.com/eightfoldai/octuple/blob/main/src/components/Snackbar/CLAUDE.md Sets up and cleans up event listeners for serving and removing snacks, ensuring SSR safety. ```typescript useEffect(() => { if (canUseDocElement()) { document.addEventListener(SNACK_EVENTS.SERVE, addSnack); document.addEventListener(SNACK_EVENTS.EAT, removeSnack); } return () => { if (canUseDocElement()) { document.removeEventListener(SNACK_EVENTS.SERVE, addSnack); document.removeEventListener(SNACK_EVENTS.EAT, removeSnack); } }; }, []); ``` -------------------------------- ### Basic Snackbar Usage Source: https://github.com/eightfoldai/octuple/blob/main/src/components/Snackbar/CLAUDE.md Demonstrates the basic usage of the `snack.serve` method to display simple notifications. Includes examples with default settings, custom duration, and specific positioning. ```typescript import { snack } from '@eightfold/octuple'; // Simple notification snack.serve({ content: 'Hello World!' }); // With custom duration snack.serve({ content: 'This stays longer', duration: 5000 }); // With position snack.serve({ content: 'Bottom right', position: 'bottom-right' }); ``` -------------------------------- ### Merging Locales Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Demonstrates how to merge base locale data with custom locale configurations. This allows for extending existing translations without overwriting them entirely. ```javascript import { mergeLocales } from '@eightfold.ai/eightfold-ui'; import baseLocale from './locales/en-US.json'; import customLocale from './locales/en-US-custom.json'; const merged = mergeLocales(baseLocale, customLocale); ``` -------------------------------- ### Use Basic Octuple Components Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/quick-start-guide.md Import and use basic Octuple components like TextInput and Button. This example shows how to manage state for input fields. ```typescript import { Button, TextInput, Select } from '@eightfold.ai/octuple'; import { useState } from 'react'; export function MyComponent() { const [name, setName] = useState(''); return (
); } ``` -------------------------------- ### Custom hooks usage Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/DOCUMENTATION_INDEX.md Example of using custom hooks provided by the library. This demonstrates abstracting complex logic into reusable functions. ```jsx import { useFetch } from "@octo/hooks"; // Assuming a custom fetch hook const UserProfile = ({ userId }) => { const { data, loading, error } = useFetch(`/api/users/${userId}`); if (loading) return

Loading...

; if (error) return

Error: {error.message}

; return (

{data.name}

{data.email}

); }; ``` -------------------------------- ### Text Input Form Example Source: https://github.com/eightfoldai/octuple/blob/main/_autodocs/api-reference-components.md Demonstrates how to use TextInput, TextArea, and SearchBox components within a React form. Includes state management for input values. ```typescript import { TextInput, TextArea, SearchBox, TextInputSize, TextInputTheme, } from '@eightfold.ai/octuple'; import { useState } from 'react'; export function InputForm() { const [email, setEmail] = useState(''); const [message, setMessage] = useState(''); const [search, setSearch] = useState(''); return (