Skip to content

Commit

Permalink
feat: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorbenSchiller committed Sep 19, 2024
1 parent 4c48fca commit 456f810
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 230 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EntryFull } from "@components/Dict";
import { Alert, Button, LoadingProgress } from "@components/ui";
import { Alert, ButtonLink, LoadingProgress } from "@components/ui";
import ExternalIcon from "@heroicons/react/24/solid/ArrowTopRightOnSquareIcon";
import type {
EntryModel,
Expand Down Expand Up @@ -48,16 +48,15 @@ export function VocabularyProvider({
entry={entry}
className="mb-4 p-4 border border-gray-300 dark:border-gray-700 rounded"
/>
<Button
as="a"
<ButtonLink
href={`/entry/${entry.id}`}
variant="default"
target="_blank"
className="inline-flex items-center"
>
Im Wörterbuch anzeigen
<ExternalIcon className="ml-1 w-4 h-4" />
</Button>
</ButtonLink>
</>
)}
{error && <Alert type="error">{error}</Alert>}
Expand Down
19 changes: 0 additions & 19 deletions components/ui/Box/Box.tsx

This file was deleted.

1 change: 0 additions & 1 deletion components/ui/Box/index.ts

This file was deleted.

56 changes: 39 additions & 17 deletions components/ui/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { forwardRef } from "react";
import { Box, BoxComponent, BoxProps } from "../Box";
import { ButtonHTMLAttributes, forwardRef, HTMLProps } from "react";
import clsx from "clsx";

export type ButtonVariant = "primary" | "default" | "text";

export type ButtonProps<E extends React.ElementType = React.ElementType> = {
export type ButtonProps = {
variant?: ButtonVariant;
} & BoxProps<E>;
} & ButtonHTMLAttributes<HTMLButtonElement>;

const COLOR_MAP: Record<ButtonVariant, string> = {
default: "border-gray-700",
Expand All @@ -14,16 +14,38 @@ const COLOR_MAP: Record<ButtonVariant, string> = {
"border-primary-700 text-primary-700 hover:bg-primary-700 hover:bg-opacity-20 focus focus:bg-opacity-40",
};

export const Button: BoxComponent<ButtonProps> = forwardRef(function Button(
{ as, className = "", variant = "default", ...rest },
ref,
) {
return (
<Box
as={as ?? "button"}
className={`select-none text-sm px-4 py-2 focus:outline-none rounded font-bold border border-gray-700 ${COLOR_MAP[variant]} ${className}`}
ref={ref}
{...rest}
/>
);
});
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
function Button({ className = "", variant = "default", ...rest }, ref) {
return (
<button
className={clsx(
"select-none text-sm px-4 py-2 focus:outline-none rounded font-bold border border-gray-700",
COLOR_MAP[variant],
className,
)}
ref={ref}
{...rest}
/>
);
},
);

export type ButtonLinkProps = {
variant?: ButtonVariant;
} & HTMLProps<HTMLAnchorElement>;

export const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(
function Button({ className = "", variant = "default", ...rest }, ref) {
return (
<a
className={clsx(
"select-none text-sm px-4 py-2 focus:outline-none rounded font-bold border border-gray-700",
COLOR_MAP[variant],
className,
)}
ref={ref}
{...rest}
/>
);
},
);
1 change: 0 additions & 1 deletion components/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "./Alert";
export * from "./Box";
export * from "./Button";
export * from "./Footer";
export * from "./Grid";
Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
Loading

0 comments on commit 456f810

Please sign in to comment.