-
Notifications
You must be signed in to change notification settings - Fork 1
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
PE-5965: gateways page (start gateway, gateway information banner) #6
Merged
kunstmusik
merged 35 commits into
develop
from
PE-5965-gateways-page-join-network-manage-gateway
May 10, 2024
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
0b953fe
chore: switch to arrow functions
kunstmusik 9b5dcfa
chore: refactor out base modal component
kunstmusik d2faef5
feat: implemented gateway initial banner
kunstmusik cffcff8
fix: disable closing dialogs with escape key and outside dialog mouse…
kunstmusik 3cbf434
chore: bump ar.io/sdk to 1.0.4
kunstmusik 60f16ce
feat: initial implementation of Start Gateway modal
kunstmusik 18c8420
fix: minor adjustments to tidy code and remove use of form element
kunstmusik 7a6c69e
fix: add title attribute to switch component
kunstmusik 4681919
fix: dependency issue with useEffect
kunstmusik 175cc43
feat: add creating ArIO writeable SDK and implement call to joinNetwo…
kunstmusik 841eb6c
fix: update label and note field validation to match contract require…
kunstmusik 7888fa0
feat: implemented banner display for when gateway is found for user
kunstmusik 79b89ba
fix: text alignment formatting with gateway information labels
kunstmusik 8b4b9b2
chore(nav): disable navigation options for unimplemented sections
kunstmusik a107bb5
fix(start-gateway): fix form validation and adjusted placeholder text…
kunstmusik c309474
fix: formaat IO for operator stake using commas and max 1 fractional …
kunstmusik 1cbb1a4
fix: add blocking message modal to show message to user while awaitin…
kunstmusik 3ff3652
feat: add lottie ario spinner animation to blocking message dialog
kunstmusik f748bbe
feat(join network): added success dialog, recording of pending gatewa…
kunstmusik 03d34af
fix: style error notifications using custom toast component
kunstmusik 6a09920
chore: store pending data cache by wallet address to account for chan…
kunstmusik eaff862
fix: initialize arweave instance using environment or default values
kunstmusik a3911b0
chore: updated @ar.io/sdk to 1.0.6
kunstmusik d694ee2
chore: add vscode settings file with insertFinalNewline enabled
kunstmusik 6f70b7c
fix: typo
kunstmusik c378954
chore: updated comment to further clarify
kunstmusik aec3307
Merge branch 'PE-5965-gateways-page-join-network-manage-gateway' of g…
kunstmusik e1de085
chore: remove unnecessary optional chaining operator
kunstmusik 60b6e5a
chore: removed dead code
kunstmusik f04239b
chore: introduce constant to clarify code
kunstmusik dc13f4f
chore: introduce constants to clarify code
kunstmusik 4eefb91
chore: simplify repeated code
kunstmusik 39ecbf1
chore: clarify code using constant object map
kunstmusik b84aa43
chore: add delay to utils
kunstmusik cdfe25f
fix: validation error messages
kunstmusik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"files.insertFinalNewline": true | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,134 @@ | ||
import * as Tooltip from '@radix-ui/react-tooltip'; | ||
import { FormErrorIcon } from '../icons'; | ||
|
||
export enum RowType { | ||
TOP, | ||
MIDDLE, | ||
BOTTOM, | ||
SINGLE, | ||
} | ||
|
||
const ROUND_STYLES = { | ||
[RowType.TOP]: 'rounded-t-md', | ||
[RowType.BOTTOM]: 'rounded-b-md', | ||
[RowType.SINGLE]: 'rounded-md', | ||
[RowType.MIDDLE]: '', | ||
}; | ||
|
||
const FormRow = ({ | ||
formPropertyName, | ||
formState, | ||
placeholder, | ||
enabled = true, | ||
setFormState, | ||
errorMessages, | ||
setErrorMessages, | ||
label, | ||
rowType = RowType.MIDDLE, | ||
leftComponent, | ||
rightComponent, | ||
validateProperty, | ||
}: { | ||
formPropertyName: string; | ||
placeholder?: string; | ||
enabled?: boolean; | ||
formState: Record<string, string>; | ||
setFormState: (formState: Record<string, string>) => void; | ||
errorMessages: Record<string, string>; | ||
setErrorMessages: (errorMessages: Record<string, string>) => void; | ||
label: string; | ||
rowType?: RowType; | ||
leftComponent?: JSX.Element; | ||
rightComponent?: JSX.Element; | ||
validateProperty: (value: string) => string | undefined; | ||
}) => { | ||
const roundStyle = ROUND_STYLES[rowType]; | ||
|
||
const errorMessage = errorMessages[formPropertyName]; | ||
const hasError = enabled && errorMessage?.trim().length > 0; | ||
|
||
return ( | ||
<> | ||
<div className="bg-grey-900 pb-px"> | ||
<div className="h-[39px] bg-grey-1000 px-[24px] py-[12px] text-xs text-low"> | ||
{label} | ||
</div> | ||
</div> | ||
<div> | ||
<div | ||
className={[ | ||
'h-[40px] overflow-hidden from-gradient-primary-start to-gradient-primary-end p-px focus-within:bg-gradient-to-r', | ||
hasError | ||
? 'bg-red-600' | ||
: 'bg-grey-800 focus-within:p-px', | ||
roundStyle, | ||
].join(' ')} | ||
> | ||
<div | ||
className={`flex h-[38px] items-center gap-[3px] overflow-hidden bg-grey-1000 ${roundStyle}`} | ||
> | ||
{leftComponent} | ||
<input | ||
className={ | ||
'size-full overflow-hidden border-none bg-grey-1000 px-[24px] py-[12px] text-sm text-mid outline-none placeholder:text-grey-600 focus:text-high' | ||
} | ||
type="text" | ||
contentEditable={enabled} | ||
readOnly={!enabled} | ||
placeholder={placeholder} | ||
value={enabled ? formState[formPropertyName] : ''} | ||
onChange={(e) => { | ||
if (hasError) { | ||
const cleared = { ...errorMessages }; | ||
delete cleared[formPropertyName]; | ||
setErrorMessages(cleared); | ||
} | ||
setFormState({ | ||
...formState, | ||
[formPropertyName]: e.target.value, | ||
}); | ||
}} | ||
onBlur={() => { | ||
const errMessage = validateProperty( | ||
formState[formPropertyName], | ||
); | ||
if (errMessage) { | ||
setErrorMessages({ | ||
...errorMessages, | ||
[formPropertyName]: errMessage, | ||
}); | ||
} else { | ||
const cleared = { ...errorMessages }; | ||
delete cleared[formPropertyName]; | ||
setErrorMessages(cleared); | ||
} | ||
}} | ||
/> | ||
{hasError && ( | ||
<div className="relative flex px-[12px] text-red-600"> | ||
<Tooltip.Provider> | ||
<Tooltip.Root> | ||
<Tooltip.Trigger> | ||
<FormErrorIcon /> | ||
</Tooltip.Trigger> | ||
<Tooltip.Portal> | ||
<Tooltip.Content className="z-50 w-fit rounded-md bg-red-1000 px-[24px] py-[12px]"> | ||
<Tooltip.Arrow className="fill-red-1000" /> | ||
<div className="text-sm text-red-600"> | ||
{errorMessage} | ||
</div> | ||
</Tooltip.Content> | ||
</Tooltip.Portal> | ||
</Tooltip.Root> | ||
</Tooltip.Provider> | ||
</div> | ||
)} | ||
{rightComponent} | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default FormRow; |
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,31 @@ | ||
import { Switch } from '@headlessui/react'; | ||
|
||
const FormSwitch = ({ | ||
checked, | ||
onChange, | ||
title, | ||
}: { | ||
checked: boolean; | ||
onChange: (checked: boolean) => void; | ||
title: string; | ||
}) => { | ||
return ( | ||
<Switch | ||
className={`${ | ||
checked ? 'bg-green-600' : 'bg-grey-800' | ||
} relative inline-flex h-[18px] w-[30px] items-center rounded-full border border-transparent-100-8`} | ||
checked={checked} | ||
onChange={onChange} | ||
title={title} | ||
> | ||
<span className="sr-only"></span> | ||
<span | ||
className={`${ | ||
checked ? 'translate-x-[14px]' : 'translate-x-[2px]' | ||
} inline-block size-[12px] rounded-full ${checked ? 'bg-neutrals-1100' : 'bg-neutrals-100'} transition`} | ||
/> | ||
</Switch> | ||
); | ||
}; | ||
|
||
export default FormSwitch; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this interact with the component at all? Might be nice to wrap in a custom hook that describes what we're setting up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are dealing with global app state stored in zustand. Components in the app will get updates by using useGlobalStore() with selectors (so they're only listening to relevant changes in the store).
In the next story, I'm adding react-query for fetching and caching data from servers (i.e., ar.io/sdk app calls). zustand will remain for global app state. The plan for rules right now will be:
Will be revisiting this code and elsewhere as I add in react-query and add hooks for those.