File tree 3 files changed +299
-269
lines changed
3 files changed +299
-269
lines changed Original file line number Diff line number Diff line change 4
4
* See License-AGPL.txt in the project root for license information.
5
5
*/
6
6
7
+ export type PillType = "info" | "warn" | "success" ;
8
+
9
+ const PillClsMap : Record < PillType , string > = {
10
+ info : "bg-blue-50 text-blue-500 dark:bg-blue-500 dark:text-blue-100" ,
11
+ warn : "bg-orange-100 text-orange-700 dark:bg-orange-600 dark:text-orange-100" ,
12
+ success : "bg-green-100 text-green-700 dark:bg-green-600 dark:text-green-100" ,
13
+ } ;
14
+
7
15
/**
8
16
* Renders a pill.
9
17
*
10
18
* **type**\
11
19
* info: Renders a blue pile label (default).\
12
20
* warn: Renders an orange pile label.
21
+ * success: Renders an green pile label.
13
22
*
14
23
* **className**\
15
24
* Add additional css classes to style this component.
16
25
*/
17
- export default function PillLabel ( props : { children ?: React . ReactNode ; type ?: "info" | "warn" ; className ?: string } ) {
18
- const infoStyle = "bg-blue-50 text-blue-500 dark:bg-blue-500 dark:text-blue-100" ;
19
- const warnStyle = "bg-orange-100 text-orange-700 dark:bg-orange-600 dark:text-orange-100" ;
20
- const style = `px-2 py-1 text-sm uppercase rounded-xl ${ props . type === "warn" ? warnStyle : infoStyle } ${
21
- props . className
22
- } `;
26
+ export default function PillLabel ( props : { children ?: React . ReactNode ; type ?: PillType ; className ?: string } ) {
27
+ const type = props . type || "info" ;
28
+ const style = `px-2 py-1 text-sm uppercase rounded-xl ${ PillClsMap [ type ] } ${ props . className } ` ;
23
29
return < span className = { style } > { props . children } </ span > ;
24
30
}
You can’t perform that action at this time.
0 commit comments