diff --git a/packages/ui-heading/src/Heading/v2/README.md b/packages/ui-heading/src/Heading/v2/README.md index b9aaee9d0b..2e63ebf7df 100644 --- a/packages/ui-heading/src/Heading/v2/README.md +++ b/packages/ui-heading/src/Heading/v2/README.md @@ -42,19 +42,78 @@ type: example ### AI Heading -Pre-configured and with unique styles, the `ai-headings` are used for standardized, ai-related components. +Use the `aiVariant` prop for headings of AI-related content, such as a Modal or Popover header. Use a standard Heading for all other headings. + +`stacked` and `horizontal` show the IgniteAI logo lockup before the heading text: ```js --- type: example ---
- Nutrition Facts - Nutrition Facts - Nutrition Facts + Stacked AI heading + Horizontal AI heading +
+``` + +`iconOnly` shows only the AI icon, and it comes in the same sizes as the standard Heading. Set the size with the `variant` or `level` prop, and the icon scales to match: + +```js +--- +type: example +--- +
+ titlePageDesktop + titlePageMobile + titleSection + titleCardSection + titleModule + titleCardLarge + titleCardRegular + titleCardMini + label
``` +For example, in a Modal header: + +```js +--- +type: example +--- +const Example = () => { + const [open, setOpen] = useState(false) + return ( +
+ + setOpen(false)} + size="small" + label="Summarize with AI" + > + + setOpen(false)} + screenReaderLabel="Close" + /> + + Summarize with AI + + + + The AI-generated summary goes here. + + +
+ ) +} + +render() +``` + ### Heading level What DOM element is output is determined in the following order: diff --git a/packages/ui-heading/src/Heading/v2/index.tsx b/packages/ui-heading/src/Heading/v2/index.tsx index 570a2b3bae..33e2882752 100644 --- a/packages/ui-heading/src/Heading/v2/index.tsx +++ b/packages/ui-heading/src/Heading/v2/index.tsx @@ -99,6 +99,22 @@ const variantToAIHorizontalIconSize: Record< labelInline: 'xs' } +const variantToAIIconOnlySize: Record< + NonNullable, + 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' +> = { + titlePageDesktop: 'xl', + titlePageMobile: 'xl', + titleSection: 'xl', + titleCardSection: 'lg', + titleModule: 'lg', + titleCardLarge: 'lg', + titleCardRegular: 'md', + titleCardMini: 'sm', + label: 'sm', + labelInline: 'sm' +} + const levelToAIHorizontalIconSize: Record< Exclude, 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' @@ -159,10 +175,12 @@ class Heading extends Component { this.checkProps() } - getIconSize(forAIHorizontal = false) { + getIconSize(aiMode?: 'horizontal' | 'iconOnly') { const { variant, level, as } = this.props + const forAIHorizontal = !!aiMode if (variant) { + if (aiMode === 'iconOnly') return variantToAIIconOnlySize[variant] return forAIHorizontal ? variantToAIHorizontalIconSize[variant] : variantToIconSize[variant] @@ -211,7 +229,10 @@ class Heading extends Component { return (