Skip to content

Commit

Permalink
feat: improve ui for input components
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcl-io committed Apr 27, 2021
1 parent a02c37e commit 1d91dfa
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
31 changes: 31 additions & 0 deletions src/components/Input/SingleLineInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { makeStyles, TextField, TextFieldProps } from '@material-ui/core';

const SingleLineInput = (props: TextFieldProps) => {
const { label, input } = useStyles();

return (
<div>
{props.label && (
<label className={label} htmlFor={props.name}>
{props.label}
</label>
)}
<TextField id={props.name} {...props} className={input} label={undefined} />
</div>
);
};

const useStyles = makeStyles((theme) => ({
label: {
display: 'block',
fontSize: '0.9rem',
fontWeight: theme.typography.fontWeightMedium,
marginBottom: theme.spacing(1),
},

input: {
width: '100%',
},
}));

export default SingleLineInput;
9 changes: 4 additions & 5 deletions src/containers/Sidebar/Files/FilterFiles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FormControl, makeStyles, TextField } from '@material-ui/core';
import React from 'react';
import { FormControl, makeStyles } from '@material-ui/core';
import SingleLineInput from '../../../components/Input/SingleLineInput';

interface Props {
onChange: (input: string) => void;
Expand All @@ -10,8 +10,8 @@ const FilterFiles = (props: Props) => {

return (
<FormControl fullWidth className={classes.formControl}>
<TextField
label='Search Files'
<SingleLineInput
placeholder='Search for notes'
variant='outlined'
autoComplete='off'
size='small'
Expand All @@ -23,7 +23,6 @@ const FilterFiles = (props: Props) => {

const useStyles = makeStyles((theme) => ({
formControl: {
display: 'flex',
marginTop: `-${theme.spacing(3)}px`,
marginBottom: `${theme.spacing(3)}px`,
},
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Checkbox,
FormControlLabel,
makeStyles,
TextField,
Typography,
useTheme,
} from '@material-ui/core';
Expand All @@ -21,6 +20,7 @@ import useCloudSyncLogin from '../../hooks/useCloudSyncLogin';
import { useEffect, useState } from 'react';
import { ErrorOrNull } from '../../hooks/useLoading';
import { defer, upperFirst } from 'lodash';
import SingleLineInput from '../../components/Input/SingleLineInput';

type FormFields = {
username: string;
Expand Down Expand Up @@ -151,7 +151,7 @@ const Login = () => {
}
/>

<TextField
<SingleLineInput
type='text'
name='username'
label='Username'
Expand All @@ -169,7 +169,7 @@ const Login = () => {
upperFirst(formik.errors.username)
}
/>
<TextField
<SingleLineInput
type='password'
name='password'
label='Password'
Expand Down
13 changes: 6 additions & 7 deletions src/pages/Signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Divider,
FormControlLabel,
makeStyles,
TextField,
Typography,
withStyles,
} from '@material-ui/core';
Expand All @@ -26,6 +25,7 @@ import prepareAndRegisterToCloudSync from '../../services/prepareAndRegisterToCl
import generateTokenFromPassword from '../../utils/generateTokenFromPassword';
import moment from 'moment';
import ExternalAnchor from '../../components/Typography/ExternalAnchor';
import SingleLineInput from '../../components/Input/SingleLineInput';

const Signup = () => {
const classes = useStyles();
Expand Down Expand Up @@ -158,7 +158,7 @@ const Signup = () => {
{({ handleSubmit, handleChange, handleBlur, values, isSubmitting, errors, touched }) => (
<React.Fragment>
<form onSubmit={handleSubmit} autoComplete='off'>
<TextField
<SingleLineInput
name='username'
label='Username'
variant='outlined'
Expand All @@ -177,7 +177,7 @@ const Signup = () => {

<Divider />

<TextField
<SingleLineInput
type='password'
name='password'
label='Password'
Expand All @@ -194,7 +194,7 @@ const Signup = () => {
}
/>

<TextField
<SingleLineInput
type='password'
name='password2'
label='Confirm Password'
Expand Down Expand Up @@ -225,8 +225,7 @@ const Signup = () => {
<AccordionDetails>
<Typography variant='body2' color='textSecondary'>
You can choose to disable cloud sync. This means that your account and notes
stay on your device. Nothing touches a server. No one knows your account
exists.
stay on your device/browser. Nothing touches a cloud server.
</Typography>
<FormControlLabel
control={
Expand All @@ -246,7 +245,7 @@ const Signup = () => {
Learn more
</ExternalAnchor>
</Typography>
<TextField
<SingleLineInput
type='number'
name='iterations'
label='PBKDF2 Iterations'
Expand Down

0 comments on commit 1d91dfa

Please sign in to comment.