11import React from 'react' ;
22import cn from '@ably/ui/core/utils/cn' ;
33
4- type AdmonitionVariant = 'neutral' | 'blue' | 'green' | 'red' | 'yellow' ;
4+ type AdmonitionVariant =
5+ | 'neutral'
6+ | 'note'
7+ | 'further-reading'
8+ | 'important'
9+ | 'new'
10+ | 'warning'
11+ | 'experimental'
12+ | 'updated' ;
513
614interface AdmonitionProps extends React . HTMLAttributes < HTMLElement > {
7- variant ?: AdmonitionVariant ;
15+ 'data-type' ?: AdmonitionVariant ;
816}
917
1018const admonitionConfig : Record <
@@ -20,43 +28,58 @@ const admonitionConfig: Record<
2028 backgroundColor : 'bg-neutral-100 dark:bg-neutral-1200' ,
2129 title : 'Category' ,
2230 } ,
23- blue : {
31+ note : {
2432 borderColor : 'border-l-blue-500 dark:border-l-blue-400' ,
2533 backgroundColor : 'bg-blue-100 dark:bg-blue-800' ,
2634 title : 'Note' ,
2735 } ,
28- green : {
36+ 'further-reading' : {
2937 borderColor : 'border-l-green-500 dark:border-l-green-400' ,
3038 backgroundColor : 'bg-green-100 dark:bg-green-800' ,
3139 title : 'Further reading' ,
3240 } ,
33- red : {
41+ important : {
3442 borderColor : 'border-l-orange-500 dark:border-l-orange-600' ,
3543 backgroundColor : 'bg-orange-100 dark:bg-orange-1000' ,
3644 title : 'Important' ,
3745 } ,
38- yellow : {
46+ new : {
3947 borderColor : 'border-l-yellow-500 dark:border-l-yellow-400' ,
4048 backgroundColor : 'bg-yellow-100 dark:bg-yellow-800' ,
41- title : 'Category' ,
49+ title : 'New' ,
50+ } ,
51+ warning : {
52+ borderColor : 'border-l-yellow-500 dark:border-l-yellow-400' ,
53+ backgroundColor : 'bg-yellow-100 dark:bg-yellow-800' ,
54+ title : 'Warning' ,
55+ } ,
56+ experimental : {
57+ borderColor : 'border-l-purple-500 dark:border-l-purple-400' ,
58+ backgroundColor : 'bg-purple-100 dark:bg-purple-800' ,
59+ title : 'Experimental' ,
60+ } ,
61+ updated : {
62+ borderColor : 'border-l-pink-500 dark:border-l-pink-400' ,
63+ backgroundColor : 'bg-pink-100 dark:bg-pink-800' ,
64+ title : 'Updated' ,
4265 } ,
4366} ;
4467
45- const Admonition : React . FC < AdmonitionProps > = ( { variant = 'blue ' , children, className, ...rest } ) => {
46- const { borderColor, backgroundColor, title } = admonitionConfig [ variant ] ?? admonitionConfig . blue ;
68+ const Admonition : React . FC < AdmonitionProps > = ( { 'data-type' : dataType = 'note ' , children, className, ...rest } ) => {
69+ const { borderColor, backgroundColor, title } = admonitionConfig [ dataType ] ?? admonitionConfig . note ;
4770
4871 return (
4972 < aside
5073 { ...rest }
51- data-variant = { variant }
74+ data-type = { dataType }
5275 className = { cn (
5376 'border-l px-6 py-4 my-4 rounded-r-lg text-neutral-1000 dark:text-neutral-300' ,
5477 borderColor ,
5578 backgroundColor ,
5679 className ,
5780 ) }
5881 >
59- < div className = "text-sm leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_p ]:inline [&_p]:m-0 " >
82+ < div className = "text-sm leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>*:nth-child(2) ]:inline [&>*:nth-child(3)]:mt-5 " >
6083 < strong className = "font-bold ui-text-p2" > { title } : </ strong >
6184 { children }
6285 </ div >
0 commit comments