Skip to content
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

Add new DuneDashboard component #138

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Conversation

gkoscky
Copy link
Contributor

@gkoscky gkoscky commented Dec 20, 2023

Adding a new DuneDashboard component to let you embed a Dune dashboard to a blog post. Well, technically any embedding. Example:

---
slug: my-blog-post
title: Introducing Dune Dashboards
authors: [flashbots]
---

import DuneDashboard from '@site/src/components/DuneDashboard/DuneDashboard'

If you'd like to embed a Dune dashboard to your post, just use this:

<DuneDashboard
  source="https://dune.com/embeds/3295088/5516700"
  label={<>You can add <code>HTML</code> labels!</>}
  aspectRatio="16/9" />

The component gives you control over:

  • Source: The URL for the embedded element
  • Label: Explanatory text added to the bottom of the embedding; Accepts HTML
  • Aspect Ratio: Control the proportions of the element

Instructions

Follow these steps to use the component in your post:

  1. Import the component
    Add the following line to your blog post file after all the headers, as shown in the example above:
    import DuneDashboard from '@site/src/components/DuneDashboard/DuneDashboard'
  2. Get the embedded URL from Dune
    When viewing a dashboard you can click the "Share" button to see the option to "Embed Iframe". What we want is the src property from the provided iframe. Select and copy that URL to use with the component.

  1. Add a component to your blog post
    Add a DuneDashboard component to your post using the URL you just copied as the source parameter:

    <DuneDashboard source="https://dune.com/embeds/3295088/5516700"/>
  2. Add a label - optional
    If you'd like to provide some context on what the dashboard is showing, you can add a label option to the component. The label can be plain text or HTML.

    HTML labels need to be surrounded by {<>…</>}

    The label is optional. If you omit it, the dashboard will still appear.

    <DuneDashboard source="" label="This is a plain text label"/>
    
    <DuneDashboard source="" label={<>This label is <code>HTML</code></>}/>

  1. Customize the proportions - optional
    All dashboards are the same width but you can control how tall it is using the aspectRatio option.

    By default all dashboards have a squareish 16/13 aspect ratio and you can make it taller or shorter by altering that ratio. For instance, a 16/5 aspect ratio would make for a shorter dashboard, while a 16/18 ratio would mean a taller one.

    The custom aspect ratio is optional. If you omit it, the component will default to 16/13.

    <DuneDashboard source="" label="16/5 aspect ratio. Very short!" aspectRatio="16/5" />
    <DuneDashboard source="" label="16/18 aspect ratio. Very tall!" aspectRatio="16/18" />

Note on mobile view

The embedded dashboards will adapt to narrow phone screens to some extent, but Dune's support for it isn't great. The legend might overlap with the graph, or disappear entirely if there's not enough space.

It is strongly recommended that you test how the page looks on a phone screen and tweak the aspect ratio for any given dashboard accordingly. Sometimes it helps. Sometimes it doesn't. But it's important to keep that in mind.

If all else fails, a good label will get you very far:

As a last tip, you can use your browser's Dev Tools to mess with the page's dimensions, to simulate a phone screen! In Chrome, on Mac, you can hit ⌘+⌥+i to open Dev Tools, then ⌘+⇧+m to turn on the mobile view simulator.

Component to let you embed a Dune dashboard to a blog post. Well, technically any embedding.

Gives you control over:
- Source: The URL for the embedded element
- Label: Explanatory text added to the bottom of the embedding; Accepts HTML
- Aspect Ratio: Control the proportions of the element
@gkoscky gkoscky added the enhancement New feature or request label Dec 20, 2023
@gkoscky gkoscky self-assigned this Dec 20, 2023
Copy link

vercel bot commented Dec 20, 2023

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

Name Status Preview Comments Updated (UTC)
flashbots-writings-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2023 5:15pm

Copy link
Collaborator

@deadpine deadpine left a comment

Choose a reason for hiding this comment

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

Looks great! Good job @gkoscky! I'd just change the background color for a more subtle one.

src/components/DuneDashboard/styles.module.scss Outdated Show resolved Hide resolved
@deadpine deadpine merged commit c1148f5 into main Dec 20, 2023
3 checks passed
@deadpine deadpine deleted the gkoscky/dune-dashboard-component branch December 20, 2023 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants