Skip to content

Commit

Permalink
Merge pull request #70 from bleu-fi/joao/click-743-simbolod-e-coracao…
Browse files Browse the repository at this point in the history
…-e-favoritar

External link display option to data table
  • Loading branch information
devjoaov authored Apr 29, 2024
2 parents a4fa758 + eb4f380 commit d6cee5e
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/components/DataTable/DataTableRowActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { DynamicActionComponent } from "./DynamicActionComponent";
export const DataTableRowActions = ({ row, column }) => {
const actions = row.original.actions || column.columnDef.actions;

if (!actions?.length) return null;

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
Expand Down
12 changes: 12 additions & 0 deletions src/components/DataTable/SWRDataTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ export const renderDataTableCell = ({ filters, column, row, selectedRows }) => {
);
case "select":
return value;
case "external_link":
return (
<a
href={value}
target="_blank"
rel="noreferrer"
className="underline text-primary flex items-center"
>
<Trans>Open</Trans>&nbsp;
<span>{column.columnDef.title}</span>
</a>
);
default:
return null;
}
Expand Down
14 changes: 12 additions & 2 deletions src/components/SectionTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import React from "react";
import { cn } from "#/lib/utils";

type SectionTitleProps = {
children: React.ReactNode;
className?: string;
};

export const SectionTitle: React.FC<SectionTitleProps> = ({ children }) => (
<h2 className="pt-8 text-2xl font-bold tracking-tigh text-foreground">
export const SectionTitle: React.FC<SectionTitleProps> = ({
children,
className,
}) => (
<h2
className={cn(
"pt-8 text-2xl font-bold tracking-tigh text-foreground",
className
)}
>
{children}
</h2>
);
28 changes: 22 additions & 6 deletions src/components/ui/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,31 @@ import { cn } from "#/lib/utils";

const ToastProvider = ToastPrimitives.Provider;

const toastViewPortVariants = cva(
"fixed z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:top-auto sm:flex-col md:max-w-[420px]",
{
variants: {
position: {
"top-right": "top-0 sm:right-0",
"bottom-right": "top-0 sm:bottom-0 sm:right-0",
"top-left": "top-0 sm:left-0",
"bottom-left": "top-0 sm:bottom-0 sm:left-0",
},
},
defaultVariants: {
position: "bottom-right",
},
}
);

const ToastViewport = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Viewport>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
>(({ className, ...props }, ref) => (
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport> &
VariantProps<typeof toastViewPortVariants>
>(({ className, position, ...props }, ref) => (
<ToastPrimitives.Viewport
ref={ref}
className={cn(
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
className
)}
className={cn(toastViewPortVariants({ position }), className)}
{...props}
/>
));
Expand Down Expand Up @@ -122,4 +137,5 @@ export {
ToastDescription,
ToastClose,
ToastAction,
toastViewPortVariants,
};
8 changes: 6 additions & 2 deletions src/components/ui/Toaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import {
} from "#/components/ui/Toast";
import { useToast } from "#/hooks/useToast";

function Toaster() {
function Toaster({
position = "top-right",
}: {
position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
}) {
const { toasts } = useToast();

return (
Expand All @@ -24,7 +28,7 @@ function Toaster() {
<ToastClose />
</Toast>
))}
<ToastViewport />
<ToastViewport position={position} />
</ToastProvider>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"This action cannot be undone": "This action cannot be undone.",
"Cancel": "Cancel",
"Confirm": "Confirm",
"Open": "Open",
"Something went wrong!": "Something went wrong!",
"Pick a date": "Pick a date",
"Click to Upload": "Click to Upload",
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt-BR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"This action cannot be undone.": "Esta ação não pode ser desfeita.",
"Cancel": "Cancelar",
"Confirm": "Confirmar",
"Open": "Abrir",
"Something went wrong!": "Algo deu errado!",
"Pick a date": "Escolha uma data",
"Click to Upload": "Clique para fazer upload",
Expand Down

0 comments on commit d6cee5e

Please sign in to comment.