### Global Header Usage and Code Example Source: https://docs.guidewire.com/jutro/documentation/10.11/global-header This snippet demonstrates the basic usage and provides a code example for the Jutro Global Header component. It outlines how to integrate the header into applications within the Guidewire Cloud ecosystem. ```jsx import React from 'react'; import { GlobalHeader } from '@guidewire/jutro-design-system'; function App() { return (
{/* Main application content */}
); } ``` -------------------------------- ### Guidewire Jutro Floorplan Override Example Source: https://docs.guidewire.com/jutro/documentation/10.11/page-layouts/appfloorplan Provides an example of a `FloorPlanOverride` configuration in Guidewire Jutro, specifically disabling the right side navigation for the '/example2' path. This demonstrates how to customize individual page layouts. ```TypeScript exportconst example2PageDefinition =():FloorPlanOverride{ return{ // Configuration override for the /example2 path only showRightSide:false, matches:'/example2' } } ``` -------------------------------- ### Basic Switch Example Source: https://docs.guidewire.com/jutro/documentation/10.11/switch Demonstrates the basic usage of the Switch component with a label. The Switch component allows users to toggle between an on and off state. ```jsx ``` -------------------------------- ### Basic TooltipIcon Example Source: https://docs.guidewire.com/jutro/documentation/10.11/tooltip Shows the basic implementation of the TooltipIcon component, used when a tooltip is associated with an icon. This example requires importing React and TooltipIcon from '@jutro/components'. ```javascript import { TooltipIcon } from '@jutro/components'; import React from 'react'; export const TooltipIconBasic = () => { return ; }; ``` -------------------------------- ### useBreakpoint: Get All Returned Values Source: https://docs.guidewire.com/jutro/documentation/10.11/responsiveness This comprehensive example demonstrates retrieving all values from the `useBreakpoint` hook: `breakpointProps`, `breakpoint`, and `applyBreakpoint`. It shows how to use each of these to conditionally style and render `TextInput` components. ```javascript const{ breakpointProps: textInputPhoneProps, breakpoint, applyBreakpoint, }=useBreakpoint({ phone:{ placeholder:'Phone placeholder', label:'Phone label', className:'somePhoneClass', }, }); return( ); ``` -------------------------------- ### Basic Phase Progress Bar Example Source: https://docs.guidewire.com/jutro/documentation/10.11/progress-indicator-phase-bar This example demonstrates a static Phase Progress Bar with predefined phases and steps. It shows how to structure the `phases` array, including icons, titles, and step visitation status, to represent completed and current progress. ```jsx ``` -------------------------------- ### Typography Component Usage Examples Source: https://docs.guidewire.com/jutro/documentation/10.11/typography-component Demonstrates various ways to use the typography component with different variants and semantic tags. Includes examples for headings, body text, blockquotes, and separating visual style from semantic structure. ```html Page Title This is a paragraph of text. Form Field Label Contextual text above heading Marketing Headline This is a quoted text. Caption for an image. Inline code snippet This is an h2 that is formatted to have medium text. This is a blockquote that is formatted to have the visual weight of a heading. ``` -------------------------------- ### Render Badge Component Source: https://docs.guidewire.com/jutro/documentation/10.11/badge Demonstrates how to render the Badge component with a specified value. This is a basic usage example. ```HTML ``` -------------------------------- ### Basic Loader Example Source: https://docs.guidewire.com/jutro/documentation/10.11/loader A basic loader that displays a Guidewire branded animation until its children are ready. The children can be shown by setting the `loaded` property to `true` or by providing a `Promise`. ```HTML Incoming content ``` -------------------------------- ### Example Heading Structure Source: https://docs.guidewire.com/jutro/documentation/10.11/building-accessible-experiences Illustrates a hierarchical heading structure for clear document organization, prioritizing accessibility for screen reader users. This example demonstrates the correct nesting of heading levels from h1 to h6. ```HTML

Main Heading

Section 1

Subsection 1.1

Subsection 1.2

Section 2

Subsection 2.1

Sub-subsection 2.1.1

``` -------------------------------- ### Basic HeaderPanel Example Source: https://docs.guidewire.com/jutro/documentation/10.11/page-layouts/components/header-panel Demonstrates the basic structure of the HeaderPanel component, which wraps content to designate page header elements. It includes a sample heading within the panel. ```HTML

Sample heading text

``` -------------------------------- ### Select Dropdown Example Source: https://docs.guidewire.com/jutro/documentation/10.11/drop-downs-overall Demonstrates the implementation of a single-select dropdown component. It requires a label and initial value, and accepts SelectOption children for the available choices. ```jsx ``` -------------------------------- ### Text Input Validation Example Source: https://docs.guidewire.com/jutro/documentation/10.11/text Provides an example of implementing custom validation logic for the TextInput component. It uses the 'onChange' event and 'stateMessages' prop to handle and display validation errors. ```javascript functionTextInputValidation(){ const[validationMessages, setValidationMessages]=useState({}); const onChange =useCallback((e, newValue)=>{ if(!newValue || newValue.indexOf('a')==-1){ setValidationMessages({}); }else{ setValidationMessages({ error:['The text cannot contain `a` character'], }); } },[]); return( ); } ``` -------------------------------- ### Generic Alert Modal Example Source: https://docs.guidewire.com/jutro/documentation/10.11/modal-component Provides an example of triggering a generic Alert modal using `showAlert` from `ModalNextContext`. It includes state management to capture the modal's result and demonstrates how to configure various alert properties like status, icon, title, message, and confirm button text. ```javascript import React, { useState, useContext } from 'react'; import { ModalNextContext } from '@jutro/components'; const AlertModalExample = () => { const [result, setResult] = useState(null); const { showAlert } = useContext(ModalNextContext); async function triggerAlert() { const results = await showAlert({ status: 'info' /* status - 'info', 'warning', 'error', or 'success' */, icon: 'gw-error-outline' /* icon - optional icon class name for the icon to display to the left of the title */, title: 'Test Alert' /* title - string/IntlMessageShape for the title of the alert */, message: 'Just testing an Alert!' /* message - string/IntlMessageShape for the message to display within the alert */, confirmButtonText: 'OK' /* confirmButtonText - string/IntlMessageShape for the text to appear on the confirm button */, }); setResult(`modal result was: ${results}`); } return (
{result}
); }; ``` -------------------------------- ### Start Development Server with Live Preview Source: https://docs.guidewire.com/jutro/documentation/10.11/i18n Starts the application in live preview mode, allowing immediate reflection of code changes in the browser. Note that changes to existing source strings require a re-run of the extract-merge-pseudo cycle (`npm run i18n`) to be reflected. ```bash npm start ``` -------------------------------- ### Render InfoLabel Component Source: https://docs.guidewire.com/jutro/documentation/10.11/info-label This snippet shows how to render the InfoLabel component with basic content. It's a fundamental example of integrating the component into a UI. ```html Lorem ipsum ``` -------------------------------- ### Basic Checkbox Example Source: https://docs.guidewire.com/jutro/documentation/10.11/checkboxes Demonstrates the usage of a single Checkbox component with a label. This component can be used independently. ```HTML ``` -------------------------------- ### Jutro Unit Testing Examples Source: https://docs.guidewire.com/jutro/documentation/10.11/testing-overview Unit tests in Jutro verify the functionality of small, isolated parts of the application. Examples include checking for rendering without errors, validating metadata-based components, testing string manipulation functions, verifying callback invocations, and ensuring side effects are triggered correctly. ```javascript // Example: Check if an app renders without crashing it('should render without crashing', () => { // Assume App is your root component render(); }); // Example: Check if a metadata-based component has valid metadata it('should have valid metadata', () => { const component = render(); // Assertions for valid metadata }); // Example: Test a function that shortens strings it('should shorten long descriptions correctly', () => { const longString = 'This is a very long description that needs to be shortened.'; const maxLength = 20; const shortenedString = shortenString(longString, maxLength); expect(shortenedString.length).toBeLessThanOrEqual(maxLength); expect(shortenedString).toBe('This is a very lon...'); }); // Example: Check if a callback is called it('should call the callback function', () => { const mockCallback = jest.fn(); render(); // Simulate an event that triggers the callback // e.g., fireEvent.click(screen.getByRole('button')); expect(mockCallback).toHaveBeenCalledTimes(1); }); // Example: Check if a side effect is triggered the appropriate number of times it('should trigger side effect twice', () => { const mockSideEffect = jest.fn(); render(); expect(mockSideEffect).toHaveBeenCalledTimes(1); }); ``` -------------------------------- ### Basic Accordion Example Source: https://docs.guidewire.com/jutro/documentation/10.11/accordion Demonstrates the basic structure of an Accordion component with multiple AccordionCard items. Shows how to set titles and initial expanded states. ```HTML Test card Card initially open Test card 3 ``` -------------------------------- ### React Confirmation Modal Example Source: https://docs.guidewire.com/jutro/documentation/10.11/modal-component This React component demonstrates how to use the `showConfirm` function from `ModalNextContext` to display a generic confirmation modal. It allows customization of the modal's status, icon, title, message, and button text. The example captures the modal's result and displays it to the user. ```javascript import React, { useState, useContext } from 'react'; import { ModalNextContext } from '@jutro/components'; const ConfirmationModalExample = () => { const [result, setResult] = useState(null); const { showConfirm } = useContext(ModalNextContext); async function triggerConfirmation() { const results = await showConfirm({ status: 'info', /* status - 'info', 'warning', 'error', or 'success' */ icon: 'gw-error-outline', /* icon - optional icon class name for the icon to display to the left of the title */ title: 'Test Confirm Modal', /* title - string/IntlMessageShape for the title of the confirm modal */ message: 'Just testing a Confirmation Modal!', /* message - string/IntlMessageShape for the message to display within the confirm modal */ confirmButtonText: 'OK', /* confirmButtonText - string/IntlMessageShape for the text to appear on the confirm button */ cancelButtonText: 'Cancel', /* cancelButtonText - string/IntlMessageShape for the text to appear on the cancel button */ }); setResult(`modal result was: ${results}`); } return (
{result}
); }; ``` -------------------------------- ### Basic Tag Example Source: https://docs.guidewire.com/jutro/documentation/10.11/tags A basic tag displays a label formatted to be recognized by the reader. It's a simple string with designated styling. ```HTML ``` -------------------------------- ### Switch Component Usage Source: https://docs.guidewire.com/jutro/documentation/10.11/switch Demonstrates the basic usage of the Switch component with a label. This is a fundamental example for integrating the Switch into an application. ```jsx ``` -------------------------------- ### Basic Overflow Menu Example Source: https://docs.guidewire.com/jutro/documentation/10.11/overflow-menu Demonstrates how to create a simple overflow menu using the DropdownMenu component. The trigger is a Button that toggles the menu when clicked. ```jsx { return( ); } ``` -------------------------------- ### Set Focus on TextArea using ref in React Source: https://docs.guidewire.com/jutro/documentation/10.11/textarea This snippet demonstrates how to use the `useRef` hook in React to get a reference to a `TextArea` component. The `setFocus` function then calls the native `focus()` method on the referenced element, allowing programmatic control over the input's focus state. This is useful for guiding user interaction within forms. ```javascript exportfunction TextAreaRef(){ const textAreaRef =useRef(null); constsetFocus=(e)=>{ textAreaRef?.current?.focus(); }; return(