@ -1,4 +1,4 @@
import React , { HTMLAttributes } from 'react' ;
import React , { ReactNode , HTMLAttributes } from 'react' ;
import { css , cx } from '@emotion/css' ;
import { Icon , LinkButton , useStyles2 } from '@grafana/ui' ;
import { GrafanaTheme2 } from '@grafana/data' ;
@ -6,19 +6,25 @@ import { GrafanaTheme2 } from '@grafana/data';
type ComponentSize = 'sm' | 'md' ;
export interface Props extends HTMLAttributes < HTMLOrSVGElement > {
text : string ;
text? : string ;
size? : ComponentSize ;
children? : ReactNode ;
secondaryAction ? : {
url : string ;
text : string ;
} ;
}
export const UpgradeBox = ( { text , className , size = 'md' , . . . htmlProps } : Props ) = > {
export const UpgradeBox = ( { text , className , children , secondaryAction , size = 'md' , . . . htmlProps } : Props ) = > {
const styles = useStyles2 ( ( theme ) = > getUpgradeBoxStyles ( theme , size ) ) ;
return (
< div className = { cx ( styles . box , className ) } { ...htmlProps } >
< Icon name = { 'arrow-up ' } className = { styles . icon } / >
< Icon name = { 'rocket ' } className = { styles . icon } / >
< div >
< h6 > You ’ ve found a Pro feature ! < / h6 >
< p className = { styles . text } > { text } < / p >
< h4 > You ’ ve found a Pro feature ! < / h4 >
{ text && < p className = { styles . text } > { text } < / p > }
{ children }
< LinkButton
variant = "primary"
size = { size }
@ -29,6 +35,19 @@ export const UpgradeBox = ({ text, className, size = 'md', ...htmlProps }: Props
>
Upgrade to Pro
< / LinkButton >
{ secondaryAction && (
< LinkButton
variant = "link"
size = { size }
className = { cx ( styles . button , styles . buttonSecondary ) }
href = { secondaryAction . url }
target = "__blank"
rel = "noopener noreferrer"
>
{ secondaryAction . text }
< / LinkButton >
) }
< / div >
< / div >
) ;
@ -53,19 +72,26 @@ const getUpgradeBoxStyles = (theme: GrafanaTheme2, size: ComponentSize) => {
` ,
text : css `
margin - bottom : 0 ;
padding : $ { theme . spacing ( 2 , 0 ) } ;
line - height : 1.5 ;
` ,
button : css `
margin - top : $ { theme . spacing ( 2 ) } ;
& : first - of - type {
margin - right : $ { theme . spacing ( 1 ) } ;
}
& : focus - visible {
box - shadow : none ;
color : $ { theme . colors . text . primary } ;
outline : 2px solid $ { theme . colors . primary . main } ;
}
` ,
buttonSecondary : css `
color : $ { theme . colors . text . secondary } ;
` ,
icon : css `
border : 1px solid $ { theme . colors . primary . shade } ;
border - radius : 50 % ;
margin : $ { theme . spacing ( 0.5 , 1 , 0.5 , 0.5 ) } ;
` ,
} ;