diff --git a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryButtons.js b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryButtons.js index fa3eb19b057e..9baacd7dbc10 100644 --- a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryButtons.js +++ b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryButtons.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { css } from '@emotion/react'; import styled from '@emotion/styled'; import { isAbsolutePath } from 'decap-cms-lib-util'; -import { buttons, shadows, zIndex } from 'decap-cms-ui-default'; +import { buttons, Icon, shadows, zIndex } from 'decap-cms-ui-default'; import { FileUploadButton } from '../UI'; @@ -11,15 +11,25 @@ const styles = { button: css` ${buttons.button}; ${buttons.default}; - display: inline-block; - margin-left: 15px; - margin-right: 2px; + display: inline-flex; + align-items: center; &[disabled] { ${buttons.disabled}; cursor: default; } `, + // Hides an element without removing it from the accessibility tree. + visuallyHidden: css` + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + `, }; export const UploadButton = styled(FileUploadButton)` @@ -68,7 +78,27 @@ const ActionButton = styled.button` `} `; -export const DownloadButton = ActionButton; +function ResponsiveActionButton({ children, icon, ...props }) { + return ( + + + ); +} + +export function DownloadButton({ children, ...props }) { + return ( + + {children} + + ); +} export class CopyToClipBoardButton extends React.Component { mounted = false; @@ -115,13 +145,15 @@ export class CopyToClipBoardButton extends React.Component { return t('mediaLibrary.mediaLibraryCard.copyPath'); }; + getIcon = () => (this.state.copied ? 'check' : 'copy'); + render() { const { disabled } = this.props; return ( - + {this.getTitle()} - + ); } } diff --git a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryCard.js b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryCard.js index fa954f3bb792..af279a19f040 100644 --- a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryCard.js +++ b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryCard.js @@ -70,7 +70,6 @@ class MediaLibraryCard extends React.Component { text, onClick, draftText, - width, height, margin, isPrivate, @@ -83,7 +82,7 @@ class MediaLibraryCard extends React.Component { props.isPrivate && colors.textFieldBorder}; `; function MediaLibraryHeader({ onClose, title, isPrivate, t }) { return ( -
+ {title} -
+ ); } diff --git a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryModal.js b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryModal.js index ba89b25517c0..6648d5b5abdf 100644 --- a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryModal.js +++ b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryModal.js @@ -25,14 +25,18 @@ const cardMargin = `10px`; */ const cardOutsideWidth = `300px`; +/** Calculated to be as wide as possible without cutting off the 40px-wide close button. */ +const minimumCardWidth = `calc(100% - 40px)`; + const StyledModal = styled(Modal)` display: grid; - grid-template-rows: 120px auto; - width: calc(${cardOutsideWidth} + 20px); + width: 100%; + grid-template-rows: auto 1fr; + gap: 20px; background-color: ${props => props.isPrivate && colors.grayDark}; - @media (min-width: 800px) { - width: calc(${cardOutsideWidth} * 2 + 20px); + @media (min-width: 500px) { + width: min(${minimumCardWidth}, calc(${cardOutsideWidth} * 2 + 20px)); } @media (min-width: 1120px) { diff --git a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibrarySearch.js b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibrarySearch.js index 54629f373387..ec49a871a2c0 100644 --- a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibrarySearch.js +++ b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibrarySearch.js @@ -8,7 +8,8 @@ const SearchContainer = styled.div` display: flex; align-items: center; position: relative; - width: 400px; + flex: 1 1 150px; + max-width: 460px; `; const SearchInput = styled.input` @@ -33,6 +34,7 @@ const SearchIcon = styled(Icon)` left: 6px; z-index: ${zIndex.zIndex2}; transform: translate(0, -50%); + pointer-events: none; `; function MediaLibrarySearch({ value, onChange, onKeyDown, placeholder, disabled }) { diff --git a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryTop.js b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryTop.js index 524b779a4008..88491dbee906 100644 --- a/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryTop.js +++ b/packages/decap-cms-core/src/components/MediaLibrary/MediaLibraryTop.js @@ -1,5 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { css } from '@emotion/react'; import styled from '@emotion/styled'; import MediaLibrarySearch from './MediaLibrarySearch'; @@ -12,19 +13,36 @@ import { InsertButton, } from './MediaLibraryButtons'; +const styles = { + flexSpacing: css` + gap: 8px; + @media (min-width: 500px) { + gap: 15px; + } + `, +}; + const LibraryTop = styled.div` position: relative; display: flex; flex-direction: column; + ${styles.flexSpacing}; `; const RowContainer = styled.div` display: flex; + align-items: center; justify-content: space-between; + flex-wrap: wrap; + ${styles.flexSpacing}; `; const ButtonsContainer = styled.div` - flex-shrink: 0; + display: flex; + align-items: center; + justify-content: stretch; + flex-wrap: wrap; + ${styles.flexSpacing}; `; function MediaLibraryTop({ diff --git a/packages/decap-cms-core/src/components/MediaLibrary/__tests__/__snapshots__/MediaLibraryCard.spec.js.snap b/packages/decap-cms-core/src/components/MediaLibrary/__tests__/__snapshots__/MediaLibraryCard.spec.js.snap index 24bbf107412d..4cf26b9d09ce 100644 --- a/packages/decap-cms-core/src/components/MediaLibrary/__tests__/__snapshots__/MediaLibraryCard.spec.js.snap +++ b/packages/decap-cms-core/src/components/MediaLibrary/__tests__/__snapshots__/MediaLibraryCard.spec.js.snap @@ -3,7 +3,7 @@ exports[`MediaLibraryCard should match snapshot for draft image 1`] = ` .emotion-0 { - width: 100px; + width: 100%; height: 240px; margin: 10px; border: solid 2px #dfdfe3; @@ -70,7 +70,7 @@ exports[`MediaLibraryCard should match snapshot for draft image 1`] = ` class="emotion-0 emotion-1" height="240px" tabindex="-1" - width="100px" + width="100%" >
.emotion-0 { - width: 100px; + width: 100%; height: 240px; margin: 10px; border: solid 2px #dfdfe3; @@ -158,7 +158,7 @@ exports[`MediaLibraryCard should match snapshot for non draft image 1`] = ` class="emotion-0 emotion-1" height="240px" tabindex="-1" - width="100px" + width="100%" >
.emotion-0 { - width: 100px; + width: 100%; height: 240px; margin: 10px; border: solid 2px #dfdfe3; @@ -242,7 +242,7 @@ exports[`MediaLibraryCard should match snapshot for non viewable image 1`] = ` class="emotion-0 emotion-1" height="240px" tabindex="-1" - width="100px" + width="100%" >
diff --git a/packages/decap-cms-ui-default/src/Icon/images/download.svg b/packages/decap-cms-ui-default/src/Icon/images/download.svg new file mode 100644 index 000000000000..bbf8d94ba1bb --- /dev/null +++ b/packages/decap-cms-ui-default/src/Icon/images/download.svg @@ -0,0 +1 @@ +