-
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.
Signed-off-by: hxtree <[email protected]>
- Loading branch information
Showing
10 changed files
with
94 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Paper, Link, Button, TextField, faArrowRight, FontAwesomeIcon } from '@cats-cradle/design-system/dist/main'; | ||
|
||
export default function LoginPage() { | ||
return ( | ||
<main className="container"> | ||
<Paper elevation="1"> | ||
<h1>Log In</h1> | ||
<TextField id="email-address" label="Email Address" type="text"/> | ||
|
||
<Link href="/forgot-password">Forgot Password</Link> | ||
<TextField id="password" label="Password" type="password"/> | ||
<Button onClick={()=>{}} color="primary">Log In <FontAwesomeIcon icon={faArrowRight}/></Button> | ||
</Paper> | ||
</main> | ||
); | ||
} |
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
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
55 changes: 46 additions & 9 deletions
55
clients/design-system/src/components/TextField/TextField.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 |
---|---|---|
@@ -1,13 +1,50 @@ | ||
import MUITextField, { | ||
TextFieldProps as MUITextFieldProps, | ||
} from '@mui/material/TextField'; | ||
import React from 'react'; | ||
|
||
export type TextFieldProps = MUITextFieldProps; | ||
export type TextFieldProps = { | ||
id?: string; | ||
type?: 'password' | 'text' | 'number'; | ||
value?: string | number | undefined; | ||
label?: string; | ||
helpBlock?: React.ReactNode; | ||
size?: 'small' | 'medium' | 'large'; | ||
invalid?: string; | ||
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void; | ||
variant?: string; | ||
} | ||
|
||
export const TextField = (props: TextFieldProps) => { | ||
const { ...muiProps } = props; | ||
// https://getbootstrap.com/docs/5.0/forms/validation/ | ||
export const TextField = (props: TextFieldProps): JSX.Element => { | ||
const { id, label, type, helpBlock, value, size, invalid, onChange } = props; | ||
|
||
return <MUITextField {...muiProps}/>; | ||
}; | ||
const classNames = []; | ||
classNames.push('form-control'); | ||
switch(size){ | ||
case 'small': | ||
classNames.push('input-group-sm') | ||
break; | ||
case 'large': | ||
classNames.push('input-group-lg') | ||
break; | ||
case 'medium': | ||
default: | ||
} | ||
|
||
export default TextField; | ||
// TODO improve validation | ||
// TODO add icons left (e.g. $) or right (e.g. calendar) | ||
// TODO tip tool for info right top | ||
|
||
if(helpBlock){ | ||
return (<> | ||
{label && <label htmlFor={ id } className="form-label">{ label }</label>} | ||
<input id={ id } type={ type } value={value} onChange={ onChange } className={classNames.join(' ')} aria-describedby={ `${id}HelpBlock` }/> | ||
{ helpBlock && <div id={ `${id}HelpBlock` } className="form-text">{ helpBlock }</div> } | ||
{ invalid && <div className="invalid-feedback">{ invalid }</div>} | ||
</>) | ||
} | ||
|
||
return (<> | ||
{label && <label htmlFor={ id } className="form-label">{ label }</label>} | ||
<input id={ id } type={ type } value={ value } onChange={ onChange }className={classNames.join(' ')}/> | ||
{ invalid && <div className="invalid-feedback">{ invalid }</div>} | ||
</>) | ||
}; |
18 changes: 0 additions & 18 deletions
18
clients/design-system/stories/components/molecules/Layout.stories.tsx
This file was deleted.
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