Skip to content

Commit

Permalink
Merge pull request #1784 from cozy/feat/viewer
Browse files Browse the repository at this point in the history
feat: Viewer on tablet is now like on mobile
  • Loading branch information
JF-Cozy authored Mar 25, 2021
2 parents ab1c5de + 9d28cf8 commit c30b2b4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions react/Viewer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import useBreakpoints from '../hooks/useBreakpoints'
import styles from './styles.styl'

const Footer = ({ children }) => {
const { isMobile } = useBreakpoints()
const { isDesktop } = useBreakpoints()

if (!isMobile) return null
if (isDesktop) return null
return <div className={styles['viewer-footer']}>{children}</div>
}

Expand Down
13 changes: 9 additions & 4 deletions react/Viewer/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Toolbar = ({
toolbarRef
}) => {
const client = useClient()
const { isMobile } = useBreakpoints()
const { isDesktop } = useBreakpoints()
const classes = useClasses()

return (
Expand All @@ -51,16 +51,21 @@ const Toolbar = ({
{onClose && (
<IconButton
onClick={onClose}
className={cx(classes.iconButton, { 'u-white': !isMobile })}
className={cx(classes.iconButton, { 'u-white': isDesktop })}
>
<Icon icon={PreviousIcon} />
</IconButton>
)}
<Typography className="u-pl-half" variant="h3" color="inherit" noWrap>
<Typography
className="u-pl-half"
variant="h3"
color={isDesktop ? 'inherit' : 'textPrimary'}
noWrap
>
{file.name}
</Typography>
<div className="u-ml-auto u-ph-1">
{!isMobile && (
{isDesktop && (
<Button
className="u-white"
icon={DownloadIcon}
Expand Down
6 changes: 3 additions & 3 deletions react/Viewer/ViewerControls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ViewerControls extends Component {
showInfoPanel,
children,
classes,
breakpoints: { isMobile }
breakpoints: { isDesktop }
} = this.props
const { showToolbar, showClose, toolbarRef } = toolbarProps
const { hidden } = this.state
Expand All @@ -136,7 +136,7 @@ class ViewerControls extends Component {
onMouseLeave={this.hideControls}
/>
)}
{showNavigation && !isMobile && hasPrevious && (
{showNavigation && isDesktop && hasPrevious && (
<Navigation
className={styles['viewer-nav--previous']}
hidden={hidden}
Expand All @@ -146,7 +146,7 @@ class ViewerControls extends Component {
/>
)}
{this.renderChildren(children)}
{showNavigation && !isMobile && hasNext && (
{showNavigation && isDesktop && hasNext && (
<Navigation
className={styles['viewer-nav--next']}
hidden={hidden}
Expand Down
4 changes: 2 additions & 2 deletions react/Viewer/ViewerSpinner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import useBreakpoints from '../hooks/useBreakpoints'
import Spinner from '../Spinner'

const ViewerSpinner = () => {
const { isMobile } = useBreakpoints()
const { isDesktop } = useBreakpoints()

return (
<Spinner
size="xxlarge"
middle
noMargin
{...(!isMobile && { color: 'white' })}
{...(isDesktop && { color: 'white' })}
/>
)
}
Expand Down
2 changes: 0 additions & 2 deletions react/Viewer/controls.styl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ $footerHeight = 3.5rem
height $toolbarHeightMedium
width calc(100% - 1rem)
padding 0 1rem 0 0

+small-screen()
background var(--paperBackgroundColor)
border-bottom 1px solid var(--dividerColor)

Expand Down
2 changes: 1 addition & 1 deletion react/Viewer/styles.styl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $viewerMarginTopMedium = $toolbarHeightMedium - $footerHeight
background var(--charcoalGrey)
color var(--white)

+small-screen()
+medium-screen()
color var(--charcoalGrey)
background var(--white)

Expand Down

0 comments on commit c30b2b4

Please sign in to comment.