-
Notifications
You must be signed in to change notification settings - Fork 1
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 #6 from ar-io/PE-5965-gateways-page-join-network-m…
…anage-gateway PE-5965: gateways page (start gateway, gateway information banner)
- Loading branch information
Showing
41 changed files
with
1,592 additions
and
151 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 |
---|---|---|
@@ -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.