Skip to content
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

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

Open
wants to merge 2 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
2 changes: 1 addition & 1 deletion dev-test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Decap CMS Development Test</title>
<script>
window.repoFiles = {
Expand Down
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 @@ -36,7 +36,7 @@ exports[`GitGatewayAuthenticationPage should render with identity error 1`] = `
height: 36px;
line-height: 36px;
font-weight: 500;
padding: 0 15px;
padding: 0 13px;
background-color: #798291;
color: #fff;
background-color: #313d3e;
Expand All @@ -54,6 +54,12 @@ exports[`GitGatewayAuthenticationPage should render with identity error 1`] = `
position: relative;
}

@media (min-width: 800px) {
.emotion-4 {
padding: 0 35px;
}
}

.emotion-4:focus,
.emotion-4:hover {
color: #fff;
Expand Down Expand Up @@ -174,7 +180,7 @@ exports[`GitGatewayAuthenticationPage should render with no identity error 1`] =
height: 36px;
line-height: 36px;
font-weight: 500;
padding: 0 15px;
padding: 0 13px;
background-color: #798291;
color: #fff;
background-color: #313d3e;
Expand All @@ -192,6 +198,12 @@ exports[`GitGatewayAuthenticationPage should render with no identity error 1`] =
position: relative;
}

@media (min-width: 800px) {
.emotion-4 {
padding: 0 35px;
}
}

.emotion-4:focus,
.emotion-4:hover {
color: #fff;
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { components, buttons, shadows } from 'decap-cms-ui-default';

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

const CollectionTopRow = styled.div`
Expand All @@ -27,7 +26,7 @@ const CollectionTopNewButton = styled(Link)`
${buttons.default};
${buttons.gray};

padding: 0 30px;
padding: clamp(4px, 1.2vw, 12px) clamp(12px, 3.2vw, 32px);
`;

const CollectionTopDescription = styled.p`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ const Button = styled(StyledDropdownButton)`
${buttons.button};
${buttons.medium};
${buttons.grayText};
font-size: 14px;
font-size: clamp(12px, 3.3vw, 14px);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { selectCollectionEntriesCursor } from '../../../reducers/cursors';
import Entries from './Entries';

const GroupHeading = styled.h2`
font-size: 22px;
font-size: clamp(18px, 2.2vw, 22px);
font-weight: 600;
line-height: 37px;
padding-inline-start: 20px;
Expand Down
Loading