fix(striker-ui): use contained variant button in file components

main
Tsu-ba-me 3 years ago
parent bf7e786c03
commit f8b3fb6787
  1. 21
      striker-ui/components/Files/FileEditForm.tsx
  2. 15
      striker-ui/components/Files/FileUploadForm.tsx
  3. 25
      striker-ui/components/Files/StyledContainedButton.tsx

@ -4,14 +4,14 @@ import {
useEffect, useEffect,
useState, useState,
} from 'react'; } from 'react';
import { Box, Button, Checkbox, checkboxClasses } from '@mui/material'; import { Box, Checkbox, checkboxClasses } from '@mui/material';
import { GREY, TEXT } from '../../lib/consts/DEFAULT_THEME'; import { GREY, TEXT } from '../../lib/consts/DEFAULT_THEME';
import { BodyText } from '../Text';
import FileInfo from './FileInfo'; import FileInfo from './FileInfo';
import fetchJSON from '../../lib/fetchers/fetchJSON'; import fetchJSON from '../../lib/fetchers/fetchJSON';
import mainAxiosInstance from '../../lib/singletons/mainAxiosInstance'; import mainAxiosInstance from '../../lib/singletons/mainAxiosInstance';
import StyledContainedButton from './StyledContainedButton';
type FileEditProps = { type FileEditProps = {
filesOverview: FileOverviewMetadata[]; filesOverview: FileOverviewMetadata[];
@ -127,6 +127,9 @@ const FileEditForm = ({ filesOverview }: FileEditProps): JSX.Element => {
sx={{ sx={{
display: 'flex', display: 'flex',
flexDirection: 'row', flexDirection: 'row',
'& > :last-child': {
flexGrow: 1,
},
}} }}
> >
<Checkbox <Checkbox
@ -142,9 +145,7 @@ const FileEditForm = ({ filesOverview }: FileEditProps): JSX.Element => {
}} }}
/> />
<FileInfo <FileInfo
fileName={fileName} {...{ fileName, fileType, fileLocations }}
fileType={fileType}
fileLocations={fileLocations}
onChange={generateFileInfoChangeHandler(fileIndex)} onChange={generateFileInfoChangeHandler(fileIndex)}
/> />
</Box> </Box>
@ -152,12 +153,10 @@ const FileEditForm = ({ filesOverview }: FileEditProps): JSX.Element => {
)} )}
{filesToEdit.length > 0 && ( {filesToEdit.length > 0 && (
<Box sx={{ display: 'flex', flexDirection: 'row' }}> <Box sx={{ display: 'flex', flexDirection: 'row' }}>
<Button onClick={purgeFiles} sx={{ textTransform: 'none' }}> <StyledContainedButton onClick={purgeFiles}>
<BodyText text="Purge" /> Purge
</Button> </StyledContainedButton>
<Button sx={{ textTransform: 'none' }} type="submit"> <StyledContainedButton type="submit">Update</StyledContainedButton>
<BodyText text="Update" />
</Button>
</Box> </Box>
)} )}
</Box> </Box>

@ -5,7 +5,7 @@ import {
useRef, useRef,
useState, useState,
} from 'react'; } from 'react';
import { Box, Button, Input, InputLabel } from '@mui/material'; import { Box, Input, InputLabel } from '@mui/material';
import EventEmitter from 'events'; import EventEmitter from 'events';
import { UPLOAD_FILE_TYPES } from '../../lib/consts/UPLOAD_FILE_TYPES'; import { UPLOAD_FILE_TYPES } from '../../lib/consts/UPLOAD_FILE_TYPES';
@ -14,6 +14,7 @@ import FileInfo from './FileInfo';
import { ProgressBar } from '../Bars'; import { ProgressBar } from '../Bars';
import { BodyText } from '../Text'; import { BodyText } from '../Text';
import mainAxiosInstance from '../../lib/singletons/mainAxiosInstance'; import mainAxiosInstance from '../../lib/singletons/mainAxiosInstance';
import StyledContainedButton from './StyledContainedButton';
type FileUploadFormProps = { type FileUploadFormProps = {
onFileUploadComplete?: () => void; onFileUploadComplete?: () => void;
@ -146,7 +147,13 @@ const FileUploadForm = (
return ( return (
<form onSubmit={uploadFiles}> <form onSubmit={uploadFiles}>
<Box sx={{ display: 'flex', flexDirection: 'column' }}> <Box
sx={{
display: 'flex',
flexDirection: 'column',
'> :not(:first-child)': { marginTop: '1em' },
}}
>
<InputLabel htmlFor="select-file"> <InputLabel htmlFor="select-file">
<Input <Input
id="select-file" id="select-file"
@ -202,9 +209,7 @@ const FileUploadForm = (
), ),
)} )}
{selectedFiles.length > 0 && ( {selectedFiles.length > 0 && (
<Button sx={{ textTransform: 'none' }} type="submit"> <StyledContainedButton type="submit">Upload</StyledContainedButton>
<BodyText text="Upload" />
</Button>
)} )}
</Box> </Box>
</form> </form>

@ -0,0 +1,25 @@
import { Button, ButtonProps, styled } from '@mui/material';
import { BLACK, GREY, TEXT } from '../../lib/consts/DEFAULT_THEME';
const StyledButton = styled(Button)({
backgroundColor: TEXT,
color: BLACK,
textTransform: 'none',
'&:hover': {
backgroundColor: GREY,
},
});
const StyledContainedButton = ({
children,
onClick,
type,
}: ButtonProps): JSX.Element => (
<StyledButton {...{ onClick, type }} variant="contained">
{children}
</StyledButton>
);
export default StyledContainedButton;
Loading…
Cancel
Save