Skip to content

Commit d660036

Browse files
jeanp413mustard-mh
andcommitted
[pat] Token UI polish
Co-authored-by: Huiwen <[email protected]>
1 parent 6609391 commit d660036

File tree

4 files changed

+448
-304
lines changed

4 files changed

+448
-304
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}

components/dashboard/src/components/PillLabel.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@
44
* See License-AGPL.txt in the project root for license information.
55
*/
66

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+
715
/**
816
* Renders a pill.
917
*
1018
* **type**\
1119
* info: Renders a blue pile label (default).\
1220
* warn: Renders an orange pile label.
21+
* success: Renders an green pile label.
1322
*
1423
* **className**\
1524
* Add additional css classes to style this component.
1625
*/
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}`;
2329
return <span className={style}>{props.children}</span>;
2430
}

0 commit comments

Comments
 (0)