-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: put toggle + disclaimer (#237)
Adds a toggle to update which graphql endpoint the logs and state are pulled from. ![gipp](https://github.com/near/queryapi/assets/25015977/65c0a7dd-7e0d-4d0d-8a66-fd35a2e9d0b3)
- Loading branch information
Showing
5 changed files
with
174 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"REPL_ACCOUNT_ID": "dev-queryapi.dataplatform.near", | ||
"REPL_GRAPHQL_ENDPOINT": "https://near-queryapi.dev.api.pagoda.co", | ||
"REPL_GRAPHQL_ENDPOINT_V2": "https://queryapi-hasura-graphql-mainnet-vcqilefdcq-ew.a.run.app", | ||
"REPL_EXTERNAL_APP_URL": "https://queryapi-frontend-vcqilefdcq-ew.a.run.app", | ||
"REPL_REGISTRY_CONTRACT_ID": "dev-queryapi.dataplatform.near" | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"REPL_ACCOUNT_ID": "dataplatform.near", | ||
"REPL_GRAPHQL_ENDPOINT": "https://near-queryapi.api.pagoda.co", | ||
"REPL_GRAPHQL_ENDPOINT_V2": "https://queryapi-hasura-graphql-mainnet-vcqilefdcq-ew.a.run.app", | ||
"REPL_EXTERNAL_APP_URL": "http://localhost:3000", | ||
"REPL_REGISTRY_CONTRACT_ID": "queryapi.dataplatform.near" | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"REPL_ACCOUNT_ID": "dataplatform.near", | ||
"REPL_GRAPHQL_ENDPOINT": "https://near-queryapi.api.pagoda.co", | ||
"REPL_EXTERNAL_APP_URL": "https://queryapi-frontend-24ktefolwq-ew.a.run.app", | ||
"REPL_GRAPHQL_ENDPOINT_V2": "https://queryapi-hasura-graphql-mainnet-vcqilefdcq-ew.a.run.app", | ||
"REPL_EXTERNAL_APP_URL": "http://localhost:3000", | ||
"REPL_REGISTRY_CONTRACT_ID": "queryapi.dataplatform.near" | ||
} |
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,78 @@ | ||
const ToggleRoot = styled.div` | ||
justify-content: space-between; | ||
width: fit-content; | ||
max-width: 100%; | ||
`; | ||
|
||
const ToggleSwitchRoot = styled("Switch.Root")` | ||
all: unset; | ||
display: block; | ||
width: 42px; | ||
height: 25px; | ||
background-color: #d1d1d1; | ||
border-radius: 9999px; | ||
position: relative; | ||
box-shadow: 0 2px 10px var(--blackA7); | ||
&[data-state="checked"] { | ||
background-color: #00d084; | ||
} | ||
&[data-disabled=""] { | ||
opacity: 0.7; | ||
} | ||
`; | ||
|
||
const ToggleSwitchThumb = styled("Switch.Thumb")` | ||
all: unset; | ||
display: block; | ||
width: 21px; | ||
height: 21px; | ||
border-radius: 9999px; | ||
transition: transform 100ms; | ||
transform: translateX(2px); | ||
will-change: transform; | ||
&[data-state="checked"] { | ||
transform: translateX(19px); | ||
} | ||
`; | ||
|
||
const ToggleLabel = styled.label` | ||
white-space: nowrap; | ||
`; | ||
|
||
const Toggle = ({ | ||
active, | ||
className, | ||
direction, | ||
disabled, | ||
key, | ||
label, | ||
onSwitch, | ||
...rest | ||
}) => ( | ||
<ToggleRoot | ||
className={[ | ||
"d-flex justify-content-between, align-items-center gap-3", | ||
direction === "rtl" ? "flex-row-reverse" : "", | ||
className, | ||
].join(" ")} | ||
{...rest} | ||
> | ||
<ToggleLabel htmlFor={`toggle-${key}`}>{label}</ToggleLabel> | ||
|
||
<ToggleSwitchRoot | ||
checked={active} | ||
className="shadow-none" | ||
id={`toggle-${key}`} | ||
onCheckedChange={disabled ? null : onSwitch} | ||
title={disabled ? `Permanently ${active ? "enabled" : "disabled"}` : null} | ||
{...{ disabled }} | ||
> | ||
{!disabled && <ToggleSwitchThumb className="bg-light shadow" />} | ||
</ToggleSwitchRoot> | ||
</ToggleRoot> | ||
); | ||
|
||
return Toggle(props); |