Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
marthendalnunes committed Dec 4, 2023
1 parent 1aec830 commit a7b1e50
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 53 deletions.
63 changes: 38 additions & 25 deletions apps/www/registry/default/buidl/sign-message-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,45 @@ interface SignMessageButtonProps extends Omit<ButtonProps, "onCick"> {
const SignMessageButton = React.forwardRef<
HTMLButtonElement,
SignMessageButtonProps
>(({ message, onSuccess, className, children, disabled, displayError=true, ...props }, ref) => {
const { isLoading, isError, error, signMessage } = useSignMessage({
message,
onSuccess,
})
>(
(
{
message,
onSuccess,
className,
children,
disabled,
displayError = true,
...props
},
ref
) => {
const { isLoading, isError, error, signMessage } = useSignMessage({
message,
onSuccess,
})

return (
<>
<Button
ref={ref}
disabled={disabled || isLoading || message.length === 0}
onClick={() => signMessage()}
className={className}
{...props}
>
{isLoading ? "Check Wallet" : children ?? "Sign Message"}
</Button>
{isError && displayError && (
<ErrorMessage
error={error}
defaultErrorMessage="Error while signing message"
/>
)}
</>
)
})
return (
<>
<Button
ref={ref}
disabled={disabled || isLoading || message.length === 0}
onClick={() => signMessage()}
className={className}
{...props}
>
{isLoading ? "Check Wallet" : children ?? "Sign Message"}
</Button>
{isError && displayError && (
<ErrorMessage
error={error}
defaultErrorMessage="Error while signing message"
/>
)}
</>
)
}
)

SignMessageButton.displayName = "SignMessageButton"

Expand Down
19 changes: 8 additions & 11 deletions apps/www/registry/registry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Registry } from "@/registry/schema"

const ui : Registry =[
{
const ui: Registry = [
{
name: "button",
type: "components:ui",
dependencies: ["@radix-ui/react-slot"],
Expand All @@ -13,7 +13,7 @@ const ui : Registry =[
dependencies: ["@radix-ui/react-dialog"],
files: ["ui/dialog.tsx"],
},
{
{
name: "toast",
type: "components:ui",
dependencies: ["@radix-ui/react-toast"],
Expand All @@ -23,11 +23,10 @@ const ui : Registry =[
name: "skeleton",
type: "components:ui",
files: ["ui/skeleton.tsx"],
}
},
]

const buidl: Registry = [

{
name: "address",
type: "components:buidl",
Expand Down Expand Up @@ -101,21 +100,21 @@ const buidl: Registry = [
name: "ens-avatar",
type: "components:buidl",
dependencies: ["wagmi"],
registryDependencies: ["blockie","skeleton"],
registryDependencies: ["blockie", "skeleton"],
files: ["buidl/ens-avatar.tsx"],
},
{
name: "ens-name",
type: "components:buidl",
dependencies: ["wagmi"],
registryDependencies: ["address","skeleton"],
registryDependencies: ["address", "skeleton"],
files: ["buidl/ens-name.tsx"],
},
{
name: "ens-address",
type: "components:buidl",
dependencies: ["wagmi"],
registryDependencies: ["address","skeleton", "error-message"],
registryDependencies: ["address", "skeleton", "error-message"],
files: ["buidl/ens-address.tsx"],
},
{
Expand Down Expand Up @@ -456,6 +455,4 @@ const example: Registry = [
},
]

export const registry: Registry = [...buidl,
...ui,
...example]
export const registry: Registry = [...buidl, ...ui, ...example]
6 changes: 4 additions & 2 deletions apps/www/scripts/build-registry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
import fs from "fs"
import template from "lodash.template"
import path, { basename } from "path"
import template from "lodash.template"
import { rimraf } from "rimraf"

import { colorMapping, colors } from "../registry/colors"
Expand Down Expand Up @@ -122,7 +122,9 @@ fs.writeFileSync(
// ----------------------------------------------------------------------------
// Build registry/index.json.
// ----------------------------------------------------------------------------
const names = result.data.filter((item) => item.type === "components:buidl" || item.type === "components:ui")
const names = result.data.filter(
(item) => item.type === "components:buidl" || item.type === "components:ui"
)
const registryJson = JSON.stringify(names, null, 2)
rimraf.sync(path.join(REGISTRY_PATH, "index.json"))
fs.writeFileSync(path.join(REGISTRY_PATH, "index.json"), registryJson, "utf8")
Expand Down
20 changes: 11 additions & 9 deletions packages/cli/src/commands/add.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { existsSync, promises as fs } from "fs"
import path from "path"
import { getConfig } from "@/src/utils/get-config"
import { getPackageManager } from "@/src/utils/get-package-manager"
import { handleError } from "@/src/utils/handle-error"
Expand All @@ -13,9 +15,7 @@ import { transform } from "@/src/utils/transformers"
import chalk from "chalk"
import { Command } from "commander"
import { execa } from "execa"
import { existsSync, promises as fs } from "fs"
import ora from "ora"
import path from "path"
import prompts from "prompts"
import * as z from "zod"

Expand Down Expand Up @@ -77,13 +77,15 @@ export const add = new Command()
message: "Which components would you like to add?",
hint: "Space to select. A to toggle all. Enter to submit.",
instructions: false,
choices: registryIndex.filter(({type})=>type === "components:buidl").map((entry) => ({
title: entry.name,
value: entry.name,
selected: options.all
? true
: options.components?.includes(entry.name),
})),
choices: registryIndex
.filter(({ type }) => type === "components:buidl")
.map((entry) => ({
title: entry.name,
value: entry.name,
selected: options.all
? true
: options.components?.includes(entry.name),
})),
})
selectedComponents = components
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { existsSync, promises as fs } from "fs"
import path from "path"
import {
DEFAULT_COMPONENTS,
DEFAULT_TAILWIND_CONFIG,
Expand All @@ -20,10 +22,8 @@ import * as templates from "@/src/utils/templates"
import chalk from "chalk"
import { Command } from "commander"
import { execa } from "execa"
import { existsSync, promises as fs } from "fs"
import template from "lodash.template"
import ora from "ora"
import path from "path"
import prompts from "prompts"
import * as z from "zod"

Expand Down
7 changes: 4 additions & 3 deletions packages/cli/src/utils/registry/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from "path"
import { Config } from "@/src/utils/get-config"
import {
registryBaseColorSchema,
Expand All @@ -8,10 +9,10 @@ import {
} from "@/src/utils/registry/schema"
import { HttpsProxyAgent } from "https-proxy-agent"
import fetch from "node-fetch"
import path from "path"
import * as z from "zod"

const baseUrl = process.env.COMPONENTS_REGISTRY_URL ?? "https://buidl.turboeth.xyz"
const baseUrl =
process.env.COMPONENTS_REGISTRY_URL ?? "https://buidl.turboeth.xyz"
const agent = process.env.https_proxy
? new HttpsProxyAgent(process.env.https_proxy)
: undefined
Expand Down Expand Up @@ -92,7 +93,7 @@ export async function resolveTree(
tree.push(...dependencies)
}
}

return tree.filter(
(component, index, self) =>
self.findIndex((c) => c.name === component.name) === index
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/src/utils/registry/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ export const registryItemSchema = z.object({
dependencies: z.array(z.string()).optional(),
registryDependencies: z.array(z.string()).optional(),
files: z.array(z.string()),
type: z.enum(["components:ui", "components:buidl", "components:component", "components:example"]),
type: z.enum([
"components:ui",
"components:buidl",
"components:component",
"components:example",
]),
})

export const registryIndexSchema = z.array(registryItemSchema)
Expand Down

0 comments on commit a7b1e50

Please sign in to comment.