-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2408 from pyth-network/cprussin/ui-10-make-app-re…
…sponsive-handle-small-screen-sizes feat(insights): make app responsive
- Loading branch information
Showing
86 changed files
with
3,111 additions
and
1,362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@use "@pythnetwork/component-library/theme"; | ||
|
||
.cards { | ||
display: flex; | ||
flex-flow: row nowrap; | ||
align-items: stretch; | ||
gap: theme.spacing(6); | ||
overflow-x: auto; | ||
margin-left: calc(-1 * #{theme.$max-width-padding}); | ||
margin-right: calc(-1 * #{theme.$max-width-padding}); | ||
padding: theme.spacing(4) theme.$max-width-padding theme.spacing(4) | ||
theme.$max-width-padding; | ||
scroll-snap-type: x mandatory; | ||
scroll-padding-inline: theme.$max-width-padding; | ||
|
||
@include theme.breakpoint("sm") { | ||
padding-top: theme.spacing(6); | ||
padding-bottom: theme.spacing(6); | ||
} | ||
|
||
& > * { | ||
flex: none; | ||
width: 70vw; | ||
max-width: theme.spacing(70); | ||
scroll-snap-align: start; | ||
|
||
@include theme.breakpoint("sm") { | ||
flex: 1 0 theme.spacing(70); | ||
width: theme.spacing(70); | ||
max-width: unset; | ||
} | ||
} | ||
|
||
.publishersChart, | ||
.priceFeedsChart { | ||
& svg { | ||
cursor: pointer; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import clsx from "clsx"; | ||
import type { ComponentProps } from "react"; | ||
|
||
import styles from "./index.module.scss"; | ||
|
||
export const Cards = ({ className, ...props }: ComponentProps<"section">) => ( | ||
<section className={clsx(className, styles.cards)} {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
@use "@pythnetwork/component-library/theme"; | ||
|
||
.entityList { | ||
background: theme.color("background", "primary"); | ||
border-radius: theme.border-radius("xl"); | ||
list-style-type: none; | ||
padding: 0; | ||
margin: 0; | ||
|
||
.entityItem { | ||
padding: theme.spacing(3) theme.spacing(4); | ||
border-bottom: 1px solid theme.color("background", "secondary"); | ||
outline: theme.spacing(0.5) solid transparent; | ||
outline-offset: -#{theme.spacing(0.5)}; | ||
transition: | ||
outline-color 100ms linear, | ||
background-color 100ms linear; | ||
-webkit-tap-highlight-color: transparent; | ||
|
||
&[data-focus-visible] { | ||
outline: theme.spacing(0.5) solid theme.color("focus"); | ||
} | ||
|
||
&[data-href] { | ||
cursor: pointer; | ||
} | ||
|
||
&[data-hovered] { | ||
background-color: theme.color("button", "outline", "background", "hover"); | ||
} | ||
|
||
&[data-pressed] { | ||
background-color: theme.color( | ||
"button", | ||
"outline", | ||
"background", | ||
"active" | ||
); | ||
} | ||
|
||
&:first-child { | ||
border-top-left-radius: theme.border-radius("xl"); | ||
border-top-right-radius: theme.border-radius("xl"); | ||
} | ||
|
||
&:last-child { | ||
border-bottom-left-radius: theme.border-radius("xl"); | ||
border-bottom-right-radius: theme.border-radius("xl"); | ||
border-bottom: none; | ||
} | ||
|
||
.itemHeader, | ||
.itemDetailsItem { | ||
display: flex; | ||
flex-flow: row nowrap; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
|
||
.itemDetails { | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
gap: theme.spacing(2) theme.spacing(18); | ||
|
||
@include theme.breakpoint("sm") { | ||
grid-template-columns: repeat(2, 1fr); | ||
} | ||
|
||
.itemDetailsItem { | ||
height: theme.spacing(5); | ||
|
||
dt { | ||
@include theme.text("sm", "normal"); | ||
|
||
color: theme.color("muted"); | ||
} | ||
|
||
dd { | ||
margin: 0; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
"use client"; | ||
|
||
import { Skeleton } from "@pythnetwork/component-library/Skeleton"; | ||
import { | ||
GridList, | ||
GridListItem, | ||
} from "@pythnetwork/component-library/unstyled/GridList"; | ||
import clsx from "clsx"; | ||
import type { ComponentProps, ReactNode } from "react"; | ||
|
||
import styles from "./index.module.scss"; | ||
|
||
type Props<T extends string> = ComponentProps<typeof GridList<RowConfig<T>>> & { | ||
headerLoadingSkeleton?: ReactNode | undefined; | ||
label: string; | ||
fields: ({ | ||
id: T; | ||
name: ReactNode; | ||
} & ( | ||
| { loadingSkeleton?: ReactNode | undefined } | ||
| { loadingSkeletonWidth?: number | undefined } | ||
))[]; | ||
} & ( | ||
| { | ||
isLoading: true; | ||
rows?: RowConfig<T>[] | undefined; | ||
} | ||
| { | ||
isLoading?: false | undefined; | ||
rows: RowConfig<T>[]; | ||
} | ||
); | ||
|
||
type RowConfig<T extends string> = { | ||
id: string | number; | ||
data: Record<T, ReactNode>; | ||
header: ReactNode; | ||
href?: string; | ||
textValue: string; | ||
}; | ||
|
||
export const EntityList = <T extends string>({ | ||
fields, | ||
isLoading, | ||
rows, | ||
headerLoadingSkeleton, | ||
className, | ||
label, | ||
...props | ||
}: Props<T>) => ( | ||
<GridList | ||
className={clsx(styles.entityList, className)} | ||
items={isLoading ? [] : rows} | ||
aria-label={label} | ||
{...props} | ||
> | ||
{isLoading ? ( | ||
<GridListItem className={styles.entityItem ?? ""}> | ||
<div className={styles.itemHeader}>{headerLoadingSkeleton}</div> | ||
<dl className={styles.itemDetails}> | ||
{fields.map((field) => ( | ||
<div key={field.id} className={styles.itemDetailsItem}> | ||
<dt>{field.name}</dt> | ||
<dd> | ||
{"loadingSkeleton" in field ? ( | ||
field.loadingSkeleton | ||
) : ( | ||
<Skeleton | ||
width={ | ||
"loadingSkeletonWidth" in field | ||
? field.loadingSkeletonWidth | ||
: 20 | ||
} | ||
/> | ||
)} | ||
</dd> | ||
</div> | ||
))} | ||
</dl> | ||
</GridListItem> | ||
) : ( | ||
({ data, header, ...props }) => ( | ||
<GridListItem className={styles.entityItem ?? ""} {...props}> | ||
<div className={styles.itemHeader}>{header}</div> | ||
<dl className={styles.itemDetails}> | ||
{fields.map((field) => ( | ||
<div key={field.id} className={styles.itemDetailsItem}> | ||
<dt>{field.name}</dt> | ||
<dd>{data[field.id]}</dd> | ||
</div> | ||
))} | ||
</dl> | ||
</GridListItem> | ||
) | ||
)} | ||
</GridList> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.