File tree Expand file tree Collapse file tree 4 files changed +448
-304
lines changed Expand file tree Collapse file tree 4 files changed +448
-304
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { ReactComponent as Spinner } from "../icons/Spinner.svg" ;
8
+
9
+ export function SpinnerLoader ( props : { content ?: string } ) {
10
+ return (
11
+ < div className = "flex items-center justify-center space-x-2 text-gray-400 text-sm pt-16 pb-40" >
12
+ < Spinner className = "h-4 w-4 animate-spin" />
13
+ { props . content && < span > { props . content } </ span > }
14
+ </ div >
15
+ ) ;
16
+ }
17
+
18
+ interface SpinnerContentProps {
19
+ loading ?: boolean ;
20
+ content ?: string ;
21
+ children : React . ReactChild [ ] | React . ReactChild | React . ReactNode ;
22
+ }
23
+ export function SpinnerOverlayLoader ( props : SpinnerContentProps ) {
24
+ return (
25
+ < div className = "relative" >
26
+ { props . loading && (
27
+ < div className = "absolute h-full w-full" >
28
+ < div className = "flex items-center justify-center space-x-2 text-gray-400 text-sm h-full" >
29
+ < Spinner className = "h-4 w-4 animate-spin" />
30
+ { props . content && < span > { props . content } </ span > }
31
+ </ div >
32
+ </ div >
33
+ ) }
34
+ < div className = { props . loading ? "opacity-40 select-none pointer-events-none" : "" } > { props . children } </ div >
35
+ </ div >
36
+ ) ;
37
+ }
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