Skip to content

Commit 4728370

Browse files
committed
File manager cleanup for mobile devices
1 parent 6ec2ae9 commit 4728370

File tree

9 files changed

+53
-40
lines changed

9 files changed

+53
-40
lines changed

resources/scripts/components/dashboard/ServerRow.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ export default ({ server, className }: { server: Server; className?: string }) =
155155
</div>
156156
<p css={tw`text-xs text-neutral-600 text-center mt-1`}>of {disklimit}</p>
157157
</div>
158-
159158
<div css={tw`flex-1 flex justify-end sm:hidden`}>
160159
<div css={tw`flex items-end text-right`}>
161160
<div

resources/scripts/components/elements/ConfirmationModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ const ConfirmationModal = ({ title, children, buttonText, onConfirmed }: Props)
1919
<>
2020
<h2 css={tw`text-2xl mb-6`}>{title}</h2>
2121
<p css={tw`text-sm`}>{children}</p>
22-
<div css={tw`flex items-center justify-end mt-8`}>
23-
<Button isSecondary onClick={() => dismiss()}>
22+
<div css={tw`flex flex-wrap items-center justify-end mt-8`}>
23+
<Button isSecondary onClick={() => dismiss()} css={tw`w-full sm:w-auto`}>
2424
Cancel
2525
</Button>
26-
<Button color={'red'} css={tw`ml-4`} onClick={() => onConfirmed()}>
26+
<Button color={'red'} css={tw`w-full sm:w-auto mt-4 sm:mt-0 sm:ml-4`} onClick={() => onConfirmed()}>
2727
{buttonText}
2828
</Button>
2929
</div>

resources/scripts/components/elements/Modal.tsx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import React, { useEffect, useMemo, useState } from 'react';
2-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3-
import { faTimes } from '@fortawesome/free-solid-svg-icons';
42
import Spinner from '@/components/elements/Spinner';
53
import tw from 'twin.macro';
6-
import styled from 'styled-components/macro';
4+
import styled, { css } from 'styled-components/macro';
75
import { breakpoint } from '@/theme';
86
import Fade from '@/components/elements/Fade';
97

@@ -26,25 +24,27 @@ export const ModalMask = styled.div`
2624
background: rgba(0, 0, 0, 0.70);
2725
`;
2826

29-
const ModalContainer = styled.div<{ alignTop?: boolean }>`
30-
${breakpoint('xs')`
31-
max-width: 95%;
32-
`};
33-
34-
${breakpoint('md')`
35-
max-width: 50%;
36-
`};
27+
const ModalContainer = styled.div<{ alignTop?: boolean }>`
28+
max-width: 95%;
29+
max-height: calc(100vh - 8rem);
30+
${breakpoint('md')`max-width: 75%`};
31+
${breakpoint('lg')`max-width: 50%`};
3732
3833
${tw`relative flex flex-col w-full m-auto`};
39-
max-height: calc(100vh - 8rem);
40-
// @todo max-w-screen-lg perhaps?
41-
${props => props.alignTop && 'margin-top: 10%'};
34+
${props => props.alignTop && css`
35+
margin-top: 20%;
36+
${breakpoint('md')`margin-top: 10%`};
37+
`};
4238
4339
& > .close-icon {
4440
${tw`absolute right-0 p-2 text-white cursor-pointer opacity-50 transition-all duration-150 ease-linear hover:opacity-100`};
45-
top: -2rem;
41+
top: -2.5rem;
4642
4743
&:hover {${tw`transform rotate-90`}}
44+
45+
& > svg {
46+
${tw`w-6 h-6`};
47+
}
4848
}
4949
`;
5050

@@ -80,6 +80,7 @@ const Modal: React.FC<ModalProps> = ({ visible, appear, dismissable, showSpinner
8080
>
8181
<ModalMask
8282
onClick={e => e.stopPropagation()}
83+
onContextMenu={e => e.stopPropagation()}
8384
onMouseDown={e => {
8485
if (isDismissable && closeOnBackground) {
8586
e.stopPropagation();
@@ -92,7 +93,14 @@ const Modal: React.FC<ModalProps> = ({ visible, appear, dismissable, showSpinner
9293
<ModalContainer alignTop={top}>
9394
{isDismissable &&
9495
<div className={'close-icon'} onClick={() => setRender(false)}>
95-
<FontAwesomeIcon icon={faTimes}/>
96+
<svg xmlns={'http://www.w3.org/2000/svg'} fill={'none'} viewBox={'0 0 24 24'} stroke={'currentColor'}>
97+
<path
98+
strokeLinecap={'round'}
99+
strokeLinejoin={'round'}
100+
strokeWidth={'2'}
101+
d={'M6 18L18 6M6 6l12 12'}
102+
/>
103+
</svg>
96104
</div>
97105
}
98106
{showSpinnerOverlay &&

resources/scripts/components/server/files/FileEditContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export default () => {
120120
/>
121121
</div>
122122
<div css={tw`flex justify-end mt-4`}>
123-
<div css={tw`rounded bg-neutral-900 mr-4`}>
123+
<div css={tw`flex-1 sm:flex-none rounded bg-neutral-900 mr-4`}>
124124
<Select value={mode} onChange={e => setMode(e.currentTarget.value)}>
125125
{Object.keys(modes).map(key => (
126126
<option key={key} value={key}>{modes[key]}</option>
@@ -129,13 +129,13 @@ export default () => {
129129
</div>
130130
{action === 'edit' ?
131131
<Can action={'file.update'}>
132-
<Button onClick={() => save()}>
132+
<Button css={tw`flex-1 sm:flex-none`} onClick={() => save()}>
133133
Save Content
134134
</Button>
135135
</Can>
136136
:
137137
<Can action={'file.create'}>
138-
<Button onClick={() => setModalVisible(true)}>
138+
<Button css={tw`flex-1 sm:flex-none`} onClick={() => setModalVisible(true)}>
139139
Create File
140140
</Button>
141141
</Can>

resources/scripts/components/server/files/FileManagerContainer.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import FileObjectRow from '@/components/server/files/FileObjectRow';
66
import FileManagerBreadcrumbs from '@/components/server/files/FileManagerBreadcrumbs';
77
import { FileObject } from '@/api/server/files/loadDirectory';
88
import NewDirectoryButton from '@/components/server/files/NewDirectoryButton';
9-
import { Link, useLocation } from 'react-router-dom';
9+
import { NavLink, useLocation } from 'react-router-dom';
1010
import Can from '@/components/elements/Can';
1111
import ServerError from '@/components/screens/ServerError';
1212
import tw from 'twin.macro';
@@ -81,16 +81,17 @@ export default () => {
8181
</CSSTransition>
8282
}
8383
<Can action={'file.create'}>
84-
<div css={tw`flex justify-end mt-8`}>
85-
<NewDirectoryButton/>
86-
<UploadButton/>
87-
<Button
88-
// @ts-ignore
89-
as={Link}
84+
<div css={tw`flex flex-wrap-reverse justify-end mt-4`}>
85+
<NewDirectoryButton css={tw`w-full flex-none mt-4 sm:mt-0 sm:w-auto sm:mr-4`}/>
86+
<UploadButton css={tw`flex-1 mr-4 sm:flex-none sm:mt-0`}/>
87+
<NavLink
9088
to={`/server/${id}/files/new${window.location.hash}`}
89+
css={tw`flex-1 sm:flex-none sm:mt-0`}
9190
>
92-
New File
93-
</Button>
91+
<Button css={tw`w-full`}>
92+
New File
93+
</Button>
94+
</NavLink>
9495
</div>
9596
</Can>
9697
</>

resources/scripts/components/server/files/NewDirectoryButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Button from '@/components/elements/Button';
1111
import { FileObject } from '@/api/server/files/loadDirectory';
1212
import useFlash from '@/plugins/useFlash';
1313
import useFileManagerSwr from '@/plugins/useFileManagerSwr';
14+
import { WithClassname } from '@/components/types';
1415

1516
interface Values {
1617
directoryName: string;
@@ -34,7 +35,7 @@ const generateDirectoryData = (name: string): FileObject => ({
3435
isEditable: () => false,
3536
});
3637

37-
export default () => {
38+
export default ({ className }: WithClassname) => {
3839
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
3940
const { clearAndAddHttpError } = useFlash();
4041
const [ visible, setVisible ] = useState(false);
@@ -95,7 +96,7 @@ export default () => {
9596
</Modal>
9697
)}
9798
</Formik>
98-
<Button isSecondary css={tw`mr-2`} onClick={() => setVisible(true)}>
99+
<Button isSecondary onClick={() => setVisible(true)} className={className}>
99100
Create Directory
100101
</Button>
101102
</>

resources/scripts/components/server/files/RenameFileModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ const RenameFileModal = ({ files, useMoveTerminology, ...props }: OwnProps) => {
6262
<Form css={tw`m-0`}>
6363
<div
6464
css={[
65-
tw`flex`,
65+
tw`flex flex-wrap`,
6666
useMoveTerminology ? tw`items-center` : tw`items-end`,
6767
]}
6868
>
69-
<div css={tw`flex-1 mr-6`}>
69+
<div css={tw`w-full sm:flex-1 sm:mr-4`}>
7070
<Field
7171
type={'string'}
7272
id={'file_name'}
@@ -79,8 +79,8 @@ const RenameFileModal = ({ files, useMoveTerminology, ...props }: OwnProps) => {
7979
autoFocus
8080
/>
8181
</div>
82-
<div>
83-
<Button>{useMoveTerminology ? 'Move' : 'Rename'}</Button>
82+
<div css={tw`w-full sm:w-auto mt-4 sm:mt-0`}>
83+
<Button css={tw`w-full`}>{useMoveTerminology ? 'Move' : 'Rename'}</Button>
8484
</div>
8585
</div>
8686
{useMoveTerminology &&

resources/scripts/components/server/files/UploadButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
1111
import useFlash from '@/plugins/useFlash';
1212
import useFileManagerSwr from '@/plugins/useFileManagerSwr';
1313
import { ServerContext } from '@/state/server';
14+
import { WithClassname } from '@/components/types';
1415

1516
const InnerContainer = styled.div`
1617
max-width: 600px;
1718
${tw`bg-black w-full border-4 border-primary-500 border-dashed rounded p-10 mx-10`}
1819
`;
1920

20-
export default () => {
21+
export default ({ className }: WithClassname) => {
2122
const fileUploadInput = useRef<HTMLInputElement>(null);
2223
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
2324
const [ visible, setVisible ] = useState(false);
@@ -114,7 +115,7 @@ export default () => {
114115
}}
115116
/>
116117
<Button
117-
css={tw`mr-2`}
118+
className={className}
118119
onClick={() => {
119120
fileUploadInput.current
120121
? fileUploadInput.current.click()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface WithClassname {
2+
className?: string;
3+
}

0 commit comments

Comments
 (0)