### Implementing Conditional Spotlight Targets with useSpotlight (JSX) Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/onboardingSpotlight.md This React component demonstrates how to create a spotlight tour where the steps are dynamically determined based on whether their associated targets are rendered. It uses the `useSpotlight` hook to access `isTargetRendered`, filtering the list of potential spotlight steps before rendering the active one. Dependencies include React and several components from the @atlaskit library, particularly `@atlaskit/onboarding`. The example includes buttons that serve as targets and controls to start the tour and toggle the visibility of one target. ```jsx import React, { useState } from 'react'; import ButtonGroup from '@atlaskit/button/button-group'; import Button, { IconButton } from '@atlaskit/button/new'; import CommentAddIcon from '@atlaskit/icon/glyph/media-services/add-comment'; import CopyIcon from '@atlaskit/icon/glyph/copy'; import FullscreenEnterIcon from '@atlaskit/icon/glyph/vid-full-screen-on'; import { Spotlight, SpotlightManager, SpotlightTarget, SpotlightTransition, useSpotlight, } from '@atlaskit/onboarding'; import { N0 } from '@atlaskit/theme/colors'; import { token } from '@atlaskit/tokens'; const SpotlightWithConditionalTargets = () => { const [active, setActive] = useState(null); const [isSecondTargetVisible, setIsSecondTargetVisible] = useState(true); const { isTargetRendered } = useSpotlight(); const start = () => setActive(0); const next = () => setActive((active || 0) + 1); const back = () => setActive((active || 0) - 1); const end = () => setActive(null); const renderActiveSpotlight = () => { if (active == null) { return null; } const spotlights = [ { target: 'comment', element: ( next(), text: 'Next', }, { onClick: () => end(), text: 'Dismiss', appearance: 'subtle' }, ]} heading="Add a comment" target="comment" key="comment" targetRadius={3} targetBgColor={N0} > Quickly add a comment to the issue. ), }, { target: 'copy', element: ( next(), text: 'Next' }, { onClick: () => back(), text: 'Go back', appearance: 'subtle' }, { onClick: () => end(), text: 'Dismiss', appearance: 'subtle' }, ]} heading="Copy code" target="copy" key="copy" targetRadius={3} targetBgColor={N0} > Trying to bring one of our components into your project? Click to copy the example code, then go ahead paste it in your editor. ), }, { target: 'expand', element: ( end(), text: 'OK' }, { onClick: () => back(), text: 'Go back', appearance: 'subtle' }, ]} heading="Expand to full screen" target="expand" key="expand" targetRadius={3} targetBgColor={N0} > For a focused view of the example, you can expand to full screen. ), }, ] .filter(({ target }) => isTargetRendered(target)) .map(({ element }) => element); return spotlights[active]; }; return ( <> {isSecondTargetVisible && ( )} {/* eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766 */}
{renderActiveSpotlight()} ); }; export default function SpotlightWithConditionalTargetsExample() { return ( ); } ``` -------------------------------- ### Install Project Dependencies (Shell) Source: https://github.com/jjcall/ads-docs-mirror/blob/main/README.md Installs the necessary Node.js dependencies for the project using npm. ```Shell npm install ``` -------------------------------- ### Example Implementation of Delayed and Fading Spinners Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/spinner.md This code provides a comprehensive example demonstrating how to use the @atlaskit/spinner component with the delay prop and how to integrate it with @atlaskit/motion components like FadeIn and ExitingPersistence for smooth transitions. It includes a context for managing delay values and a Harness component to wrap different spinner usage examples (basic delayed spinner and cross-fading spinner/content). ```jsx /** * @jsxRuntime classic * @jsx jsx */ import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react'; import { css, jsx } from '@compiled/react'; import Avatar from '@atlaskit/avatar'; import Button from '@atlaskit/button/new'; import { Label } from '@atlaskit/form'; import { ExitingPersistence, FadeIn } from '@atlaskit/motion'; import Select, { type ValueType } from '@atlaskit/select'; import Spinner from '@atlaskit/spinner'; import { token } from '@atlaskit/tokens'; type Delays = { spinner: number; content: number; }; const DelayContext = React.createContext({ spinner: 0, content: 0 }); type Phase = 'stopped' | 'loading' | 'ready'; const layoutStyles = css({ display: 'grid', justifyContent: 'center', gridTemplateColumns: 'repeat(auto-fit, minmax(0, 300px))', marginBlockStart: token('space.400', '32px'), }); const controlContainerStyles = css({ display: 'flex', maxWidth: 300, margin: '0 auto', gap: token('space.100', '8px'), flexDirection: 'column', }); const columnStyles = css({ display: 'flex', alignItems: 'center', flexDirection: 'column', textAlign: 'center', }); const columnInfoStyles = css({ minHeight: 70 }); const loadingContainerStyles = css({ display: 'flex', width: 200, height: 200, alignItems: 'center', justifyContent: 'center', }); const spinnerStyles = css({ position: 'absolute' }); function Harness({ children, title, description, }: { children: (phase: Phase, delays: Delays) => React.ReactElement; title: string; description: string; }) { const [phase, setPhase] = useState('stopped'); const delays: Delays = useContext(DelayContext); useEffect( function onPhaseChange() { if (phase === 'loading') { const id = window.setTimeout(() => setPhase('ready'), delays.content); return () => window.clearTimeout(id); } }, [delays.content, phase], ); return (

{title}

{description}

{children(phase, delays)}
); } function Basic() { return ( {(phase: Phase, delays: Delays) => ( {phase === 'ready' && } {phase === 'loading' && ( )} )} ); } function CrossFade() { return ( {(phase: Phase, delays: Delays) => ( {phase === 'ready' && ( {(props) => ( )} )} {phase === 'loading' && ( {(props) => ( )} )} )} ); } type Option = { value: string; label: string }; const contentDelayOptions: Option[] = [ { value: '10', label: 'Content load time: tiny (10ms)' }, { value: '50', label: 'Content load time: small (50ms)' }, { value: '100', label: 'Content load time: medium (100ms)' }, { value: '500', label: 'Content load time: long (500ms)' }, ``` -------------------------------- ### Install Atlaskit Primitives Package Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/responsiveBreakpoints.md Installs the @atlaskit/primitives package using Yarn, which provides access to design system primitives including breakpoints and media queries. ```Shell yarn add @atlaskit/primitives ``` -------------------------------- ### Example using useCustomSkipLink with PageLayout Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/pageLayout.md This example demonstrates how to use the `useCustomSkipLink` hook within a React application using `@atlaskit/page-layout`. It shows linking to an element inside the layout (`ListExample`) with dynamic ID/position updates, and linking to elements outside the layout (`#intro-section`, `#external-footer`) by calling the hook from a component rendered within `PageLayout`. It sets up a basic page structure with various PageLayout slots. ```jsx /** * @jsxRuntime classic * @jsx jsx */ import { useState } from 'react'; // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 import { jsx } from '@emotion/react'; import { Banner, Content, LeftSidebarWithoutResize, Main, PageLayout, RightPanel, TopNavigation, useCustomSkipLink, } from '@atlaskit/page-layout'; import { token } from '@atlaskit/tokens'; import { SlotLabel, SlotWrapper } from '../common'; const baseId = 'list-example'; const ListExample = () => { const skipLinkCount = document.querySelectorAll('[data-skip-link-wrapper] a').length; const [id, setId] = useState(baseId); const [position, setPosition] = useState(2); useCustomSkipLink(id, 'List example', position); const moveDown = () => { setPosition((pos) => Math.min(pos + 1, skipLinkCount)); }; const moveUp = () => { setPosition((pos) => Math.max(pos - 1, 0)); }; const changeId = () => { setId(`${baseId}${Date.now()}`); }; return (
  1. This list is an example of an element that you can skipped to that is nested inside{' '} the PageLayout component using the useCustomSkipLink hook.
  2. Current position of List example skip link: {position}
  3. Current id: {id}
); }; // Registering custom skip links // whose targets live outside PageLayout const RegisterCustomSkipLinks = () => { useCustomSkipLink('external-footer', 'External Footer', 7); useCustomSkipLink('intro-section', 'Intro section', 0); return null; }; const BasicGrid = () => { return (

This section isn't part of PageLayout, but you can still use skip links to jump to it with the `useCustomSkipLink` hook that is exported from PageLayout.

Product Navigation Space Navigation
Main Content

Visit the first focusable element on the page to see the skip links menu

Help Panel

It's also possible to

This footer isn't part of PageLayout, but you can still use skip links to jump to it with the `useCustomSkipLink` hook that is exported from PageLayout.
); }; export default BasicGrid; ``` -------------------------------- ### Implementing Integrated Page Layout with Atlassian Navigation and Side Navigation - JSX Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/pageLayout.md This snippet provides a comprehensive example of building a page layout using Atlassian UI components. It demonstrates the composition of PageLayout with TopNavigation, LeftSidebar, and Main content areas, integrating AtlassianNavigation for the top bar and SideNavigation for the left sidebar. It includes helper components for the navigation elements like product home, create button, and help popup. ```jsx /** * @jsxRuntime classic * @jsx jsx */ import { useState } from 'react'; // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 import { jsx } from '@emotion/react'; import { AtlassianNavigation, Create, Help, PrimaryButton, ProductHome, } from '@atlaskit/atlassian-navigation'; import noop from '@atlaskit/ds-lib/noop'; import { ConfluenceIcon, ConfluenceLogo } from '@atlaskit/logo'; import { ButtonItem, MenuGroup, Section } from '@atlaskit/menu'; import { Content, LeftSidebar, Main, PageLayout, TopNavigation } from '@atlaskit/page-layout'; import Popup from '@atlaskit/popup'; import { Header, NavigationHeader, NestableNavigationContent, NestingItem, SideNavigation, } from '@atlaskit/side-navigation'; import { SlotLabel, SlotWrapper } from '../common'; export default function ProductLayout() { return (
Main Content
); } function TopNavigationContents() { return ( Item 1, Item 2, Item 3, Item 4, ]} renderProductHome={ProductHomeExample} renderCreate={DefaultCreate} renderHelp={HelpPopup} /> ); } const SideNavigationContent = () => { return (
Sidebar Header
Item 1 Item 2
); }; /* * Components for composing top and side navigation */ export const DefaultCreate = () => ( ); const ProductHomeExample = () => ( ); export const HelpPopup = () => { const [isOpen, setIsOpen] = useState(false); const onClick = () => { setIsOpen(!isOpen); }; const onClose = () => { setIsOpen(false); }; return ( ( )} /> ); }; const HelpPopupContent = () => (
Item 1 Item 2 Item 3 Item 4
Item 5 Item 6
); ``` -------------------------------- ### React/JSX Example of Atlassian UI Component Layering Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/portal.md This snippet provides a comprehensive example of how to integrate multiple Atlassian UI components that rely on portalling and layering. It includes components like ModalDialog, InlineDialog, Spotlight, Flag, and Tooltip, demonstrating their correct rendering order and interaction within a complex UI structure. Dependencies include various packages from `@atlaskit/*` and `@emotion/react` for styling. ```jsx /** * @jsxRuntime classic * @jsx jsx */ import { Fragment, type ReactNode, useState } from 'react'; // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 import { css, jsx } from '@emotion/react'; import Button from '@atlaskit/button/new'; import Flag, { FlagGroup } from '@atlaskit/flag'; import EmojiIcon from '@atlaskit/icon/glyph/emoji'; import InlineDialog from '@atlaskit/inline-dialog'; import ModalDialog, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition, } from '@atlaskit/modal-dialog'; import { Spotlight, SpotlightManager, SpotlightTarget, SpotlightTransition, } from '@atlaskit/onboarding'; import { token } from '@atlaskit/tokens'; import Tooltip from '@atlaskit/tooltip'; const tooltipContainerStyles = css({ backgroundColor: token('color.background.neutral'), }); const TooltipButton = ({ children, onClick, id, }: { children: ReactNode; onClick: () => void; id?: string; }) => (
); const spotlightContainerStyles = css({ display: 'flex', padding: token('space.300'), justifyContent: 'space-between', }); type SpotlightProps = { stepOne: ReactNode; stepTwo: ReactNode; stepThree: ReactNode; isOpen: boolean; onFinish: () => void; }; const ThreeStepSpotlight = (props: SpotlightProps) => { const [step, setStep] = useState(1); const { stepOne, stepTwo, stepThree, isOpen, onFinish } = props; const next = () => { const nextStep = step + 1; if (nextStep > 3) { setStep(1); onFinish(); } else { setStep(nextStep); } }; return (
{stepOne} {stepTwo} {stepThree}
{isOpen && ( )}
); }; type ModalProps = { onClose: () => void; }; const Modal = (props: ModalProps) => { const [onboardingOpen, setOnboardingOpen] = useState(false); const [inlineOpen, setInlineOpen] = useState(false); const [flags, setFlags] = useState([]); const toggleOnboarding = (onboardingOpen: boolean) => setOnboardingOpen(onboardingOpen); const toggleInline = (inlineOpen: boolean) => setInlineOpen(inlineOpen); const addFlag = () => setFlags([flags.length, ...flags]); const removeFlag = (id: number | string) => setFlags(flags.filter((v) => v !== id)); const { onClose } = props; return ( Modal dialog

This dialog has three great features:

toggleOnboarding(false)} stepOne={ toggleOnboarding(true)} id={'showOnboardingBtn'}> Show onboarding } stepTwo={ toggleInline(!inlineOpen)}> Show an inline dialog } stepThree={ addFlag()} id={'showFlagBtn'}> Show a flag } />
removeFlag(id)}> {flags.map((id) => ( } title={`${id + 1}: Whoa a new flag!`} /> ))}
); }; const PortalComplexLayeringExample = () => { const [modals, setModals] = useState([]); return ( {modals.map((id: number) => ( setModals(modals.filter((i: number) => i !== id))} /> ))} setModals([1])}> Open Dialog ); }; export default PortalComplexLayeringExample; ``` -------------------------------- ### Rendering an Integration Layout with Atlassian UI Components Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/navigationSystem.md This React functional component `IntegrationLayoutExample` demonstrates how to construct a typical application layout using components from `@atlassian/navigation-system` and `@atlaskit`. It includes a top bar with actions, a side navigation panel, and a main content area, managing panel visibility and settings popup state using `useReducer`. It serves as a comprehensive example of integrating various UI elements like buttons, menus, popups, and navigation items within a structured layout. ```jsx import React, { useReducer } from 'react'; import Breadcrumbs, { BreadcrumbsItem } from '@atlaskit/breadcrumbs'; import { IconButton } from '@atlaskit/button/new'; import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu'; import Heading from '@atlaskit/heading'; import CloseIcon from '@atlaskit/icon/glyph/cross'; import NotificationIcon from '@atlaskit/icon/glyph/notification'; import PageIcon from '@atlaskit/icon/glyph/page'; import PersonIcon from '@atlaskit/icon/glyph/person'; import ProjectIcon from '@atlaskit/icon/core/project'; import IssuesIcon from '@atlaskit/icon/glyph/issues'; import { JiraIcon, JiraLogo } from '@atlaskit/logo'; import { LinkItem, MenuGroup, Section } from '@atlaskit/menu'; import PageHeader from '@atlaskit/page-header'; import { Popup, PopupContent, PopupTrigger } from '@atlaskit/popup/experimental'; import { Box, Inline, Stack } from '@atlaskit/primitives'; import Skeleton from '@atlaskit/skeleton'; import { CreateButton, Help, NavLogo, Root, SideNav, SideNavContent, SideNavFooter, } from '@atlassian/navigation-system'; import { Aside } from '@atlassian/navigation-system/layout/aside'; import { Main } from '@atlassian/navigation-system/layout/main'; import { Panel } from '@atlassian/navigation-system/layout/panel'; import { PanelSplitter } from '@atlassian/navigation-system/layout/panel-splitter'; import { SideNavToggleButton } from '@atlassian/navigation-system/layout/side-nav'; import { TopBar } from '@atlassian/navigation-system/layout/top-bar'; import { ExpandableMenuItem, ExpandableMenuItemContent, ExpandableMenuItemTrigger, } from '@atlassian/navigation-system/side-nav/expandable-menu-item'; import { MenuLinkItem } from '@atlassian/navigation-system/side-nav/menu-link-item'; import { MenuList } from '@atlassian/navigation-system/side-nav/menu-list'; import { CommonActions, HomeActions, Search, Settings, UserActions, } from '@atlassian/navigation-system/top-nav'; export const IntegrationLayoutExample = () => { const [isPanelVisible, toggleIsPanelVisible] = useReducer((isVisible) => !isVisible, true); const [isSettingsOpen, toggleIsSettingsOpen] = useReducer((isOpen) => !isOpen, false); return ( Create {({ ref }) => } {() => (
} > General settings } > Notification settings
} > Billing
)}
Your work } > Projects Design System Give feedback
``` -------------------------------- ### Atlaskit PageLayout Server Rendering Example - JSX Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/pageLayout.md This React component demonstrates how to integrate a server-rendered element into an Atlaskit PageLayout structure. It defines styles for the server-rendered content and includes state management and toggle components to control the visibility and fixed positioning of various PageLayout slots. ```jsx /** * @jsxRuntime classic * @jsx jsx */ import { Fragment, useCallback, useState } from 'react'; // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 import { css, jsx } from '@emotion/react'; import { Banner, BANNER_HEIGHT, Content, LEFT_PANEL_WIDTH, LEFT_SIDEBAR_WIDTH, LeftPanel, LeftSidebar, Main, PageLayout, RIGHT_PANEL_WIDTH, RIGHT_SIDEBAR_WIDTH, RightPanel, RightSidebar, TOP_NAVIGATION_HEIGHT, TopNavigation, } from '@atlaskit/page-layout'; import { token } from '@atlaskit/tokens'; import { ScrollableContent, SlotLabel, SlotWrapper, Toggle, ToggleBox } from '../common'; type SlotName = | 'Banner' | 'TopNavigation' | 'LeftPanel' | 'LeftSidebar' | 'Main' | 'RightSidebar' | 'RightPanel'; const serverRenderedStyles = css({ height: 'auto', position: 'absolute', backgroundColor: token('color.background.neutral.subtle'), insetBlockEnd: 0, // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766 insetBlockStart: `calc(${TOP_NAVIGATION_HEIGHT} + ${BANNER_HEIGHT})`, // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766 insetInlineEnd: `calc(${RIGHT_PANEL_WIDTH} + ${RIGHT_SIDEBAR_WIDTH})`, // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766 insetInlineStart: `calc(${LEFT_PANEL_WIDTH} + ${LEFT_SIDEBAR_WIDTH})`, transition: 'left 300ms', }); const draggingStyles = css({ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766 [`[data-is-sidebar-dragging] &`]: { transition: 'none', }, }); const ServerRenderedPage = () => { return ( Server rendered page. Added as a sibling to Grid componenet ); }; const initialState = { isBannerShown: true, isTopNavigationShown: true, isLeftPanelShown: true, isLeftSidebarShown: true, isRightSidebarShown: true, isRightPanelShown: true, isBannerFixed: false, isTopNavigationFixed: false, isLeftPanelFixed: false, isLeftPanelScrollable: false, isLeftSidebarFixed: false, isLeftSidebarScrollable: false, isRightSidebarFixed: false, isRightSidebarScrollable: false, isRightPanelFixed: false, isRightPanelScrollable: false, }; const BasicGrid = () => { const [gridState, setGridState] = useState(initialState); const ToggleFixed = useCallback( ({ slotName }: { slotName: SlotName }) => { const gridKey = `is${slotName}Fixed` as keyof typeof gridState; return ( setGridState({ ...gridState, [gridKey]: !gridState[gridKey] })} > Toggle fixed ); }, [gridState], ); const ToggleScrollable = useCallback( ({ slotName }: { slotName: SlotName }) => { const gridKey = `is${slotName}Scrollable` as keyof typeof gridState; return ( setGridState({ ...gridState, [gridKey]: !gridState[gridKey] })} > Toggle scrollable content {gridState[gridKey] && } ); }, [gridState], ); const ToggleShown = useCallback( ({ slotName }: { slotName: SlotName }) => { const gridKey = `is${slotName}Shown` as keyof typeof gridState; return ( setGridState({ ...gridState, [gridKey]: !gridState[gridKey] })} isChecked={!gridState[gridKey]} >{`${gridState[gridKey] ? 'Hide' : 'Show'} ${slotName}`} ); }, [gridState], ); return ( {gridState.isBannerShown && ( Banner )} {gridState.isTopNavigationShown && ( TopNavigation )} {gridState.isLeftPanelShown && ( ``` -------------------------------- ### Example HTML Markup for Code Block Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/cssReset.md This HTML snippet is used within a
 block to demonstrate how multi-line code markup is rendered.

```html

Example markup snippet

Sona si Latine loqueris. Sentio aliquos togatos contra me conspirare.

``` -------------------------------- ### Demonstrating TextArea Resize Options (React/JSX) Source: https://github.com/jjcall/ads-docs-mirror/blob/main/docs/textArea.md This example shows how to use the `resize` prop on the Atlaskit `TextArea` component to control its resizing behavior. It includes examples for `auto`, `vertical`, `horizontal`, `smart` (default), and `none` resize options, wrapped within a `Box` and using `Label` from `@atlaskit/form`. ```jsx /** * @jsxRuntime classic * @jsx jsx */ import { cssMap, cx, jsx } from '@compiled/react'; import { Label } from '@atlaskit/form'; import { Box } from '@atlaskit/primitives/compiled'; import TextArea from '@atlaskit/textarea'; const wrapperStyles = cssMap({ root: { maxWidth: '500px', }, }); export default () => (