-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💄(website) replace grommet input by cunningham input
- replace grommet input by cunningham input - move PrivateTextInputField to root/components/Text - refacto forms to fit new cunningham input text
- Loading branch information
Showing
28 changed files
with
408 additions
and
383 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
61 changes: 61 additions & 0 deletions
61
src/frontend/apps/standalone_site/src/components/Text/PrivateTextInputField.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,61 @@ | ||
import { Input } from '@openfun/cunningham-react'; | ||
import { Button } from 'grommet'; | ||
import { ComponentPropsWithRef, useState } from 'react'; | ||
import { defineMessages, useIntl } from 'react-intl'; | ||
|
||
import { ReactComponent as HideContent } from 'assets/svg/hide-content.svg'; | ||
import { ReactComponent as ShowContent } from 'assets/svg/show-content.svg'; | ||
|
||
const messages = defineMessages({ | ||
revealPassword: { | ||
defaultMessage: 'Show the password.', | ||
description: 'A18n label for the password button.', | ||
id: 'components.Text.PrivateTextInputfield.revealPassword', | ||
}, | ||
hidePassword: { | ||
defaultMessage: 'Hide the password.', | ||
description: 'A18n label for the hidden password button.', | ||
id: 'components.Text.PrivateTextInputfield.hidePassword', | ||
}, | ||
}); | ||
|
||
type InputProps = ComponentPropsWithRef<typeof Input>; | ||
|
||
interface PrivateTextInputFieldProps extends InputProps { | ||
revealButtonLabel?: string; | ||
hideButtonLabel?: string; | ||
} | ||
|
||
export const PrivateTextInputField = ({ | ||
label, | ||
revealButtonLabel, | ||
hideButtonLabel, | ||
...inputProps | ||
}: PrivateTextInputFieldProps) => { | ||
const intl = useIntl(); | ||
const [isHidden, setIsHidden] = useState(true); | ||
|
||
return ( | ||
<Input | ||
aria-label={label} | ||
label={label} | ||
fullWidth | ||
required | ||
rightIcon={ | ||
<Button | ||
a11yTitle={ | ||
isHidden | ||
? revealButtonLabel || intl.formatMessage(messages.revealPassword) | ||
: hideButtonLabel || intl.formatMessage(messages.hidePassword) | ||
} | ||
plain | ||
style={{ margin: '0 1rem' }} | ||
icon={isHidden ? <ShowContent /> : <HideContent />} | ||
onClick={() => setIsHidden(!isHidden)} | ||
/> | ||
} | ||
type={isHidden ? 'password' : 'text'} | ||
{...inputProps} | ||
/> | ||
); | ||
}; |
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
Oops, something went wrong.