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
3 changes: 1 addition & 2 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { StorybookConfig } from "@storybook/react-vite";

import { dirname, join } from "node:path";
import type { StorybookConfig } from "@storybook/react-vite";

/**
* This function is used to resolve the absolute path of a package.
Expand Down
1 change: 1 addition & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { withThemeByClassName } from "@storybook/addon-themes";
import type { Preview } from "@storybook/react-vite";
import "../tailwind.css";
// biome-ignore lint/correctness/noUnusedImports: ignore
import React from "react";
import { ClipboardProvider } from "../components/providers/clipboard-provider";

Expand Down
19 changes: 17 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"files": {
"ignore": ["**/*.gen.ts", "dist", "package.json", "storybook-static"]
"includes": [
"**",
"!**/*.gen.ts",
"!**/dist",
"!**/package.json",
"!**/storybook-static"
]
},
"formatter": {
"indentStyle": "space"
Expand All @@ -15,7 +21,16 @@
},
"style": {
"noUselessElse": "off",
"noNonNullAssertion": "off"
"noNonNullAssertion": "off",
"noParameterAssign": "error",
"useAsConstAssertion": "error",
"useDefaultParameterLast": "error",
"useEnumInitializers": "error",
"useSelfClosingElements": "error",
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "error",
"useNumberNamespace": "error",
"noInferrableTypes": "error"
},
"performance": {
"noAccumulatingSpread": "error",
Expand Down
36 changes: 17 additions & 19 deletions components/abi-form/array-input.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Plus, X } from "lucide-react";
import { useState } from "react";
import { Debug, cn } from "../../lib/utils.js";
import { cn, Debug } from "../../lib/utils.js";
import { Button } from "../shadcn/button.js";
import { Separator } from "../shadcn/separator.js";
import { AbiInput, type InnerProps } from "./abi-input.js";
Expand Down Expand Up @@ -56,26 +56,24 @@ export function ArrayInput({
Expanded
</Button>
</div>
<>
{tab === "text" && (
<Basic
{...{ ...rest, label, type, defaultValue: value }}
{tab === "text" && (
<Basic
{...{ ...rest, label, type, defaultValue: value }}
onChange={onChange}
/>
)}
{tab === "expanded" && (
<div className="border-bg-secondary border-l-2 border-solid pl-1">
<ArrayElements
{...{
...rest,
elemType: `${baseType}${subArrays}`,
defaultValue: value,
}}
onChange={onChange}
/>
)}
{tab === "expanded" && (
<div className="border-bg-secondary border-l-2 border-solid pl-1">
<ArrayElements
{...{
...rest,
elemType: `${baseType}${subArrays}`,
defaultValue: value,
}}
onChange={onChange}
/>
</div>
)}
</>
</div>
)}
</div>
);
}
Expand Down
6 changes: 2 additions & 4 deletions components/abi-form/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useCallback, useState } from "react";

import type { InnerProps } from "./abi-input.js";

import { parse } from "@ethui/abiparse";
import { useCallback, useState } from "react";
import { Debug, stringify } from "../../lib/utils.js";
import { Input } from "../shadcn/input.js";
import type { InnerProps } from "./abi-input.js";

export type BasicProps = Omit<InnerProps, "depth" | "type" | "label">;
export function Basic({ name, defaultValue, onChange, debug }: BasicProps) {
Expand Down
2 changes: 2 additions & 0 deletions components/click-to-copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function ClickToCopy({ children, text, ...props }: ClickToCopyProps) {
writeText(text.toString());
};

// biome-ignore-start lint/a11y/noStaticElementInteractions: ignore
return (
<TooltipProvider>
<Tooltip open={open}>
Expand All @@ -66,4 +67,5 @@ export function ClickToCopy({ children, text, ...props }: ClickToCopyProps) {
</Tooltip>
</TooltipProvider>
);
// biome-ignore-end lint/a11y/noStaticElementInteractions: ignore
}
7 changes: 3 additions & 4 deletions components/form.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import clsx from "clsx";
import { Check, LoaderCircle, type LucideIcon, Save } from "lucide-react";
import { createElement } from "react";
import {
type FieldPath,
type FieldPathValue,
Expand All @@ -7,10 +10,6 @@ import {
type UseFormReturn,
useFormContext,
} from "react-hook-form";

import clsx from "clsx";
import { Check, LoaderCircle, type LucideIcon, Save } from "lucide-react";
import { createElement } from "react";
import { cn } from "../lib/utils.js";
import { Button, type ButtonProps } from "./shadcn/button.js";
import {
Expand Down
2 changes: 1 addition & 1 deletion components/shadcn/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type VariantProps, cva } from "class-variance-authority";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "../../lib/utils.js";

Expand Down
2 changes: 1 addition & 1 deletion components/shadcn/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type VariantProps, cva } from "class-variance-authority";
import { cva, type VariantProps } from "class-variance-authority";
import type * as React from "react";

import { cn } from "../../lib/utils.js";
Expand Down
2 changes: 1 addition & 1 deletion components/shadcn/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Slot } from "@radix-ui/react-slot";
import { type VariantProps, cva } from "class-variance-authority";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "../../lib/utils.js";

Expand Down
2 changes: 1 addition & 1 deletion components/shadcn/label.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as LabelPrimitive from "@radix-ui/react-label";
import { type VariantProps, cva } from "class-variance-authority";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "../../lib/utils.js";

Expand Down
2 changes: 1 addition & 1 deletion components/shadcn/sheet.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as SheetPrimitive from "@radix-ui/react-dialog";
import { Cross2Icon } from "@radix-ui/react-icons";
import { type VariantProps, cva } from "class-variance-authority";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "../../lib/utils.js";

Expand Down
5 changes: 3 additions & 2 deletions components/shadcn/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Slot } from "@radix-ui/react-slot";
import { type VariantProps, cva } from "class-variance-authority";
import { cva, type VariantProps } from "class-variance-authority";
import { PanelLeft } from "lucide-react";
import * as React from "react";

Expand Down Expand Up @@ -62,7 +62,7 @@ function SidebarProvider({
open?: boolean;
onOpenChange?: (open: boolean) => void;
}) {
const isMobile = allowMobile && useIsMobile();
const isMobile = useIsMobile() && allowMobile;
const [openMobile, setOpenMobile] = React.useState(false);

// This is the internal state of the sidebar.
Expand All @@ -79,6 +79,7 @@ function SidebarProvider({
}

// This sets the cookie to keep the sidebar state.
// biome-ignore lint/suspicious/noDocumentCookie: ignore
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
},
[setOpenProp, open],
Expand Down
2 changes: 1 addition & 1 deletion components/shadcn/toast.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Cross2Icon } from "@radix-ui/react-icons";
import * as ToastPrimitives from "@radix-ui/react-toast";
import { type VariantProps, cva } from "class-variance-authority";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "../../lib/utils.js";

const ToastProvider = ToastPrimitives.Provider;
Expand Down
39 changes: 18 additions & 21 deletions components/solidity-call.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Abi, AbiFunction, Address } from "abitype";
import { decodeFunctionData, formatUnits, parseAbi } from "viem";

import clsx from "clsx";
import { decodeFunctionData, formatUnits, parseAbi } from "viem";
import { ClickToCopy } from "./click-to-copy.js";

export interface SolidityCallProps {
Expand Down Expand Up @@ -63,25 +62,23 @@ interface DeployProps {

function Deploy({ value, from, decimals, ArgProps }: DeployProps) {
return (
<>
<div className="flex gap-x-1">
<Arg
label="Ξ"
type="uint256"
{...ArgProps}
value={formatUnits(value, decimals)}
variant="value"
/>
<Arg
label="from"
type="address"
{...ArgProps}
value={from}
variant="caller"
/>
<span className="font-mono">to newly deployed contract</span>
</div>
</>
<div className="flex gap-x-1">
<Arg
label="Ξ"
type="uint256"
{...ArgProps}
value={formatUnits(value, decimals)}
variant="value"
/>
<Arg
label="from"
type="address"
{...ArgProps}
value={from}
variant="caller"
/>
<span className="font-mono">to newly deployed contract</span>
</div>
);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"tailwindcss-animate": "^1.0"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@biomejs/biome": "^2.0.6",
"@chromatic-com/storybook": "^4.0.0-next.16",
"@storybook/addon-docs": "^9.0.4",
"@storybook/addon-links": "^9.0.4",
Expand Down
1 change: 1 addition & 0 deletions stories/Alert.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react-vite";

import { CircleCheck, CircleX, Info } from "lucide-react";
// biome-ignore lint/correctness/noUnusedImports: ignore
import React from "react";
import {
Alert,
Expand Down
4 changes: 2 additions & 2 deletions stories/ButtonWithDropdown.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { fn } from "storybook/test";

// biome-ignore lint/correctness/noUnusedImports: ignore
import React from "react";
import { fn } from "storybook/test";
import { ButtonWithDropdown } from "../components/button-with-dropdown.js";
import { Button } from "../components/shadcn/button.js";

Expand Down
1 change: 1 addition & 0 deletions stories/abi-item-form-with-preview.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
// biome-ignore lint/correctness/noUnusedImports: ignore
import React, { useState } from "react";
import { AbiItemFormWithPreview } from "../components/abi-form/abi-item-form-with-preview.js";
import { Input } from "../components/shadcn/input.js";
Expand Down
1 change: 0 additions & 1 deletion stories/click-to-copy.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { fn } from "storybook/test";

import { ClickToCopy } from "../components/click-to-copy.js";

Expand Down
5 changes: 2 additions & 3 deletions stories/forms/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react-vite";

import { zodResolver } from "@hookform/resolvers/zod";
import React, { useEffect } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Form } from "../../components/form.js";
Expand Down
5 changes: 2 additions & 3 deletions stories/forms/NumberField.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react-vite";

import { zodResolver } from "@hookform/resolvers/zod";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { Check } from "lucide-react";
import React, { useEffect } from "react";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Form } from "../../components/form.js";
Expand Down
4 changes: 2 additions & 2 deletions stories/forms/Submit.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react-vite";

import { zodResolver } from "@hookform/resolvers/zod";
import type { Meta, StoryObj } from "@storybook/react-vite";
// biome-ignore lint/correctness/noUnusedImports: ignore
import React from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
Expand Down
5 changes: 2 additions & 3 deletions stories/forms/Text.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react-vite";

import { zodResolver } from "@hookform/resolvers/zod";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { Check, LoaderCircle } from "lucide-react";
import React, { useEffect } from "react";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Form } from "../../components/form.js";
Expand Down
5 changes: 2 additions & 3 deletions stories/forms/Textarea.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react-vite";

import { zodResolver } from "@hookform/resolvers/zod";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { Check } from "lucide-react";
import React, { useEffect } from "react";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Form } from "../../components/form.js";
Expand Down
12 changes: 6 additions & 6 deletions stories/infinite-scroll.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { LoaderCircle } from "lucide-react";

import React from "react";
// biome-ignore lint/correctness/noUnusedImports: ignore
import React, { useRef, useState } from "react";
import { InfiniteScroll } from "../components/infinite-scroll.js";

const meta: Meta = {
Expand Down Expand Up @@ -33,10 +33,10 @@ const Item = ({ item }: { item: Item }) => {

export const Default: Story = {
render: () => {
const [loading, setLoading] = React.useState(false);
const [hasMore, setHasMore] = React.useState(true);
const [items, setItems] = React.useState<Item[]>([]);
const listRef = React.useRef<HTMLDivElement>(null);
const [loading, setLoading] = useState(false);
const [hasMore, setHasMore] = useState(true);
const [items, setItems] = useState<Item[]>([]);
const listRef = useRef<HTMLDivElement>(null);

const next = async () => {
setLoading(true);
Expand Down
4 changes: 2 additions & 2 deletions stories/sidebar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react-vite";

import { ChevronRightIcon } from "@radix-ui/react-icons";
import type { Meta, StoryObj } from "@storybook/react-vite";
// biome-ignore lint/correctness/noUnusedImports: ignore
import React from "react";
import { EthuiLogo } from "../components/ethui-logo";
import {
Expand Down
2 changes: 1 addition & 1 deletion stories/solidity-call.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react-vite";

// biome-ignore lint/correctness/noUnusedImports: ignore
import React from "react";
import { SolidityCall } from "../components/solidity-call.js";

Expand Down
Loading