### Start Development Server Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Starts the development server for the project. ```bash turbo dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Run this command in the root of the project to install all necessary dependencies. ```bash npm install ``` -------------------------------- ### Start Storybook Server Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Launches the Storybook server for developing and viewing UI components in isolation. ```bash turbo storybook ``` -------------------------------- ### Install Turbo Globally Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Install the turbo CLI globally to conveniently run turbo commands from anywhere in your repository. ```bash npm install turbo --global ``` -------------------------------- ### DxcButton Examples Source: https://context7.com/dxc-technology/halstack-react/llms.txt Demonstrates various configurations for the DxcButton component, including different modes, semantic variants, icons, sizes, and states. ```tsx import { DxcButton, DxcFlex } from "@dxc-technology/halstack-react"; function ButtonExamples() { const handleClick = () => console.log("Button clicked"); return ( {/* Primary button (default) */} {/* Secondary and tertiary modes */} {/* Semantic variants */} {/* With icon (Material Symbol name or SVG) */} {/* Icon-only button */} {/* Size variations */} {/* Submit button for forms */} {/* Disabled state */} ); } ``` -------------------------------- ### Implementing DxcTabs with various configurations Source: https://context7.com/dxc-technology/halstack-react/llms.txt Examples showing basic usage, icon positioning, notification badges, disabled states, and event handling. ```tsx import { DxcTabs, DxcFlex } from "@dxc-technology/halstack-react"; function TabsExamples() { return ( {/* Basic tabs with content */}

Overview content goes here.

Details content goes here.

Reviews content goes here.

{/* Tabs with icons */}

Home content

Settings content

Profile content

{/* Icons on top */}

Dashboard content

Analytics content

{/* With notification badges */}

You have 5 new messages.

You have new alerts.

Archived items.

{/* With disabled tab and default active */}

Active content

This tab is active by default.

This tab is disabled.

{/* With click and hover handlers */} console.log("Tab clicked")} onHover={() => console.log("Tab hovered")} >

Check console for events.

); } ``` -------------------------------- ### Basic Setup with HalstackProvider Source: https://context7.com/dxc-technology/halstack-react/llms.txt Wrap your application with HalstackProvider to enable theming and internationalization. Customize labels and tokens as needed. ```tsx import { HalstackProvider, DxcButton, DxcTextInput } from "@dxc-technology/halstack-react"; function App() { return ( console.log("Submitted")} /> ); } ``` -------------------------------- ### DxcApplicationLayout Example Source: https://context7.com/dxc-technology/halstack-react/llms.txt Shows a full application layout implementation including header, sidenav, main content, and footer. ```tsx import { DxcApplicationLayout, DxcButton, DxcFlex, DxcHeading, DxcParagraph, } from "@dxc-technology/halstack-react"; function ApplicationLayoutExample() { return ( console.log("Logo clicked"), }} header={ } sidenav={ Navigation}> } footer={ © 2024 Company Name Privacy Policy Terms of Service } > This is the main content area of your application. The layout automatically handles responsive behavior and sidenav toggling. ); } ``` -------------------------------- ### Install Halstack React Source: https://context7.com/dxc-technology/halstack-react/llms.txt Install the Halstack React library and its peer dependencies using npm. ```bash npm install @dxc-technology/halstack-react @emotion/react @emotion/styled react react-dom ``` -------------------------------- ### DxcFlex Layout Examples Source: https://context7.com/dxc-technology/halstack-react/llms.txt Demonstrates various flexbox configurations including alignment, direction, wrapping, and nesting. ```tsx import { DxcFlex, DxcButton, DxcTextInput } from "@dxc-technology/halstack-react"; function FlexExamples() { return ( <> {/* Basic horizontal layout */} {/* Vertical layout */} {/* Space between items */} Left content Right content {/* Center content */}

Centered content

{/* Wrap items */} {Array.from({ length: 10 }, (_, i) => ( ))} {/* Different row and column gaps */} {/* Grow and shrink */} {/* Custom HTML tag */} Home About Contact {/* Nested flex containers */} Header Left Header Right Sidebar Main Content ); } ``` -------------------------------- ### DxcDialog Basic and Confirmation Examples Source: https://context7.com/dxc-technology/halstack-react/llms.txt Demonstrates how to trigger and manage DxcDialog components for general content and confirmation actions. Ensure the dialog is conditionally rendered based on state. ```tsx import { useState } from "react"; import { DxcDialog, DxcButton, DxcTextInput, DxcFlex } from "@dxc-technology/halstack-react"; function DialogExamples() { const [isOpen, setIsOpen] = useState(false); const [isConfirmOpen, setIsConfirmOpen] = useState(false); return ( <> {/* Basic dialog trigger */} setIsOpen(true)} /> setIsConfirmOpen(true)} /> {/* Basic dialog with close button */} {isOpen && ( setIsOpen(false)} onBackgroundClick={() => setIsOpen(false)} overlay >

Dialog Title

This is a dialog with content. Click the X or background to close.

setIsOpen(false)} /> { console.log("Saved!"); setIsOpen(false); }} />
)} {/* Confirmation dialog */} {isConfirmOpen && ( setIsConfirmOpen(false)} overlay >

Confirm Action

Are you sure you want to delete this item? This action cannot be undone.

setIsConfirmOpen(false)} /> { console.log("Deleted!"); setIsConfirmOpen(false); }} />
)} ); } ``` -------------------------------- ### DxcDropdown Basic and Icon Examples Source: https://context7.com/dxc-technology/halstack-react/llms.txt Demonstrates the basic usage of the DxcDropdown component and its variations with icons. The `onSelectOption` prop handles user selections. ```tsx import { DxcDropdown, DxcFlex } from "@dxc-technology/halstack-react"; function DropdownExamples() { const handleSelect = (value: string) => { console.log("Selected:", value); }; const basicOptions = [ { label: "Edit", value: "edit" }, { label: "Delete", value: "delete" }, { label: "Share", value: "share" }, ]; const iconOptions = [ { label: "Edit", value: "edit", icon: "edit" }, { label: "Delete", value: "delete", icon: "delete" }, { label: "Share", value: "share", icon: "share" }, { label: "Download", value: "download", icon: "download" }, ]; return ( {/* Basic dropdown */} {/* With icon */} {/* Icon after label */} {/* Options with icons */} {/* Without caret */} {/* Expand on hover */} {/* Disabled */} {/* Size variations */} ); } ``` -------------------------------- ### DxcTextInput Usage Examples Source: https://context7.com/dxc-technology/halstack-react/llms.txt Demonstrates various configurations of the DxcTextInput component, including controlled/uncontrolled states, validation patterns, suggestions, and visual variations. ```tsx import { useState } from "react"; import { DxcTextInput, DxcFlex } from "@dxc-technology/halstack-react"; function TextInputExamples() { const [value, setValue] = useState(""); const [error, setError] = useState(); // Static suggestions const countries = ["Spain", "France", "Germany", "Italy", "Portugal"]; // Async suggestions function const fetchSuggestions = async (searchValue: string): Promise => { const response = await fetch(`/api/search?q=${searchValue}`); const data = await response.json(); return data.results; }; return ( {/* Basic controlled input */} { setValue(value); setError(error); }} onBlur={({ value, error }) => console.log("Blur:", value, error)} error={error} helperText="Enter your full legal name" placeholder="John Doe" /> {/* Uncontrolled with default value */} {/* With validation pattern and length constraints */} { if (error) console.log("Validation error:", error); }} /> {/* With prefix and suffix */} {/* Clearable input */} {/* With static suggestions (autocomplete) */} {/* With async suggestions */} {/* With custom action */} navigator.clipboard.writeText(value), }} /> {/* Optional field */} {/* Read-only and disabled states */} {/* Size variations */} ); } ``` -------------------------------- ### Install Halstack via npm Source: https://github.com/dxc-technology/halstack-react/blob/master/README.md Use this command to add the Halstack package to your React project dependencies. ```bash npm i @dxc-technology/halstack-react ``` -------------------------------- ### DxcSlider Examples Source: https://context7.com/dxc-technology/halstack-react/llms.txt Demonstrates various configurations of the DxcSlider component, including controlled and uncontrolled states, step increments, visual aids, input integration, custom formatting, event handling, and disabled states. ```tsx import { useState } from "react"; import { DxcSlider, DxcFlex } from "@dxc-technology/halstack-react"; function SliderExamples() { const [value, setValue] = useState(50); const [volume, setVolume] = useState(75); return ( {/* Controlled slider */} setValue(newValue)} minValue={0} maxValue={100} helperText={`Current value: ${value}`} /> {/* Uncontrolled with default */} {/* With step and marks */} {/* Show limit values */} {/* Show input field */} {/* Custom label format */} `${val}%`} /> {/* Price slider with currency format */} `$${val}`} /> {/* With drag end callback */} { console.log("Final value:", finalValue); // Useful for API calls after user finishes dragging }} minValue={0} maxValue={100} /> {/* Disabled */} {/* Size variations */} ); } ``` -------------------------------- ### DxcToastsQueue and useToast Hook Examples Source: https://context7.com/dxc-technology/halstack-react/llms.txt Shows how to integrate DxcToastsQueue with the useToast hook to display various types of notifications, including default, success, warning, info, loading, and toasts with actions. The DxcToastsQueue should wrap the application. ```tsx import { DxcToastsQueue, useToast, DxcButton, DxcFlex } from "@dxc-technology/halstack-react"; // Wrap your app with DxcToastsQueue function App() { return ( ); } function ToastExamples() { const toast = useToast(); const showDefaultToast = () => { toast.default({ message: "This is a default notification", icon: "info", }); }; const showSuccessToast = () => { toast.success({ message: "Operation completed successfully!", }); }; const showWarningToast = () => { toast.warning({ message: "Please review your input before proceeding.", hideSemanticIcon: false, }); }; const showInfoToast = () => { toast.info({ message: "New updates are available.", }); }; const showLoadingToast = () => { const clearToast = toast.loading({ message: "Processing your request...", }); // Clear the loading toast after 3 seconds setTimeout(() => { clearToast?.(); toast.success({ message: "Request completed!" }); }, 3000); }; const showToastWithAction = () => { toast.info({ message: "File deleted successfully", action: { label: "Undo", icon: "undo", onClick: () => { console.log("Undo clicked"); toast.success({ message: "File restored!" }); }, }, }); }; return ( ); } ``` -------------------------------- ### Build the Library Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Use this command to build the halstack-react component library. ```bash turbo build ``` -------------------------------- ### Build Storybook Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Generates a static build of the Storybook for deployment. ```bash turbo storybook:build ``` -------------------------------- ### Implement DxcAccordion configurations Source: https://context7.com/dxc-technology/halstack-react/llms.txt Shows how to use independent and non-independent accordion modes, along with adding badges and status lights to items. ```tsx import { useState } from "react"; import { DxcAccordion, DxcBadge, DxcStatusLight } from "@dxc-technology/halstack-react"; function AccordionExamples() { const [activeIndex, setActiveIndex] = useState(0); const [multipleActive, setMultipleActive] = useState([0, 2]); return ( <> {/* Independent mode - only one panel open at a time (controlled) */} setActiveIndex(index)} >

Enter your personal information here.

Enter your payment information.

This section is disabled.

{/* Non-independent mode - multiple panels can be open (controlled) */} setMultipleActive(indexes)} margin={{ top: "large" }} >

Content for section 1

Content for section 2

Content for section 3

{/* Uncontrolled with default active */} }} >

This item has a badge.

} >

This item has a status light.

); } ``` -------------------------------- ### Run Tests Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Executes the test suite for the project. ```bash turbo test ``` -------------------------------- ### Deploy Storybook Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Deploys the Storybook to GitHub Pages. ```bash turbo storybook:deploy ``` -------------------------------- ### Implement Halstack components Source: https://github.com/dxc-technology/halstack-react/blob/master/README.md Import and use DxcButton and DxcTextInput components within a React application. ```jsx import { DxcButton, DxcTextInput } from "@dxc-technology/halstack-react"; const App = () => ( <> ); ``` -------------------------------- ### Implement DxcSelect variations Source: https://context7.com/dxc-technology/halstack-react/llms.txt Demonstrates various configurations of the DxcSelect component, including controlled and uncontrolled states, search functionality, grouped options, and virtualization. ```tsx import { useState } from "react"; import { DxcSelect, DxcFlex } from "@dxc-technology/halstack-react"; function SelectExamples() { const [singleValue, setSingleValue] = useState(""); const [multiValue, setMultiValue] = useState([]); // Simple options const simpleOptions = [ { label: "Option 1", value: "1" }, { label: "Option 2", value: "2" }, { label: "Option 3", value: "3" }, ]; // Options with icons const iconOptions = [ { label: "Home", value: "home", icon: "home" }, { label: "Settings", value: "settings", icon: "settings" }, { label: "Profile", value: "profile", icon: "person" }, ]; // Grouped options const groupedOptions = [ { label: "Fruits", options: [ { label: "Apple", value: "apple" }, { label: "Banana", value: "banana" }, { label: "Orange", value: "orange" }, ], }, { label: "Vegetables", options: [ { label: "Carrot", value: "carrot" }, { label: "Broccoli", value: "broccoli" }, { label: "Spinach", value: "spinach" }, ], }, ]; return ( {/* Basic single select (controlled) */} { setSingleValue(value); if (error) console.log("Error:", error); }} helperText="Select one option" placeholder="Select..." /> {/* Multiple select (controlled) */} setMultiValue(value)} enableSelectAll helperText="You can select multiple options" /> {/* Uncontrolled with default value */} {/* Searchable select */} {/* Searchable with startsWith mode */} {/* With icons */} {/* Grouped options */} {/* Optional select */} {/* With error state */} {/* Virtualized for large lists */} ({ label: `Option ${i + 1}`, value: String(i + 1), }))} virtualizedHeight="300px" searchable /> {/* Size variations */} ); } ``` -------------------------------- ### DxcFileInput with File Type Restriction and Preview Source: https://context7.com/dxc-technology/halstack-react/llms.txt Enables file type restriction using the `accept` prop and displays a preview of the uploaded image files. The `showPreview` prop is set to true. ```tsx import { DxcFileInput, DxcFlex } from "@dxc-technology/halstack-react"; import type { FileData } from "@dxc-technology/halstack-react"; import { useState } from "react"; function FileInputExamples() { const [files, setFiles] = useState([]); const handleFileCallback = (newFiles: FileData[]) => { // Validate files and add custom errors if needed const validatedFiles = newFiles.map((fileData) => { if (fileData.file.size > 5 * 1024 * 1024) { return { ...fileData, error: "File exceeds 5MB limit" }; } return fileData; }); setFiles(validatedFiles); }; return ( {/* With file type restriction */} ); } ``` -------------------------------- ### DxcDataGrid Basic Usage Source: https://context7.com/dxc-technology/halstack-react/llms.txt Demonstrates the basic implementation of the DxcDataGrid component with columns and rows. ```tsx import { DxcDataGrid, DxcFlex } from "@dxc-technology/halstack-react"; function DataGridExamples() { const columns = [ { key: "id", label: "ID", sortable: true }, { key: "name", label: "Name", sortable: true, resizable: true }, { key: "email", label: "Email", resizable: true }, { key: "role", label: "Role", alignment: "center" as const }, { key: "status", label: "Status", alignment: "right" as const }, ]; const rows = [ { id: 1, name: "John Doe", email: "john@example.com", role: "Admin", status: "Active" }, { id: 2, name: "Jane Smith", email: "jane@example.com", role: "User", status: "Active" }, { id: 3, name: "Bob Johnson", email: "bob@example.com", role: "User", status: "Inactive" }, { id: 4, name: "Alice Brown", email: "alice@example.com", role: "Editor", status: "Active" }, { id: 5, name: "Charlie Wilson", email: "charlie@example.com", role: "User", status: "Pending" }, ]; return ( {/* Basic data grid */} ); } ``` -------------------------------- ### Run Linter Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Executes the linter to check for code quality and potential issues. ```bash turbo lint ``` -------------------------------- ### Implement DxcRadioGroup variants Source: https://context7.com/dxc-technology/halstack-react/llms.txt Shows how to configure radio groups with controlled/uncontrolled modes, horizontal stacking, optional items, and error states. ```tsx import { useState } from "react"; import { DxcRadioGroup, DxcFlex } from "@dxc-technology/halstack-react"; function RadioGroupExamples() { const [selectedSize, setSelectedSize] = useState("medium"); const sizeOptions = [ { label: "Small", value: "small" }, { label: "Medium", value: "medium" }, { label: "Large", value: "large" }, ]; const paymentOptions = [ { label: "Credit Card", value: "credit" }, { label: "PayPal", value: "paypal" }, { label: "Bank Transfer", value: "bank", disabled: true }, ]; return ( {/* Controlled radio group */} setSelectedSize(value)} helperText="Choose your preferred size" /> {/* Uncontrolled with default */} { console.log("Selected:", value); if (error) console.log("Error:", error); }} /> {/* Row stacking (horizontal layout) */} {/* Optional with custom label */} {/* With error state */} {/* Read-only */} ); } ``` -------------------------------- ### Run Accessibility Tests Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Runs accessibility tests to ensure the components meet accessibility standards. ```bash turbo test:accessibility ``` -------------------------------- ### Implement DxcDateInput variations Source: https://context7.com/dxc-technology/halstack-react/llms.txt Demonstrates controlled and uncontrolled date inputs, custom date formats, and various states like read-only, disabled, and error handling. ```tsx import { useState } from "react"; import { DxcDateInput, DxcFlex } from "@dxc-technology/halstack-react"; function DateInputExamples() { const [date, setDate] = useState(""); return ( {/* Controlled date input */} { setDate(value); if (dateObj) { console.log("Valid date:", dateObj.toISOString()); } if (error) { console.log("Validation error:", error); } }} onBlur={({ value, error, date }) => { console.log("Blur - Value:", value, "Date:", date); }} helperText="Format: dd-MM-yyyy" /> {/* Custom date format */} {/* European format */} {/* ISO format */} {/* Uncontrolled with default */} {/* Clearable */} {/* Optional field */} {/* With error */} {/* Read-only and disabled */} {/* Size variations */} ); } ``` -------------------------------- ### DxcFileInput with Size Constraints Source: https://context7.com/dxc-technology/halstack-react/llms.txt Applies size constraints to uploaded files using `minSize` and `maxSize` props. The helper text informs the user about the allowed file size range. ```tsx import { DxcFileInput, DxcFlex } from "@dxc-technology/halstack-react"; import type { FileData } from "@dxc-technology/halstack-react"; import { useState } from "react"; function FileInputExamples() { const [files, setFiles] = useState([]); const handleFileCallback = (newFiles: FileData[]) => { // Validate files and add custom errors if needed const validatedFiles = newFiles.map((fileData) => { if (fileData.file.size > 5 * 1024 * 1024) { return { ...fileData, error: "File exceeds 5MB limit" }; } return fileData; }); setFiles(validatedFiles); }; return ( {/* With size constraints */} ); } ``` -------------------------------- ### Run Prettier Formatter Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Executes the Prettier formatter to ensure code style consistency. ```bash npm run format ``` -------------------------------- ### Run Storybook Tests Source: https://github.com/dxc-technology/halstack-react/blob/master/LOCAL.md Executes tests specifically for the Storybook environment. ```bash turbo test-storybook ```