-
Notifications
You must be signed in to change notification settings - Fork 123
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
Update _RenderFormInput.tsx featue Ehancement #67
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ed63b26
Update _RenderFormInput.tsx featue Ehancement
Ktbch 34d244e
Merge branch 'dashpresshq:master' into master
Ktbch 777b172
Update _RenderFormInput.tsx
Ktbch 2179048
Create FormPasswordInput.tsx
Ktbch 8d71754
Update Icons.tsx
Ktbch 1adf8d2
Update FormPasswordInput.tsx
Ktbch 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 |
---|---|---|
|
@@ -11,6 +11,9 @@ | |
import { FormRichTextArea } from "frontend/design-system/components/Form/FormRichTextArea"; | ||
import { useExtendRenderFormInputProps } from "frontend/views/data/portal"; | ||
import { useLingui } from "@lingui/react"; | ||
import { msg } from "@lingui/macro"; | ||
import { useToggle } from "frontend/hooks/state/useToggleState"; | ||
import { FormPasswordInput } from "frontend/design-system/components/Form/FormPasswordInput"; | ||
import { IRenderFormInputProps } from "./types"; | ||
|
||
export function RenderFormInput(props: IRenderFormInputProps) { | ||
|
@@ -28,6 +31,7 @@ | |
onChange, | ||
} = useExtendRenderFormInputProps(props); | ||
const { _ } = useLingui(); | ||
const showPassword = useToggle(); | ||
const formProps = { | ||
label, | ||
required, | ||
|
@@ -70,13 +74,37 @@ | |
|
||
switch (type) { | ||
case "email": | ||
case "password": | ||
case "url": | ||
case "color": | ||
return <FormInput type={type} {...formProps} />; | ||
case "number": | ||
return <FormNumberInput {...formProps} />; | ||
|
||
case "password": | ||
return ( | ||
<FormPasswordInput | ||
type={showPassword.isOn ? "text" : "password"} | ||
Check failure on line 85 in src/frontend/components/SchemaForm/_RenderFormInput.tsx GitHub Actions / build
|
||
{...formProps} | ||
rightActions={ | ||
showPassword.isOn | ||
? [ | ||
{ | ||
systemIcon: "Eye", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this
to |
||
action() { | ||
showPassword.toggle(); | ||
}, | ||
label: msg`Hide Password`, | ||
}, | ||
] | ||
: [ | ||
{ | ||
systemIcon: "EyeOff", | ||
action: showPassword.toggle, | ||
label: msg`Show Password`, | ||
}, | ||
] | ||
} | ||
/> | ||
); | ||
case "datetime-local": | ||
return <FormDateInput {...formProps} />; | ||
|
||
|
23 changes: 23 additions & 0 deletions
23
src/frontend/design-system/components/Form/FormPasswordInput.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,23 @@ | ||
import { useLingui } from "@lingui/react"; | ||
import { ISharedFormInput } from "./_types"; | ||
import { generateFormArias, wrapLabelAndError } from "./_wrapForm"; | ||
import { Input } from "./Styles"; | ||
|
||
interface IFormInput extends ISharedFormInput {} | ||
|
||
export const FormPasswordInput = (formInput: IFormInput) => { | ||
const { input, type, disabled, meta, placeholder, ...rest } = formInput; | ||
const { _ } = useLingui(); | ||
return wrapLabelAndError( | ||
<Input | ||
{...input} | ||
{...rest} | ||
{...generateFormArias(meta)} | ||
type={type} | ||
id={formInput.input.name} | ||
placeholder={placeholder ? _(placeholder) : null} | ||
disabled={disabled} | ||
/>, | ||
formInput | ||
); | ||
}; |
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.
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.
Can you move all the logic here to the new password component
Like here it should just be
everything else should be in the component
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.
Got It