Skip to content

feat(ui): add responsive styling for mobile compatibility #7298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dev-test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<html>
<head>
<meta charset="utf-8" />

<title>Decap CMS Development Test</title>
<script>
window.repoFiles = {
Expand Down
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const LoginButton = styled.button`
${buttons.default};
${buttons.gray};

padding: 0 30px;
padding: clamp(4px, 1.2vw, 12px) clamp(12px, 3.2vw, 32px);
display: block;
margin-top: 20px;
margin-left: auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ exports[`GitGatewayAuthenticationPage should render with identity error 1`] = `
}

.emotion-2 {
width: 300px;
width: auto;
max-width: 300px;
height: auto;
}

Expand All @@ -33,10 +34,9 @@ exports[`GitGatewayAuthenticationPage should render with identity error 1`] = `
border-radius: 5px;
cursor: pointer;
box-shadow: 0 4px 12px 0 rgba(68, 74, 87, 0.15),0 1px 3px 0 rgba(68, 74, 87, 0.25);
height: 36px;
line-height: 36px;
line-height: 1.1;
font-weight: 500;
padding: 0 15px;
padding: clamp(4px, 1.2vw, 12px) clamp(12px, 3.2vw, 32px);
background-color: #798291;
color: #fff;
background-color: #313d3e;
Expand Down Expand Up @@ -162,7 +162,8 @@ exports[`GitGatewayAuthenticationPage should render with no identity error 1`] =
}

.emotion-2 {
width: 300px;
width: auto;
max-width: 300px;
height: auto;
}

Expand All @@ -171,10 +172,9 @@ exports[`GitGatewayAuthenticationPage should render with no identity error 1`] =
border-radius: 5px;
cursor: pointer;
box-shadow: 0 4px 12px 0 rgba(68, 74, 87, 0.15),0 1px 3px 0 rgba(68, 74, 87, 0.25);
height: 36px;
line-height: 36px;
line-height: 1.1;
font-weight: 500;
padding: 0 15px;
padding: clamp(4px, 1.2vw, 12px) clamp(12px, 3.2vw, 32px);
background-color: #798291;
color: #fff;
background-color: #313d3e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const LoginButton = styled.button`
${buttons.default};
${buttons.gray};

padding: 0 30px;
padding: clamp(4px, 1.2vw, 12px) clamp(12px, 3.2vw, 32px);
margin-top: 0;
display: flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const LoginButton = styled.button`
${buttons.default};
${buttons.gray};

padding: 0 30px;
padding: clamp(4px, 1.2vw, 12px) clamp(12px, 3.2vw, 32px);
margin-top: 0;
display: flex;
align-items: center;
Expand Down
4 changes: 2 additions & 2 deletions packages/decap-cms-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"react-polyglot": "^0.7.0",
"react-redux": "^7.2.0",
"react-router-dom": "^5.2.0",
"react-scroll-sync": "^0.9.0",
"react-split-pane": "^0.1.85",
"react-scroll-sync": "^0.11.2",
"react-split-pane": "^0.1.92",
"react-toastify": "^9.1.1",
"react-topbar-progress-indicator": "^4.0.0",
"react-virtualized-auto-sizer": "^1.0.2",
Expand Down
11 changes: 11 additions & 0 deletions packages/decap-cms-core/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ function bootstrap(opts = {}) {
console.log(`decap-cms-core ${DECAP_CMS_CORE_VERSION}`);
}

/**
* Create meta tag for viewport if it doesn't exist.
*/
const viewportMetaTag = document.querySelector('meta[name="viewport"]');
if (!viewportMetaTag) {
const meta = document.createElement('meta');
meta.name = 'viewport';
meta.content = 'width=device-width, initial-scale=1.0';
document.head.appendChild(meta);
}

/**
* Get DOM element where app will mount.
*/
Expand Down
29 changes: 17 additions & 12 deletions packages/decap-cms-core/src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ TopBarProgress.config({
});

const AppMainContainer = styled.div`
min-width: 800px;
max-width: 1440px;
margin: 0 auto;
`;
Expand Down Expand Up @@ -151,6 +150,7 @@ class App extends React.Component {
openMediaLibrary,
t,
showMediaButton,
location,
} = this.props;

if (config === null) {
Expand All @@ -172,20 +172,25 @@ class App extends React.Component {
const defaultPath = getDefaultPath(collections);
const hasWorkflow = publishMode === EDITORIAL_WORKFLOW;

const isEditorRoute =
location.pathname.includes('/new') || location.pathname.includes('/entries');

return (
<>
<Notifications />
<Header
user={user}
collections={collections}
onCreateEntryClick={createNewEntry}
onLogoutClick={logoutUser}
openMediaLibrary={openMediaLibrary}
hasWorkflow={hasWorkflow}
displayUrl={config.display_url}
isTestRepo={config.backend.name === 'test-repo'}
showMediaButton={showMediaButton}
/>
{!isEditorRoute && (
<Header
user={user}
collections={collections}
onCreateEntryClick={createNewEntry}
onLogoutClick={logoutUser}
openMediaLibrary={openMediaLibrary}
hasWorkflow={hasWorkflow}
displayUrl={config.display_url}
isTestRepo={config.backend.name === 'test-repo'}
showMediaButton={showMediaButton}
/>
)}
<AppMainContainer>
{isFetching && <TopBarProgress />}
<Switch>
Expand Down
90 changes: 54 additions & 36 deletions packages/decap-cms-core/src/components/App/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ function AppHeader(props) {
top: 0;
background-color: ${colors.foreground};
z-index: ${zIndex.zIndex300};
height: ${lengths.topBarHeight};
height: ${lengths.topBarHeightMobile};
@media (min-width: 800px) {
height: ${lengths.topBarHeight};
}
`}
{...props}
/>
Expand All @@ -47,26 +50,34 @@ function AppHeader(props) {
const AppHeaderContent = styled.div`
display: flex;
justify-content: space-between;
min-width: 800px;
flex-direction: column-reverse;
min-width: 100%;
max-width: 1440px;
padding: 0 12px;
margin: 0 auto;

@media (min-width: 800px) {
min-width: 800px;
flex-direction: row;
}
`;

const AppHeaderButton = styled.button`
${buttons.button};
background: none;
color: #7b8290;
font-family: inherit;
font-size: 16px;
font-size: clamp(14px, 1.6vw, 16px);
font-weight: 500;
display: inline-flex;
padding: 16px 20px;
align-items: center;
padding: clamp(8px, 1.6vw, 16px) 0;

${Icon} {
margin-right: 4px;
color: #b3b9c4;
width: clamp(20px, 2.4vw, 24px);
height: clamp(20px, 2.4vw, 24px);
}

&:hover,
Expand Down Expand Up @@ -95,21 +106,27 @@ const AppHeaderNavLink = AppHeaderButton.withComponent(NavLink);
const AppHeaderActions = styled.div`
display: inline-flex;
align-items: center;
gap: clamp(8px, 2.5vw, 20px);
`;

const AppHeaderQuickNewButton = styled(StyledDropdownButton)`
${buttons.button};
${buttons.medium};
${buttons.gray};
margin-right: 8px;

@media (max-width: 800px) {
font-weight: 400;
}

&:after {
top: 11px;
top: 50%;
transform: translateY(-50%);
}
`;

const AppHeaderNavList = styled.ul`
display: flex;
gap: clamp(16px, 4vw, 60px);
margin: 0;
list-style: none;
`;
Expand Down Expand Up @@ -166,8 +183,8 @@ class Header extends React.Component {

return (
<AppHeader>
<AppHeaderContent>
<nav>
<nav>
<AppHeaderContent>
<AppHeaderNavList>
<li>
<AppHeaderNavLink
Expand Down Expand Up @@ -196,34 +213,35 @@ class Header extends React.Component {
</li>
)}
</AppHeaderNavList>
</nav>
<AppHeaderActions>
{creatableCollections.size > 0 && (
<Dropdown
renderButton={() => (
<AppHeaderQuickNewButton> {t('app.header.quickAdd')}</AppHeaderQuickNewButton>
)}
dropdownTopOverlap="30px"
dropdownWidth="160px"
dropdownPosition="left"
>
{creatableCollections.map(collection => (
<DropdownItem
key={collection.get('name')}
label={collection.get('label_singular') || collection.get('label')}
onClick={() => this.handleCreatePostClick(collection.get('name'))}
/>
))}
</Dropdown>
)}
<SettingsDropdown
displayUrl={displayUrl}
isTestRepo={isTestRepo}
imageUrl={user?.avatar_url}
onLogoutClick={onLogoutClick}
/>
</AppHeaderActions>
</AppHeaderContent>

<AppHeaderActions>
{creatableCollections.size > 0 && (
<Dropdown
renderButton={() => (
<AppHeaderQuickNewButton> {t('app.header.quickAdd')}</AppHeaderQuickNewButton>
)}
dropdownTopOverlap="30px"
dropdownWidth="160px"
dropdownPosition="left"
>
{creatableCollections.map(collection => (
<DropdownItem
key={collection.get('name')}
label={collection.get('label_singular') || collection.get('label')}
onClick={() => this.handleCreatePostClick(collection.get('name'))}
/>
))}
</Dropdown>
)}
<SettingsDropdown
displayUrl={displayUrl}
isTestRepo={isTestRepo}
imageUrl={user?.avatar_url}
onLogoutClick={onLogoutClick}
/>
</AppHeaderActions>
</AppHeaderContent>
</nav>
</AppHeader>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@ import {
} from '../../reducers/entries';

const CollectionContainer = styled.div`
margin: ${lengths.pageMargin};
margin: ${lengths.pageMarginMobile};
@media (min-width: 800px) {
margin: ${lengths.pageMargin};
}
`;

const CollectionMain = styled.main`
padding-left: 280px;
@media (min-width: 800px) {
padding-left: 280px;
}
`;

const SearchResultContainer = styled.div`
${components.cardTop};
margin-bottom: 22px;
`;

const SearchResultHeading = styled.h1`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ const CollectionControlsContainer = styled.div`
align-items: center;
flex-direction: row-reverse;
margin-top: 22px;
width: ${lengths.topCardWidth};
max-width: 100%;

@media (min-width: 800px) {
width: ${lengths.topCardWidth};
}

& > div {
margin-left: 6px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';

const SearchContainer = styled.div`
margin: 0 12px;
margin: 0 clamp(12px, 2vw, 20px);
position: relative;

${Icon} {
Expand Down
Loading