Skip to content

Commit d2504c6

Browse files
minor tweaks (#60)
1 parent 6669424 commit d2504c6

File tree

10 files changed

+72
-23
lines changed

10 files changed

+72
-23
lines changed

.changeset/pink-months-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@scaffold-ui/debug-contracts": patch
3+
---
4+
5+
(debug-contracts): make the hardhat/anvil chain name neutral

.changeset/poor-apples-wear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@scaffold-ui/components": patch
3+
---
4+
5+
set font-family at component level instead of global css rule

packages/components/src/Address/Address.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { mainnet } from "viem/chains";
77
import { AddressLinkWrapper } from "./AddressLinkWrapper";
88
import { AddressCopyIcon } from "./AddressCopyIcon";
99
import { textSizeMap, blockieSizeMap, copyIconSizeMap, getNextSize, getPrevSize } from "./utils";
10+
import { DefaultStylesWrapper } from "../utils/ComponentWrapper";
1011

1112
export type AddressProps = {
1213
address?: AddressType;
@@ -51,7 +52,7 @@ export const Address: React.FC<AddressProps> = ({
5152

5253
if (!checkSumAddress) {
5354
return (
54-
<div className="flex items-center text-sui-primary-content" style={style}>
55+
<DefaultStylesWrapper className="flex items-center text-sui-primary-content" style={style}>
5556
<div
5657
className="shrink-0 sui-skeleton !rounded-full"
5758
style={{
@@ -69,12 +70,12 @@ export const Address: React.FC<AddressProps> = ({
6970
<span className="invisible">0x1234...56789</span>
7071
</div>
7172
</div>
72-
</div>
73+
</DefaultStylesWrapper>
7374
);
7475
}
7576

7677
return (
77-
<div className="flex items-center shrink-0 text-sui-primary-content" style={style}>
78+
<DefaultStylesWrapper className="flex items-center shrink-0 text-sui-primary-content" style={style}>
7879
<div className="shrink-0">
7980
<img
8081
className="rounded-full"
@@ -115,6 +116,6 @@ export const Address: React.FC<AddressProps> = ({
115116
/>
116117
</div>
117118
</div>
118-
</div>
119+
</DefaultStylesWrapper>
119120
);
120121
};

packages/components/src/Balance.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Address, Chain } from "viem";
55
import { useBalance } from "@scaffold-ui/hooks";
66
import { useAccount } from "wagmi";
77
import { mainnet } from "viem/chains";
8+
import { DefaultStylesWrapper } from "./utils/ComponentWrapper";
89

910
export type BalanceProps = {
1011
address?: Address;
@@ -39,26 +40,27 @@ export const Balance: React.FC<BalanceProps> = ({ address, chain, defaultUsdMode
3940

4041
if (isLoading || !balance) {
4142
return (
42-
<div className="flex items-center animate-pulse" style={style}>
43+
<DefaultStylesWrapper className="flex items-center animate-pulse" style={style}>
4344
<div className="h-4 w-20 bg-sui-skeleton-base rounded" />
44-
</div>
45+
</DefaultStylesWrapper>
4546
);
4647
}
4748

4849
if (isError) {
4950
return (
50-
<div
51+
<DefaultStylesWrapper
5152
className="border border-gray-300 rounded px-2 flex flex-col items-center max-w-fit text-sui-primary-content"
5253
style={style}
5354
>
5455
<div className="text-sui-warning text-sm">Error</div>
55-
</div>
56+
</DefaultStylesWrapper>
5657
);
5758
}
5859

5960
return (
60-
<button
61-
className={`flex flex-col items-center font-normal bg-transparent focus:outline-none cursor-pointer text-sui-primary-content`}
61+
<DefaultStylesWrapper
62+
as="button"
63+
className="flex flex-col items-center font-normal bg-transparent focus:outline-none cursor-pointer text-sui-primary-content"
6264
onClick={toggleDisplayUsdMode}
6365
type="button"
6466
title="Toggle balance display mode"
@@ -77,6 +79,6 @@ export const Balance: React.FC<BalanceProps> = ({ address, chain, defaultUsdMode
7779
</div>
7880
)}
7981
</div>
80-
</button>
82+
</DefaultStylesWrapper>
8183
);
8284
};

packages/components/src/Input/BaseInput.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { ChangeEvent, FocusEvent, ReactNode, useCallback, useEffect, useRef } from "react";
44
import { CommonInputProps } from "./utils";
5+
import { DefaultStylesWrapper } from "../utils/ComponentWrapper";
56

67
export type BaseInputProps<T> = CommonInputProps<T> & {
78
error?: boolean;
@@ -82,7 +83,7 @@ export const BaseInput = <T extends { toString: () => string } | undefined = str
8283
}, [reFocus]);
8384

8485
return (
85-
<div
86+
<DefaultStylesWrapper
8687
className={`flex border-2 rounded-full border-sui-input-border bg-sui-input-background text-sui-input-text ${modifier}`}
8788
style={style}
8889
>
@@ -101,6 +102,6 @@ export const BaseInput = <T extends { toString: () => string } | undefined = str
101102
onFocus={onFocus}
102103
/>
103104
{suffix}
104-
</div>
105+
</DefaultStylesWrapper>
105106
);
106107
};

packages/components/src/styles.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@
4141
--color-sui-input-border: var(--color-sui-primary);
4242
}
4343

44-
/* Apply default font family to all component elements */
45-
* {
46-
font-family: var(--font-sans);
47-
}
48-
4944
.sui-skeleton {
5045
border-radius: 0.2rem;
5146
background-color: var(--color-sui-skeleton-base);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React, { CSSProperties, ElementType, ComponentPropsWithoutRef } from "react";
2+
3+
type ComponentWrapperProps<T extends ElementType = "div"> = {
4+
children: React.ReactNode;
5+
className?: string;
6+
style?: CSSProperties;
7+
as?: T;
8+
} & Omit<ComponentPropsWithoutRef<T>, "className" | "style" | "children" | "as">;
9+
10+
/**
11+
* Base wrapper component for all scaffold-ui components
12+
* Automatically applies the font-sans class for consistent styling
13+
*/
14+
export const DefaultStylesWrapper = <T extends ElementType = "div">({
15+
children,
16+
className = "",
17+
style,
18+
as,
19+
...props
20+
}: ComponentWrapperProps<T>) => {
21+
const Component = as || "div";
22+
return (
23+
<Component className={`${className} font-sans`} style={style} {...props}>
24+
{children}
25+
</Component>
26+
);
27+
};

packages/debug-contracts/src/Contract.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const Contract: React.FC<ContractProps> = ({ contractName, contract, chai
2828

2929
return (
3030
<ContractConfigProvider config={{ blockExplorerAddressLink, chain, chainId }}>
31-
<div className={`grid grid-cols-1 lg:grid-cols-6 px-6 lg:px-10 lg:gap-12 w-full max-w-7xl my-0`}>
31+
<div className="grid grid-cols-1 lg:grid-cols-6 px-6 lg:px-10 lg:gap-12 w-full max-w-7xl my-0 font-sans">
3232
<div className="col-span-5 grid grid-cols-1 lg:grid-cols-3 gap-8 lg:gap-10">
3333
<div className="col-span-1 flex flex-col">
3434
<div className="bg-sui-base-100 border-sui-primary-subtle dark:border-sui-primary border shadow-md shadow-sui-primary-subtle rounded-3xl px-6 lg:px-8 mb-6 space-y-1 py-4">
@@ -55,7 +55,9 @@ export const Contract: React.FC<ContractProps> = ({ contractName, contract, chai
5555
</div>
5656
<p className="my-0 text-sm">
5757
<span className="font-bold">Network</span>:{" "}
58-
<span style={{ color: NETWORKS_EXTRA_DATA[chainId]?.color }}>{chain.name}</span>
58+
<span style={{ color: NETWORKS_EXTRA_DATA[chainId]?.color }}>
59+
{chain.id === 31_337 ? "Localhost" : chain.name}
60+
</span>
5961
</p>
6062
</div>
6163
</div>

packages/debug-contracts/src/components/DisplayVariable.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ export const DisplayVariable = ({
7373
<div className="text-sui-primary-content/80 flex flex-col items-start">
7474
<div>
7575
<div
76-
className={`block transition bg-transparent ${
77-
showAnimation ? "bg-warning rounded-xs animate-pulse-fast" : ""
78-
}`}
76+
className={`block transition ${showAnimation ? "bg-[#e2d563] rounded-xs animate-pulse-fast" : "bg-transparent"}`}
7977
>
8078
{displayTxResult(result, "base")}
8179
</div>

packages/debug-contracts/src/styles.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,17 @@
7070
.link-dc:hover {
7171
opacity: 80%;
7272
}
73+
74+
.loading-dc {
75+
@apply pointer-events-none inline-block aspect-square bg-current align-middle;
76+
width: calc(var(0.25rem) * 6);
77+
mask-size: 100%;
78+
mask-repeat: no-repeat;
79+
mask-position: center;
80+
mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='black' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform-origin='center'%3E%3Ccircle cx='12' cy='12' r='9.5' fill='none' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='2s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dasharray' values='0,150;42,150;42,150' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dashoffset' values='0;-16;-59' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/svg%3E");
81+
}
82+
83+
.loading-dc-spinner {
84+
mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='black' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform-origin='center'%3E%3Ccircle cx='12' cy='12' r='9.5' fill='none' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='2s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dasharray' values='0,150;42,150;42,150' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dashoffset' values='0;-16;-59' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/svg%3E");
85+
}
7386
}

0 commit comments

Comments
 (0)