Skip to content

Commit a596ad2

Browse files
authored
Merge branch 'main' into 10-23-next15
Signed-off-by: greg <[email protected]>
2 parents a97bb59 + 004cac0 commit a596ad2

File tree

95 files changed

+2260
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2260
-205
lines changed

.changeset/early-shoes-applaud.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/fuzzy-olives-prove.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/new-rules-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Allow smart accounts to switch chains between zk and non zk chains

.changeset/smart-chicken-beam.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/three-dancers-hear.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

apps/dashboard/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,17 @@ Some env vars can be overridden that are required for some external services to
2323

2424
To define env vars please create a `.env` file based on the `.env.example` template at the root level of the project. This file is ignored by git so you can safely add it to your local copy of the project.
2525

26-
**Add your thirdweb clientID and secret key to build a basic functioning version of the site.**
26+
**Add your thirdweb clientID and secret key to build a basic functioning version of the site.**
27+
28+
## Code Structure and Style Guide
29+
30+
### Components
31+
- Components should go in a `components` folder next to the app page they are used in.
32+
- If a component is reused in multiple pages, it should go in the lowest level route folder it is used in. For example, if a chart component is used in all analytics subroutes `/analytics/...`, it should go in the `/analytics/components` folder.
33+
- All low-level components such as buttons, inputs, etc. should be shadcn components found in `@/ui`.
34+
- All composed components reused across all page routes are `blocks`, and should also go in the `@/ui` folder.
35+
36+
### Data fetching
37+
- Use RSC wherever possible.
38+
- Write data fetching code in its own function in the same file as the component it is used in, not exported.
39+
- If the same data fetching function is used in multiple components, place it in a file in an `api` folder at the lowest level possible (just like components). If you need to do this you probable aren't organizing your components properly.

apps/dashboard/src/@/components/blocks/Img.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable @next/next/no-img-element */
22
"use client";
3-
import { useState } from "react";
3+
import { useRef, useState } from "react";
4+
import { useIsomorphicLayoutEffect } from "../../lib/useIsomorphicLayoutEffect";
45
import { cn } from "../../lib/utils";
56

67
type imgElementProps = React.DetailedHTMLProps<
@@ -25,19 +26,39 @@ export function Img(props: imgElementProps) {
2526
const { className, fallback, skeleton, ...restProps } = props;
2627
const defaultSkeleton = <div className="animate-pulse bg-accent" />;
2728
const defaultFallback = <div className="bg-muted" />;
29+
const imgRef = useRef<HTMLImageElement>(null);
30+
31+
useIsomorphicLayoutEffect(() => {
32+
const imgEl = imgRef.current;
33+
if (!imgEl) {
34+
return;
35+
}
36+
if (imgEl.complete) {
37+
setStatus("loaded");
38+
} else {
39+
function handleLoad() {
40+
setStatus("loaded");
41+
}
42+
imgEl.addEventListener("load", handleLoad);
43+
return () => {
44+
imgEl.removeEventListener("load", handleLoad);
45+
};
46+
}
47+
}, []);
2848

2949
return (
3050
<div className="relative">
3151
<img
3252
{...restProps}
33-
onLoad={() => {
34-
setStatus("loaded");
35-
}}
53+
// avoid setting empty src string to prevent request to the entire page
54+
src={restProps.src || undefined}
55+
ref={imgRef}
3656
onError={() => {
3757
setStatus("fallback");
3858
}}
3959
style={{
4060
opacity: status === "loaded" ? 1 : 0,
61+
...restProps.style,
4162
}}
4263
alt={restProps.alt || ""}
4364
className={cn(
@@ -48,6 +69,7 @@ export function Img(props: imgElementProps) {
4869

4970
{status !== "loaded" && (
5071
<div
72+
style={restProps.style}
5173
className={cn(
5274
"fade-in-0 absolute inset-0 overflow-hidden transition-opacity duration-300 [&>*]:h-full [&>*]:w-full",
5375
className,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use client";
2+
3+
import { Spinner } from "@/components/ui/Spinner/Spinner";
4+
5+
export function GenericLoadingPage() {
6+
return (
7+
<div className="flex min-h-[500px] grow items-center justify-center rounded-lg border border-border">
8+
<Spinner className="size-10" />
9+
</div>
10+
);
11+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use client";
2+
3+
export { GenericLoadingPage as default } from "@/components/blocks/skeletons/GenericLoadingPage";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use client";
2+
3+
export { GenericLoadingPage as default } from "@/components/blocks/skeletons/GenericLoadingPage";

0 commit comments

Comments
 (0)