Skip to content

Commit 7cb9bc7

Browse files
authored
Merge pull request #3050 from pyth-network/feat/dev-hub
fix(dev hub): ui fixes
2 parents 2e12920 + 2809aab commit 7cb9bc7

File tree

10 files changed

+766
-290
lines changed

10 files changed

+766
-290
lines changed

apps/developer-hub/src/components/CopyAddress/index.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,40 @@
22

33
import { CopyButton } from "@pythnetwork/component-library/CopyButton";
44
import { Link } from "@pythnetwork/component-library/Link";
5+
import { useMemo } from "react";
56

67
import styles from "./index.module.scss";
78

8-
const CopyAddress = ({ address, url }: { address: string; url?: string }) => {
9+
const truncate = (value: string, maxLength?: number) => {
10+
if (!maxLength) {
11+
return value;
12+
}
13+
return `${value.slice(0, maxLength)}...${value.slice(-maxLength)}`;
14+
};
15+
16+
const CopyAddress = ({
17+
address,
18+
maxLength,
19+
url,
20+
}: {
21+
address: string;
22+
maxLength?: number;
23+
url?: string;
24+
}) => {
25+
const formattedAddress = useMemo(
26+
() => truncate(address, maxLength),
27+
[address, maxLength],
28+
);
29+
930
return url ? (
1031
<div className={styles.address}>
1132
<Link href={url} target="_blank" rel="noreferrer">
12-
{address}
33+
{formattedAddress}
1334
</Link>
1435
<CopyButton text={address} iconOnly />
1536
</div>
1637
) : (
17-
<CopyButton text={address}>{address}</CopyButton>
38+
<CopyButton text={address}>{formattedAddress}</CopyButton>
1839
);
1940
};
2041

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.table {
2+
overflow-x: auto;
3+
}

apps/developer-hub/src/components/EntropyTable/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { FORTUNA_API_URLS } from "./constants";
1515
import type { EntropyDeployment } from "./entropy-api-data-fetcher";
1616
import { fetchEntropyDeployments } from "./entropy-api-data-fetcher";
1717
import CopyAddress from "../CopyAddress";
18+
import styles from "./index.module.scss";
1819

1920
function isValidAddress(address: string): address is `0x${string}` {
2021
return isAddress(address);
@@ -64,7 +65,6 @@ const EntropyTableContent = ({
6465
chains: Record<string, EntropyDeployment>;
6566
}) => {
6667
const fees = useEntropyFees(chains);
67-
6868
const columns: ColumnConfig<Col>[] = [
6969
{ id: "chain", name: "Chain", isRowHeader: true },
7070
{ id: "address", name: "Contract" },
@@ -81,11 +81,12 @@ const EntropyTableContent = ({
8181
chain: chainName,
8282
address: deployment.explorer ? (
8383
<CopyAddress
84+
maxLength={6}
8485
address={deployment.address}
8586
url={`${deployment.explorer}/address/${deployment.address}`}
8687
/>
8788
) : (
88-
<CopyAddress address={deployment.address} />
89+
<CopyAddress maxLength={6} address={deployment.address} />
8990
),
9091
delay: deployment.delay,
9192
gasLimit: deployment.gasLimit,
@@ -97,6 +98,7 @@ const EntropyTableContent = ({
9798

9899
return (
99100
<Table<Col>
101+
className={styles.table ?? ""}
100102
label="Entropy deployments"
101103
columns={columns}
102104
rows={rows}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Overrides for Fumadocs content. Everything after prose is MDX generated content to which we can't apply custom classes so we need to globally select and override content
3+
*/
4+
.prose {
5+
line-height: 1.5;
6+
}
7+
8+
:where(.prose) :where(p, li) {
9+
line-height: 1.5;
10+
}
11+
12+
:where(.prose) :where(h1, h2, h3, h4, h5, h6) {
13+
line-height: 1.2;
14+
}
15+
16+
.prose p + ul,
17+
.prose p + ol {
18+
margin-top: 0;
19+
padding-top: 0.25rem;
20+
}
21+
22+
.prose p:has(+ ul),
23+
.prose p:has(+ ol) {
24+
margin-bottom: 0;
25+
}
26+
27+
#nd-sidebar {
28+
--fd-sidebar-top: var(--header-height) !important;
29+
}

apps/developer-hub/src/components/Root/global.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
@import "fumadocs-ui/css/neutral.css";
33
@import "fumadocs-ui/css/preset.css";
44
@import "./theme.css";
5+
@import "./fumadocs-global-style-overrides.css";
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppShell } from "@pythnetwork/component-library/AppShell";
1+
import { AppBody, AppShellRoot } from "@pythnetwork/component-library/AppShell";
22
import { RootProvider as FumadocsRootProvider } from "fumadocs-ui/provider";
33
import { NuqsAdapter } from "nuqs/adapters/next/app";
44
import type { ReactNode } from "react";
@@ -24,29 +24,32 @@ type Props = {
2424
};
2525

2626
export const Root = ({ children }: Props) => (
27-
<FumadocsRootProvider
28-
search={{
29-
enabled: true,
30-
options: {
31-
api: "/api/search",
32-
},
33-
}}
27+
<AppShellRoot
28+
amplitudeApiKey={AMPLITUDE_API_KEY}
29+
googleAnalyticsId={GOOGLE_ANALYTICS_ID}
30+
enableAccessibilityReporting={ENABLE_ACCESSIBILITY_REPORTING}
31+
providers={[NuqsAdapter]}
3432
>
35-
<AppShell
36-
appName="Developer Hub"
37-
displaySupportButton={false}
38-
amplitudeApiKey={AMPLITUDE_API_KEY}
39-
googleAnalyticsId={GOOGLE_ANALYTICS_ID}
40-
enableAccessibilityReporting={ENABLE_ACCESSIBILITY_REPORTING}
41-
extraCta={<SearchButton />}
42-
mainCta={{
43-
label: "Developer Forum",
44-
href: "https://dev-forum.pyth.network/",
33+
<FumadocsRootProvider
34+
search={{
35+
enabled: true,
36+
options: {
37+
api: "/api/search",
38+
},
4539
}}
46-
providers={[NuqsAdapter]}
47-
tabs={TABS}
4840
>
49-
{children}
50-
</AppShell>
51-
</FumadocsRootProvider>
41+
<AppBody
42+
appName="Developer Hub"
43+
displaySupportButton={false}
44+
extraCta={<SearchButton />}
45+
mainCta={{
46+
label: "Developer Forum",
47+
href: "https://dev-forum.pyth.network/",
48+
}}
49+
tabs={TABS}
50+
>
51+
{children}
52+
</AppBody>
53+
</FumadocsRootProvider>
54+
</AppShellRoot>
5255
);

apps/developer-hub/src/components/Root/theme.css

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
var(--color-steel-900),
302302
var(--color-steel-50)
303303
);
304-
--color-fd-muted: light-dark(var(--color-steel-100), var(--color-steel-700));
304+
--color-fd-muted: light-dark(var(--color-steel-50), var(--color-steel-900));
305305
--color-fd-muted-foreground: light-dark(
306306
var(--color-steel-600),
307307
var(--color-steel-400)
@@ -334,16 +334,3 @@
334334
);
335335
--color-fd-ring: light-dark(var(--color-violet-600), var(--color-violet-400));
336336
}
337-
338-
/* Global typography: tighten line spacing in docs content */
339-
:where(.prose) {
340-
line-height: 1.5;
341-
}
342-
343-
:where(.prose) :where(p, li) {
344-
line-height: 1.5;
345-
}
346-
347-
:where(.prose) :where(h1, h2, h3, h4, h5, h6) {
348-
line-height: 1.2;
349-
}

packages/component-library/src/AppShell/index.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,52 @@ type Tab = ComponentProps<typeof MainNavTabs>["tabs"][number] & {
3030
children: ReactNode;
3131
};
3232

33-
type Props = AppBodyProps & {
33+
type AppShellRootProps = {
3434
enableAccessibilityReporting: boolean;
3535
amplitudeApiKey?: string | undefined;
3636
googleAnalyticsId?: string | undefined;
3737
providers?: ComponentProps<typeof ComposeProviders>["providers"] | undefined;
38+
children: ReactNode;
3839
};
3940

40-
export const AppShell = ({
41+
export const AppShellRoot = ({
4142
enableAccessibilityReporting,
4243
amplitudeApiKey,
4344
googleAnalyticsId,
4445
providers,
45-
...props
46-
}: Props) => (
46+
children,
47+
}: AppShellRootProps) => (
4748
<RootProviders providers={providers}>
4849
<HtmlWithLang
4950
// See https://github.com/pacocoursey/next-themes?tab=readme-ov-file#with-app
5051
suppressHydrationWarning
5152
className={clsx(sans.className, styles.html)}
5253
>
53-
<body className={styles.body}>
54-
<AppBody {...props} />
55-
</body>
54+
<body className={styles.body}>{children}</body>
5655
{googleAnalyticsId && <GoogleAnalytics gaId={googleAnalyticsId} />}
5756
{amplitudeApiKey && <Amplitude apiKey={amplitudeApiKey} />}
5857
{enableAccessibilityReporting && <ReportAccessibility />}
5958
</HtmlWithLang>
6059
</RootProviders>
6160
);
6261

62+
export const AppShell = ({
63+
enableAccessibilityReporting,
64+
amplitudeApiKey,
65+
googleAnalyticsId,
66+
providers,
67+
...props
68+
}: AppShellRootProps & AppBodyProps) => (
69+
<AppShellRoot
70+
enableAccessibilityReporting={enableAccessibilityReporting}
71+
amplitudeApiKey={amplitudeApiKey}
72+
googleAnalyticsId={googleAnalyticsId}
73+
providers={providers}
74+
>
75+
<AppBody {...props} />
76+
</AppShellRoot>
77+
);
78+
6379
type AppBodyProps = Pick<
6480
ComponentProps<typeof Header>,
6581
"appName" | "mainCta" | "extraCta" | "displaySupportButton"

0 commit comments

Comments
 (0)