Skip to content

[pat] Token UI polish #15015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions components/dashboard/src/components/Loader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

import { ReactComponent as Spinner } from "../icons/Spinner.svg";

export function SpinnerLoader(props: { content?: string }) {
return (
<div className="flex items-center justify-center space-x-2 text-gray-400 text-sm pt-16 pb-40">
<Spinner className="h-4 w-4 animate-spin" />
{props.content && <span>{props.content}</span>}
</div>
);
}

interface SpinnerContentProps {
loading?: boolean;
content?: string;
children: React.ReactChild[] | React.ReactChild | React.ReactNode;
}
export function SpinnerOverlayLoader(props: SpinnerContentProps) {
return (
<div className="relative">
{props.loading && (
<div className="absolute h-full w-full">
<div className="flex items-center justify-center space-x-2 text-gray-400 text-sm h-full">
<Spinner className="h-4 w-4 animate-spin" />
{props.content && <span>{props.content}</span>}
</div>
</div>
)}
<div className={props.loading ? "opacity-40 select-none pointer-events-none" : ""}>{props.children}</div>
</div>
);
}
18 changes: 12 additions & 6 deletions components/dashboard/src/components/PillLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@
* See License-AGPL.txt in the project root for license information.
*/

export type PillType = "info" | "warn" | "success";

const PillClsMap: Record<PillType, string> = {
info: "bg-blue-50 text-blue-500 dark:bg-blue-500 dark:text-blue-100",
warn: "bg-orange-100 text-orange-700 dark:bg-orange-600 dark:text-orange-100",
success: "bg-green-100 text-green-700 dark:bg-green-600 dark:text-green-100",
};
Comment on lines +9 to +13
Copy link
Contributor

@gtsiolis gtsiolis Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Thank you for extending this component, @jeanp413 & @mustard-mh!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is @mustard-mh change 😄

Copy link
Contributor

@gtsiolis gtsiolis Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized this a few hours after posting the comment above.

Thanks for giving credit where credit is due, @jeanp413! 🧡


/**
* Renders a pill.
*
* **type**\
* info: Renders a blue pile label (default).\
* warn: Renders an orange pile label.
* success: Renders an green pile label.
*
* **className**\
* Add additional css classes to style this component.
*/
export default function PillLabel(props: { children?: React.ReactNode; type?: "info" | "warn"; className?: string }) {
const infoStyle = "bg-blue-50 text-blue-500 dark:bg-blue-500 dark:text-blue-100";
const warnStyle = "bg-orange-100 text-orange-700 dark:bg-orange-600 dark:text-orange-100";
const style = `px-2 py-1 text-sm uppercase rounded-xl ${props.type === "warn" ? warnStyle : infoStyle} ${
props.className
}`;
export default function PillLabel(props: { children?: React.ReactNode; type?: PillType; className?: string }) {
const type = props.type || "info";
const style = `px-2 py-1 text-sm uppercase rounded-xl ${PillClsMap[type]} ${props.className}`;
return <span className={style}>{props.children}</span>;
}
Loading