Skip to content
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
31 changes: 25 additions & 6 deletions components/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { FC, ReactNode } from "react";
import { twMerge } from "tailwind-merge";
import { workspacestate } from "@/state";
import { useRecoilState } from "recoil";
import { getContrastColor } from "@/utils/color";
import { getHexFromTheme } from "@/utils/themeColor";

type Props = {
children: ReactNode;
Expand All @@ -26,33 +28,50 @@ const Button: FC<Props> = ({
disabled,
type = "button",
}) => {
const [workspaceState] = useRecoilState(workspacestate);
const workspaceTextColor = getContrastColor(
workspaceState?.groupTheme
? getHexFromTheme(workspaceState.groupTheme)
: "#000000"
);
return (
<button
type={type}
onClick={onPress || onClick}
disabled={disabled}
className={twMerge(
"inline-flex items-center justify-center transition rounded-lg text-sm text-white focus-visible:outline-none",
"inline-flex items-center justify-center transition rounded-lg text-sm focus-visible:outline-none",
compact
? "min-h-0 py-1.5 px-3.5"
: workspace
? "min-h-0 py-2 px-4"
: "min-h-0 py-2.5 px-5",
workspace
? "bg-primary hover:bg-primary/80 focus-visible:bg-primary/80 disabled:bg-primary/50 dark:bg-zinc-700 dark:hover:bg-zinc-600 dark:text-white dark:disabled:bg-zinc-700/50"
: "bg-orbit hover:bg-orbit/80 focus-visible:bg-orbit/80 disabled:bg-orbit/50 dark:bg-white dark:text-black dark:hover:bg-zinc-300 dark:disabled:bg-white/50",
? `${workspaceTextColor} bg-primary hover:bg-primary/80 focus-visible:bg-primary/80 disabled:bg-primary/50 dark:bg-zinc-700 dark:hover:bg-zinc-600 dark:text-white dark:disabled:bg-zinc-700/50`
: "text-white bg-orbit hover:bg-orbit/80 focus-visible:bg-orbit/80 disabled:bg-orbit/50 dark:bg-white dark:text-black dark:hover:bg-zinc-300 dark:disabled:bg-white/50",
classoverride
)}
>
{loading ? (
<svg
className="animate-spin mx-auto h-5 w-5 text-white dark:text-black"
className="animate-spin mx-auto h-5 w-5 text-current"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
/>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
/>
</svg>
) : (
children
Expand Down
Loading
Loading