@ -5,7 +5,7 @@ import React, { CSSProperties, useState, ReactNode } from 'react';
import { useInterval } from 'react-use' ;
import { LoadingState } from '@grafana/data' ;
import { PanelChrome , PanelChromeProps } from '@grafana/ui' ;
import { Button , Icon , PanelChrome , PanelChromeProps , RadioButtonGroup } from '@grafana/ui' ;
import { DashboardStoryCanvas } from '../../utils/storybook/DashboardStoryCanvas' ;
import { withCenteredStory } from '../../utils/storybook/withCenteredStory' ;
@ -40,7 +40,7 @@ function getContentStyle(): CSSProperties {
function renderPanel ( name : string , overrides? : Partial < PanelChromeProps > ) {
const props : PanelChromeProps = {
width : 400 ,
height : 13 0 ,
height : 15 0 ,
children : ( ) = > undefined ,
} ;
@ -131,10 +131,6 @@ export const Examples = () => {
{ renderPanel ( 'No title, streaming loadingState' , {
loadingState : LoadingState.Streaming ,
} ) }
{ renderPanel ( 'No title, loading loadingState' , {
loadingState : LoadingState.Loading ,
} ) }
{ renderPanel ( 'Error status, menu' , {
title : 'Default title' ,
menu ,
@ -183,22 +179,120 @@ export const Examples = () => {
/ > ,
] ,
} ) }
{ renderPanel ( 'Deprecated error indicator, menu ' , {
{ renderPanel ( 'Display mode = transparent ' , {
title : 'Default title' ,
displayMode : 'transparent' ,
menu ,
leftItems : [
< PanelChrome.ErrorIndicator
key = "errorIndicator"
error = "Error text"
onClick = { action ( 'ErrorIndicator: onClick fired' ) }
} ) }
{ renderPanel ( 'Actions with button no menu' , {
title : 'Actions with button no menu' ,
actions : (
< Button size = "sm" variant = "secondary" key = "A" >
Breakdown
< / Button >
) ,
} ) }
{ renderPanel ( 'Panel with two actions' , {
title : 'I have two buttons' ,
actions : [
< Button size = "sm" variant = "secondary" key = "A" >
Breakdown
< / Button > ,
< Button size = "sm" variant = "secondary" icon = "times" key = "B" / > ,
] ,
} ) }
{ renderPanel ( 'With radio button' , {
title : 'I have a radio button' ,
actions : [
< RadioButtonGroup
key = "radio-button-group"
size = "sm"
value = "A"
options = { [
{ label : 'Graph' , value : 'A' } ,
{ label : 'Table' , value : 'B' } ,
] }
/ > ,
] ,
} ) }
{ renderPanel ( 'Display mode = transparent' , {
{ renderPanel ( 'Panel with action link' , {
title : 'Panel with action link' ,
actions : (
< a className = "external-link" href = "/some/page" >
Error details
< Icon name = "arrow-right" / >
< / a >
) ,
} ) }
{ renderPanel ( 'Action and menu (should be rare)' , {
title : 'Action and menu' ,
menu ,
actions : (
< Button size = "sm" variant = "secondary" >
Breakdown
< / Button >
) ,
} ) }
< / HorizontalGroup >
< / div >
< / DashboardStoryCanvas >
) ;
} ;
export const ExamplesHoverHeader = ( ) = > {
return (
< DashboardStoryCanvas >
< div >
< HorizontalGroup spacing = "md" align = "flex-start" wrap >
{ renderPanel ( 'Title items, menu, hover header' , {
title : 'Default title' ,
displayMode : 'transparent' ,
description : 'This is a description ' ,
menu ,
leftItems : [ ] ,
hoverHeader : true ,
dragClass : 'draggable' ,
titleItems : (
< PanelChrome.TitleItem title = "Online" >
< Icon name = "heart" / >
< / PanelChrome.TitleItem >
) ,
} ) }
{ renderPanel ( 'Multiple title items' , {
title : 'Default title' ,
menu ,
hoverHeader : true ,
dragClass : 'draggable' ,
titleItems : [
< PanelChrome.TitleItem title = "Online" key = "A" >
< Icon name = "heart" / >
< / PanelChrome.TitleItem > ,
< PanelChrome.TitleItem title = "Link" key = "B" onClick = { ( ) = > { } } >
< Icon name = "external-link-alt" / >
< / PanelChrome.TitleItem > ,
] ,
} ) }
{ renderPanel ( 'Hover header, loading loadingState' , {
loadingState : LoadingState.Loading ,
hoverHeader : true ,
title : 'I am a hover header' ,
dragClass : 'draggable' ,
} ) }
{ renderPanel ( 'No title, Hover header' , {
hoverHeader : true ,
dragClass : 'draggable' ,
} ) }
{ renderPanel ( 'Should not have drag icon' , {
title : 'No drag icon' ,
hoverHeader : true ,
} ) }
{ renderPanel ( 'With action link' , {
title : 'With link in hover header' ,
hoverHeader : true ,
actions : (
< a className = "external-link" href = "/some/page" >
Error details
< Icon name = "arrow-right" / >
< / a >
) ,
} ) }
< / HorizontalGroup >
< / div >