-
Notifications
You must be signed in to change notification settings - Fork 219
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 #2211 from pyth-network/cprussin/add-test-feed-toggle
feat(insights): add a toggle to include test price components
- Loading branch information
Showing
16 changed files
with
275 additions
and
521 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
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
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,83 @@ | ||
@use "../theme"; | ||
|
||
.switch { | ||
cursor: pointer; | ||
line-height: theme.spacing(4); | ||
|
||
.indicator { | ||
flex: none; | ||
width: theme.spacing(6); | ||
height: theme.spacing(4); | ||
background: theme.color("border"); | ||
border-radius: theme.border-radius("2xl"); | ||
display: inline-flex; | ||
align-items: center; | ||
padding: 0 theme.spacing(0.5); | ||
margin-right: theme.spacing(2); | ||
justify-content: flex-start; | ||
transition-property: background-color, border-color, outline-color; | ||
transition-duration: 100ms; | ||
transition-timing-function: linear; | ||
border: 1px solid transparent; | ||
outline-offset: 0; | ||
outline: theme.spacing(1) solid transparent; | ||
|
||
.dot { | ||
width: theme.spacing(2.5); | ||
height: theme.spacing(2.5); | ||
background-color: theme.color("background", "primary"); | ||
border-radius: theme.border-radius("full"); | ||
transition: background-color 100ms linear; | ||
} | ||
} | ||
|
||
.label { | ||
@include theme.text("sm", "normal"); | ||
|
||
display: inline-block; | ||
} | ||
|
||
&[data-hovered] { | ||
.indicator { | ||
background-color: theme.color("forms", "input", "hover", "border"); | ||
} | ||
} | ||
|
||
&[data-selected] { | ||
.indicator { | ||
justify-content: flex-end; | ||
background-color: theme.color( | ||
"button", | ||
"primary", | ||
"background", | ||
"normal" | ||
); | ||
} | ||
} | ||
|
||
&[data-disabled], | ||
&[data-pending] { | ||
.indicator { | ||
background-color: theme.color("button", "disabled", "background"); | ||
|
||
.dot { | ||
background-color: theme.color("button", "disabled", "foreground"); | ||
} | ||
} | ||
} | ||
|
||
&[data-disabled] { | ||
cursor: not-allowed; | ||
} | ||
|
||
&[data-pending] { | ||
cursor: wait; | ||
} | ||
|
||
&[data-focus-visible] { | ||
.indicator { | ||
border-color: theme.color("focus"); | ||
outline-color: theme.color("focus-dim"); | ||
} | ||
} | ||
} |
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,41 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { Switch as SwitchComponent } from "./index.js"; | ||
|
||
const meta = { | ||
component: SwitchComponent, | ||
argTypes: { | ||
isDisabled: { | ||
control: "boolean", | ||
table: { | ||
category: "State", | ||
}, | ||
}, | ||
isPending: { | ||
control: "boolean", | ||
table: { | ||
category: "State", | ||
}, | ||
}, | ||
onChange: { | ||
table: { | ||
category: "Behavior", | ||
}, | ||
}, | ||
children: { | ||
control: "text", | ||
table: { | ||
category: "Label", | ||
}, | ||
}, | ||
}, | ||
} satisfies Meta<typeof SwitchComponent>; | ||
export default meta; | ||
|
||
export const Switch = { | ||
args: { | ||
children: "Click me!", | ||
isDisabled: false, | ||
isPending: false, | ||
}, | ||
} satisfies StoryObj<typeof SwitchComponent>; |
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,46 @@ | ||
import clsx from "clsx"; | ||
import { motion } from "motion/react"; | ||
import type { ComponentProps } from "react"; | ||
|
||
import styles from "./index.module.scss"; | ||
import { Switch as UnstyledSwitch } from "../unstyled/Switch/index.js"; | ||
|
||
type OwnProps = { | ||
isPending?: boolean | undefined; | ||
}; | ||
type Props = Omit<ComponentProps<typeof UnstyledSwitch>, keyof OwnProps> & | ||
OwnProps; | ||
|
||
export const Switch = ({ | ||
children, | ||
className, | ||
isPending, | ||
isDisabled, | ||
...props | ||
}: Props) => ( | ||
<UnstyledSwitch | ||
className={clsx(styles.switch, className)} | ||
isDisabled={isDisabled === true || isPending === true} | ||
data-pending={isPending ? "" : undefined} | ||
{...props} | ||
> | ||
{(args) => ( | ||
<> | ||
<div className={styles.indicator}> | ||
<motion.div | ||
layout | ||
className={styles.dot} | ||
transition={{ | ||
type: "spring", | ||
stiffness: 500, | ||
damping: 20, | ||
}} | ||
/> | ||
</div> | ||
<div className={styles.label}> | ||
{typeof children === "function" ? children(args) : children} | ||
</div> | ||
</> | ||
)} | ||
</UnstyledSwitch> | ||
); |
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
3 changes: 3 additions & 0 deletions
3
packages/component-library/src/unstyled/SearchField/index.tsx
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,3 @@ | ||
"use client"; | ||
|
||
export { SearchField } from "react-aria-components"; |
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,3 @@ | ||
"use client"; | ||
|
||
export { Switch } from "react-aria-components"; |
Oops, something went wrong.