Skip to content

Commit

Permalink
Merge pull request #5 from bleu-fi/jose/click-557-deploy-new-app-prod…
Browse files Browse the repository at this point in the history
…-version

feat(components): add components
  • Loading branch information
ribeirojose authored Jan 19, 2024
2 parents e6f511c + 863b6e0 commit 6ccfff2
Show file tree
Hide file tree
Showing 74 changed files with 6,363 additions and 139 deletions.
8 changes: 0 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ module.exports = {
"typescript-sort-keys/interface": "error",
"typescript-sort-keys/string-enum": "error",
"unused-imports/no-unused-imports": "error",
"prefer-arrow/prefer-arrow-functions": [
"error",
{
disallowPrototype: true,
singleReturnOnly: true,
classPropertiesAllowed: false,
},
],
"sort-class-members/sort-class-members": [
"error",
{
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ storybook-static
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.yalc/*
yalc.lock
47 changes: 45 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^14.1.2",
"@types/node": "20.11.5",
"@types/quill": "^1",
"@types/react": "18.2.48",
"@types/react-beautiful-dnd": "^13",
"@types/react-dom": "18.2.18",
"@types/react-test-renderer": "18.0.7",
"@types/rollup-plugin-peer-deps-external": "^2",
Expand Down Expand Up @@ -153,7 +155,8 @@
},
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
"react-dom": ">=18",
"react-router-dom": "^6.21.0"
},
"resolutions": {
"glob-parent": ">=5.1.2",
Expand All @@ -166,10 +169,50 @@
},
"packageManager": "yarn@4.0.0",
"dependencies": {
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-aspect-ratio": "^1.0.3",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-context-menu": "^2.1.5",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-menubar": "^1.0.4",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-toggle": "^1.0.3",
"@radix-ui/react-toggle-group": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.7",
"@tanstack/react-table": "^8.11.6",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"tailwind-merge": "^2.2.0"
"cmdk": "^0.2.0",
"copy-to-clipboard": "^3.3.3",
"object-to-formdata": "^4.5.1",
"quill": "^1.3.7",
"quill-html-edit-button": "^2.2.13",
"react-beautiful-dnd": "^13.1.1",
"react-day-picker": "^8.10.0",
"react-hook-form": "^7.49.3",
"react-quill": "^2.0.0",
"react-router": "^6.21.1",
"react-router-dom": "^6.21.1",
"swr": "^2.2.4",
"tailwind-merge": "^2.2.0",
"zod": "^3.22.4"
}
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default [
format: "esm",
},
],
external: ["react", "react-dom"],
external: ["react", "react-dom", "react-router-dom"],
plugins: [
peerDepsExternal(),
resolve(),
Expand Down
96 changes: 96 additions & 0 deletions src/components/Cmdk.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { CircleIcon, FileIcon } from "@radix-ui/react-icons";
import * as React from "react";
import { useNavigate } from "react-router-dom";
import {
Button,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
} from "@/components/ui";
import { cn } from "@/lib/utils";

export function CommandMenu({ commands, ...props }) {
const navigate = useNavigate();
const [open, setOpen] = React.useState(false);

React.useEffect(() => {
const down = (e) => {
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
// eslint-disable-next-line no-shadow
setOpen((open) => !open);
}
};

document.addEventListener("keydown", down);
return () => document.removeEventListener("keydown", down);
}, []);

const runCommand = React.useCallback((command) => {
setOpen(false);
command();
}, []);

return (
<>
<Button
variant="outline"
className={cn(
"text-muted-foreground relative w-full justify-start text-sm sm:pr-12 md:w-40 lg:w-64"
)}
onClick={() => setOpen(true)}
{...props}
>
<span className="inline-flex">Busca global</span>
<kbd className="bg-muted top- pointer-events-none absolute right-1.5 hidden h-5 select-none items-center gap-1 rounded border px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex">
<span className="text-xs"></span>K
</kbd>
</Button>
<CommandDialog open={open} onOpenChange={setOpen}>
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Links">
{commands.mainNav
.filter((navitem) => !navitem.external)
.map((navItem) => (
<CommandItem
key={navItem.href}
value={navItem.title}
onSelect={() => {
runCommand(() => navigate(navItem.href));
}}
>
<FileIcon className="mr-2 h-2 w-2" />
{navItem.title}
</CommandItem>
))}
</CommandGroup>
<CommandSeparator />
{commands.sidebarNav?.map((group) => (
<CommandGroup key={group.title} heading={group.title}>
{group.items.map((navItem) => (
<CommandItem
key={navItem.href}
value={navItem.title}
onSelect={() => {
runCommand(() => navigate(navItem.href));
}}
>
<div className="mr-2 flex h-4 w-4 items-center justify-center">
<CircleIcon className="h-3 w-3" />
</div>
{navItem.title}
</CommandItem>
))}
</CommandGroup>
))}
</CommandList>
</CommandDialog>
</>
);
}
78 changes: 78 additions & 0 deletions src/components/CopyClipboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* eslint-disable consistent-return */
import { ClipboardCopyIcon } from "@radix-ui/react-icons";
import copy from "copy-to-clipboard";
import React, { PropsWithChildren, useCallback, useLayoutEffect } from "react";
import { cn } from "@/lib/utils";
import { useToast } from "@/hooks/useToast";

export function ClickToCopy({
text,
className,
children,
}: PropsWithChildren<{
className?: string;
text: string;
}>) {
const [copied, setCopied] = React.useState(false);
const { toast } = useToast();

useLayoutEffect(() => {
if (copied) {
const timeout = setTimeout(() => {
setCopied(false);
}, 2000);

toast({
title: "Copied to clipboard",
variant: "default",
});

return () => clearTimeout(timeout);
}
}, [copied]);

return (
<div>
<CopyToClipboard
text={text}
onCopy={() => setCopied(true)}
className={cn("flex flex-row items-center", className)}
>
<>
<span className="mr-1">{children}</span>
<ClipboardCopyIcon
width={18}
height={18}
className="text-foreground"
/>
</>
</CopyToClipboard>
</div>
);
}

function CopyToClipboard({ text, className, onCopy, children }) {
const [copied, setCopied] = React.useState(false);

useLayoutEffect(() => {
if (copied) {
const timeout = setTimeout(() => {
setCopied(false);
}, 1000);

return () => clearTimeout(timeout);
}
}, [copied]);

const handleCopy = useCallback(() => {
copy(text);
onCopy?.();
}, [text, onCopy]);

return (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div className={cn("cursor-pointer", className)} onClick={handleCopy}>
{children}
</div>
);
}
60 changes: 60 additions & 0 deletions src/components/DataTable/DataTableColumnHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {
ArrowDownIcon,
ArrowUpIcon,
CaretSortIcon,
EyeNoneIcon,
} from "@radix-ui/react-icons";
import React from "react";
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui";
import { cn } from "@/lib/utils";

export function DataTableColumnHeader({ column, title, className }) {
if (!column.getCanSort()) {
return <div className={cn(className)}>{title}</div>;
}

return (
<div className={cn("flex items-center space-x-2", className)}>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="sm"
className="data-[state=open]:bg-accent -ml-3 h-8"
>
<span>{title}</span>
{column.getIsSorted() === "desc" ? (
<ArrowDownIcon className="ml-2 h-4 w-4" />
) : column.getIsSorted() === "asc" ? (
<ArrowUpIcon className="ml-2 h-4 w-4" />
) : (
<CaretSortIcon className="ml-2 h-4 w-4" />
)}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem onClick={() => column.toggleSorting(false)}>
<ArrowUpIcon className="text-muted-foreground/70 mr-2 h-3.5 w-3.5" />
Asc
</DropdownMenuItem>
<DropdownMenuItem onClick={() => column.toggleSorting(true)}>
<ArrowDownIcon className="text-muted-foreground/70 mr-2 h-3.5 w-3.5" />
Desc
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => column.toggleVisibility(false)}>
<EyeNoneIcon className="text-muted-foreground/70 mr-2 h-3.5 w-3.5" />
Hide
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
);
}
Loading

0 comments on commit 6ccfff2

Please sign in to comment.