Skip to content

Start porting docs content #2735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 31, 2025
Merged

Start porting docs content #2735

merged 23 commits into from
May 31, 2025

Conversation

aaronbassett
Copy link
Contributor

Summary

Port across the price feed MDX files and display components

Rationale

There's still more content to be added, but this PR should also fix the Eslint errors that are currently being triggered on main.

@aaronbassett aaronbassett requested a review from a team as a code owner May 27, 2025 14:18
Copy link

vercel bot commented May 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
component-library ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 4:28pm
developer-hub ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 4:28pm
entropy-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 4:28pm
insights ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 4:28pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Skipped (Inspect) May 30, 2025 4:28pm
entropy-debugger ⬜️ Skipped (Inspect) May 30, 2025 4:28pm
proposals ⬜️ Skipped (Inspect) May 30, 2025 4:28pm
staking ⬜️ Skipped (Inspect) May 30, 2025 4:28pm

@aaronbassett aaronbassett requested a review from cprussin May 27, 2025 14:19
@vercel vercel bot temporarily deployed to Preview – api-reference May 27, 2025 14:40 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-debugger May 27, 2025 14:40 Inactive
@vercel vercel bot temporarily deployed to Preview – insights May 27, 2025 14:40 Inactive
@vercel vercel bot temporarily deployed to Preview – proposals May 27, 2025 14:40 Inactive
@vercel vercel bot temporarily deployed to Preview – staking May 27, 2025 14:40 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer May 27, 2025 14:40 Inactive
Copy link
Collaborator

@cprussin cprussin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, minor comments about some components in the component library that may be more appropriate for what you're doing

@@ -0,0 +1,66 @@
"use client";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component looks like it's basically <Card> but with added variants. I don't think that's the right component to use here; instead I think we should be using <InfoBox> which already has most if not all of these variants and I think is a more correct fit for a callout (assuming I understand how you're using this correctly)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't seen InfoBox, it looks like it and CopyButton aren't in Storybook so I missed them.

The icon and header are required props for InfoBox but were not for Callout so the interfaces are different. However, rather than duplicating the majority of the component I'll create a thin wrapper around it that sets default values for icon and header based on the type

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just make those changes to InfoBox directly, it seems reasonable for the component to have those defaults

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and <Callout /> supports an optional href prop to convert the whole thing into a <Link />, but looking at the existing docs we don't seem to ever actually use that functionality so we can just leave it out. If we need to link to somewhere from a within a <Callout /> we can just add it to the children.

@@ -0,0 +1,96 @@
"use client";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a <CopyButton> component in the component library which implements the copy to clipboard functionality, I think you can just use that and simplify this component to just implement the address truncation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapped the existing <CopyButton /> component as it needs to support copying and navigating when clicked.

Copy link
Collaborator

@cprussin cprussin May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can take a look at https://github.com/pyth-network/pyth-crosschain/blob/main/apps/entropy-explorer/src/components/Address/index.tsx for a component which implements exactly this functionality for the WIP entropy explorer app, you'll see it used in a few places in the preview. Maybe we should extract that to the component library if it will become a more commonly used component?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I guess it depends on wether or not we want the copy and the navigate to be two seperate controls. They were not in the previous implementation on existing docs site. Clicking on the link would copy and navigate.

I prefer the way you're doing it in that preview, I was just replicating what was there. But I'll change it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh got it, I never even realized they were the same control. I agree that's an odd way to handle it, but it's totally your call

<span
className={styles.truncateToMiddle}
data-text-start={text.slice(0, Math.floor(text.length / 2))}
data-text-end={text.slice(Math.floor(text.length / 2) * -1)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is clever. Note that I believe there will be accessibility issues with only showing content in ::before and ::after so ideally you'd give this {text} as the children and then set @include theme.sr-only so that the content doesn't show up visually (you might want to read some a11y docs to confirms as I can't recall how accessibility devices handle pseudo-elements).

It would also be nice to be able to specify the minimum number of characters at the start & end here if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sorta got the minimum number of characters working, it's 100% accurate for strings of all zeros 😅


const { pressProps } = usePress({
onPress: () => {
void writeClipboardText(address);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor point but I personally avoid void as the intent is not obvious when reading the code. To me, it's better to write doSomething().catch((error: unkonwn) => {/* no-op */}), which makes it very obvious that you are intentionally disregarding error handling. void has the same effect but does it implicitly and does not look like an intentional decision to disregard errors.

…ced code block

Known issue in current version of Prettier.
See: prettier/prettier#15740
@vercel vercel bot temporarily deployed to Preview – proposals May 28, 2025 13:05 Inactive
@vercel vercel bot temporarily deployed to Preview – insights May 28, 2025 16:41 Inactive
@vercel vercel bot temporarily deployed to Preview – api-reference May 28, 2025 16:41 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-debugger May 28, 2025 16:41 Inactive
@vercel vercel bot temporarily deployed to Preview – proposals May 28, 2025 16:41 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer May 28, 2025 16:41 Inactive
@vercel vercel bot temporarily deployed to Preview – staking May 28, 2025 16:41 Inactive
@@ -0,0 +1,171 @@
export const CASE_VARIANTS = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the problem with modules like this is that they are extremely locale specific and they make it a nightmare to localize codebases if we ever decide to do so. I generally recommend explicitly mapping strings rather than relying on clever tricks like this because mapping strings explicitly is simpler, drastically easier to localize, and also generally less brittle.

Comment on lines 13 to 18
neutral: "⦿",
info: "💡",
warning: "⚠️",
error: "❗",
data: "💾",
success: "🎉",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use icons from phosphor-icons to be consistent with the rest of our iconography?

I also think you should add the default icons to the underlying InfoBox component directly, it makes sense to me that it would have sane defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do, the current content uses Emojis, but that is probably a requirement of the old framework rather than a conscious decision. I'm happy to swap them out

);
};

export default CopyAddress;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we decide we don't want to extract & reuse the same component from entropy-explorer for some reason? I think it would be better to share the same component given this is effectively identical functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I just saw your comment about their being a Copy component in the library, so that's what I used. I'll look at the explorer components and work on getting it extracted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so the <Address /> component in entropy-explorer is tightly coupled with EntropyDeployments. So I don't think we can extract and use that component. However, we could create a <CopyWithLink /> component that is responsible for the rendering and have <Address /> and the devhub use that component.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's exactly what I had in mind, the only coupling in that component to EntropyDeployments is to figure out the href value, so just leave that part in entropy-explorer and extract the rest of the component & styling to the component library

// might differ slightly from the specified 'ch' value.
const style = {
"--min-chars-start-ch": `${minCharsStart.toString()}ch`,
"--min-chars-end-ch": `${minCharsEnd.toString()}ch`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is very clever, I like this solution a lot

@aaronbassett aaronbassett merged commit 289c304 into main May 31, 2025
11 checks passed
@aaronbassett aaronbassett deleted the docs-port-price-feeds branch May 31, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants