feat: adicionar estrutura para gerenciamento de mudanças de código
Implementa um sistema para registrar e gerenciar mudanças de código de forma eficiente. A estrutura permite a adição, remoção e edição de entradas de mudanças, facilitando o acompanhamento do histórico de alterações no projeto.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -7,6 +8,7 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { cn } from "@/lib/utils/ui";
|
||||
import Image from "next/image";
|
||||
|
||||
@@ -51,26 +53,26 @@ export function LogoPickerTrigger({
|
||||
onClick={onOpen}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60",
|
||||
"flex w-full items-center gap-2 rounded-md border p-2 text-left transition-colors hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60",
|
||||
className
|
||||
)}
|
||||
>
|
||||
<span className="flex size-14 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border/40 bg-background shadow-xs">
|
||||
<span className="flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border/40 bg-background shadow-xs">
|
||||
{selectedLogoPath ? (
|
||||
<Image
|
||||
src={selectedLogoPath}
|
||||
alt={selectedLogoLabel || "Logo selecionado"}
|
||||
width={48}
|
||||
height={48}
|
||||
width={28}
|
||||
height={28}
|
||||
className="h-full w-full object-contain"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-xs text-muted-foreground">{placeholder}</span>
|
||||
<span className="text-[10px] text-muted-foreground">Logo</span>
|
||||
)}
|
||||
</span>
|
||||
|
||||
<span className="flex min-w-0 flex-1 flex-col">
|
||||
<span className="truncate font-medium text-foreground">
|
||||
<span className="truncate text-sm font-medium text-foreground">
|
||||
{selectedLogoLabel || placeholder}
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
@@ -104,9 +106,22 @@ export function LogoPickerDialog({
|
||||
description = "Selecione o logo que será usado para identificar este item.",
|
||||
emptyState,
|
||||
}: LogoPickerDialogProps) {
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
const filteredLogos = logos.filter((logo) => {
|
||||
if (!search.trim()) return true;
|
||||
const logoLabel = deriveNameFromLogo(logo).toLowerCase();
|
||||
return logoLabel.includes(search.toLowerCase().trim());
|
||||
});
|
||||
|
||||
const handleOpenChange = (isOpen: boolean) => {
|
||||
if (!isOpen) setSearch("");
|
||||
onOpenChange(isOpen);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-xl">
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogContent className="sm:max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
{description ? (
|
||||
@@ -114,15 +129,29 @@ export function LogoPickerDialog({
|
||||
) : null}
|
||||
</DialogHeader>
|
||||
|
||||
{logos.length > 0 && (
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="Pesquisar..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="h-8 text-sm"
|
||||
/>
|
||||
)}
|
||||
|
||||
{logos.length === 0 ? (
|
||||
emptyState ?? (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Nenhum logo encontrado. Adicione arquivos na pasta de logos.
|
||||
</p>
|
||||
)
|
||||
) : filteredLogos.length === 0 ? (
|
||||
<p className="py-4 text-center text-sm text-muted-foreground">
|
||||
Nenhum logo encontrado para “{search}”
|
||||
</p>
|
||||
) : (
|
||||
<div className="grid max-h-72 grid-cols-3 gap-4 overflow-y-auto p-1 sm:grid-cols-4">
|
||||
{logos.map((logo) => {
|
||||
<div className="grid max-h-custom-height-1 grid-cols-4 gap-2 overflow-y-auto p-1 sm:grid-cols-4 md:grid-cols-5">
|
||||
{filteredLogos.map((logo) => {
|
||||
const isActive = value === logo;
|
||||
const logoLabel = deriveNameFromLogo(logo);
|
||||
|
||||
@@ -132,21 +161,21 @@ export function LogoPickerDialog({
|
||||
key={logo}
|
||||
onClick={() => onSelect(logo)}
|
||||
className={cn(
|
||||
"flex flex-col items-center gap-2 border rounded-lg bg-card p-2 text-center text-xs transition-all hover:border-primary hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
||||
"flex flex-col items-center gap-1 rounded-md bg-card p-2 text-center text-xs transition-all hover:border-primary hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
||||
isActive &&
|
||||
"border-primary bg-primary/5 ring-2 ring-primary/40"
|
||||
)}
|
||||
>
|
||||
<span className="flex w-full items-center justify-center overflow-hidden rounded-lg">
|
||||
<span className="flex w-full items-center justify-center overflow-hidden rounded-md">
|
||||
<Image
|
||||
src={resolveLogoSrc(logo, basePath)}
|
||||
alt={logoLabel || logo}
|
||||
width={48}
|
||||
height={48}
|
||||
className="rounded-lg"
|
||||
width={40}
|
||||
height={40}
|
||||
className="rounded-md"
|
||||
/>
|
||||
</span>
|
||||
<span className="line-clamp-2 leading-tight text-muted-foreground">
|
||||
<span className="line-clamp-1 text-[10px] leading-tight text-muted-foreground">
|
||||
{logoLabel}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user