mirror of
https://github.com/strapi/strapi.git
synced 2025-10-11 08:02:55 +00:00
Merge pull request #5419 from wysher/feat/menu-scrollbars
Fit Left menu + scrollbars
This commit is contained in:
commit
37d6a3464d
@ -137,6 +137,39 @@ const GlobalStyle = createGlobalStyle`
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// scrollbar
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-track {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-track:hover {
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
background-color: #ccc;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb:hover {
|
||||||
|
background-color: #bbb;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-button {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
// firefox scrollbar
|
||||||
|
* {
|
||||||
|
scrollbar-color: #bbb #eee;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default GlobalStyle;
|
export default GlobalStyle;
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const LeftMenuSection = styled.div`
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
overflow: hidden;
|
||||||
|
min-height: 175px;
|
||||||
|
height: auto;
|
||||||
|
flex: 0 1 auto;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default LeftMenuSection;
|
@ -11,6 +11,8 @@ const Wrapper = styled.div`
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
height: calc(100vh - (${props => props.theme.main.sizes.leftMenu.height} + 10.2rem));
|
height: calc(100vh - (${props => props.theme.main.sizes.leftMenu.height} + 10.2rem));
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
padding-left: 2rem;
|
padding-left: 2rem;
|
||||||
|
@ -5,6 +5,7 @@ import { get, snakeCase, isEmpty } from 'lodash';
|
|||||||
|
|
||||||
import { SETTINGS_BASE_URL } from '../../config';
|
import { SETTINGS_BASE_URL } from '../../config';
|
||||||
import Wrapper from './Wrapper';
|
import Wrapper from './Wrapper';
|
||||||
|
import MenuSection from './MenuSection';
|
||||||
import messages from './messages.json';
|
import messages from './messages.json';
|
||||||
|
|
||||||
import LeftMenuLinkSection from '../LeftMenuLinkSection';
|
import LeftMenuLinkSection from '../LeftMenuLinkSection';
|
||||||
@ -19,6 +20,7 @@ const LeftMenuLinkContainer = ({ plugins }) => {
|
|||||||
acc[snakeCase(section.name)] = {
|
acc[snakeCase(section.name)] = {
|
||||||
name: section.name,
|
name: section.name,
|
||||||
searchable: true,
|
searchable: true,
|
||||||
|
shrink: true,
|
||||||
links: get(acc[snakeCase(section.name)], 'links', []).concat(
|
links: get(acc[snakeCase(section.name)], 'links', []).concat(
|
||||||
section.links
|
section.links
|
||||||
.filter(link => link.isDisplayed !== false)
|
.filter(link => link.isDisplayed !== false)
|
||||||
@ -50,49 +52,58 @@ const LeftMenuLinkContainer = ({ plugins }) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const menu = {
|
const menus = [
|
||||||
...contentTypesSections,
|
contentTypesSections,
|
||||||
plugins: {
|
{
|
||||||
searchable: false,
|
plugins: {
|
||||||
name: 'plugins',
|
searchable: false,
|
||||||
emptyLinksListMessage: messages.noPluginsInstalled.id,
|
name: 'plugins',
|
||||||
links: pluginsLinks,
|
emptyLinksListMessage: messages.noPluginsInstalled.id,
|
||||||
|
links: pluginsLinks,
|
||||||
|
},
|
||||||
|
general: {
|
||||||
|
searchable: false,
|
||||||
|
name: 'general',
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
icon: 'list',
|
||||||
|
label: messages.listPlugins.id,
|
||||||
|
destination: '/list-plugins',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: 'shopping-basket',
|
||||||
|
label: messages.installNewPlugin.id,
|
||||||
|
destination: '/marketplace',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: 'cog',
|
||||||
|
label: messages.settings.id,
|
||||||
|
destination: SETTINGS_BASE_URL || '/settings',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
general: {
|
];
|
||||||
searchable: false,
|
|
||||||
name: 'general',
|
|
||||||
links: [
|
|
||||||
{
|
|
||||||
icon: 'list',
|
|
||||||
label: messages.listPlugins.id,
|
|
||||||
destination: '/list-plugins',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: 'shopping-basket',
|
|
||||||
label: messages.installNewPlugin.id,
|
|
||||||
destination: '/marketplace',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: 'cog',
|
|
||||||
label: messages.settings.id,
|
|
||||||
destination: SETTINGS_BASE_URL || '/settings',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
{Object.keys(menu).map(current => (
|
{menus.map(
|
||||||
<LeftMenuLinkSection
|
section => (
|
||||||
key={current}
|
<MenuSection>
|
||||||
links={menu[current].links}
|
{Object.entries(section).map(([key, value]) => (
|
||||||
section={current}
|
<LeftMenuLinkSection
|
||||||
location={location}
|
key={key}
|
||||||
searchable={menu[current].searchable}
|
shrink={value.shrink}
|
||||||
emptyLinksListMessage={menu[current].emptyLinksListMessage}
|
links={value.links}
|
||||||
/>
|
section={key}
|
||||||
))}
|
location={location}
|
||||||
|
searchable={value.searchable}
|
||||||
|
emptyLinksListMessage={value.emptyLinksListMessage}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</MenuSection>
|
||||||
|
)
|
||||||
|
)}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const LeftMenuListLink = styled.div`
|
const LeftMenuListLink = styled.div`
|
||||||
max-height: 180px;
|
box-sizing: border-box;
|
||||||
|
min-height: 3.7rem;
|
||||||
|
flex-shrink: 0;
|
||||||
margin-bottom: 0.1rem;
|
margin-bottom: 0.1rem;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
|
||||||
|
|
||||||
|
${props =>
|
||||||
|
props.shrink &&
|
||||||
|
`
|
||||||
|
flex-shrink: 1;
|
||||||
|
`}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default LeftMenuListLink;
|
export default LeftMenuListLink;
|
||||||
|
@ -10,7 +10,14 @@ import LeftMenuListLink from './LeftMenuListLink';
|
|||||||
import EmptyLinksList from './EmptyLinksList';
|
import EmptyLinksList from './EmptyLinksList';
|
||||||
import EmptyLinksListWrapper from './EmptyLinksListWrapper';
|
import EmptyLinksListWrapper from './EmptyLinksListWrapper';
|
||||||
|
|
||||||
const LeftMenuLinksSection = ({ section, searchable, location, links, emptyLinksListMessage }) => {
|
const LeftMenuLinksSection = ({
|
||||||
|
section,
|
||||||
|
searchable,
|
||||||
|
location,
|
||||||
|
links,
|
||||||
|
emptyLinksListMessage,
|
||||||
|
shrink,
|
||||||
|
}) => {
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
|
|
||||||
const filteredList = sortBy(
|
const filteredList = sortBy(
|
||||||
@ -39,7 +46,7 @@ const LeftMenuLinksSection = ({ section, searchable, location, links, emptyLinks
|
|||||||
setSearch={setSearch}
|
setSearch={setSearch}
|
||||||
search={search}
|
search={search}
|
||||||
/>
|
/>
|
||||||
<LeftMenuListLink>
|
<LeftMenuListLink shrink={shrink}>
|
||||||
{filteredList.length > 0 ? (
|
{filteredList.length > 0 ? (
|
||||||
filteredList.map((link, index) => (
|
filteredList.map((link, index) => (
|
||||||
<LeftMenuLink
|
<LeftMenuLink
|
||||||
@ -64,9 +71,14 @@ const LeftMenuLinksSection = ({ section, searchable, location, links, emptyLinks
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LeftMenuLinksSection.defaultProps = {
|
||||||
|
shrink: false,
|
||||||
|
};
|
||||||
|
|
||||||
LeftMenuLinksSection.propTypes = {
|
LeftMenuLinksSection.propTypes = {
|
||||||
section: PropTypes.string.isRequired,
|
section: PropTypes.string.isRequired,
|
||||||
searchable: PropTypes.bool.isRequired,
|
searchable: PropTypes.bool.isRequired,
|
||||||
|
shrink: PropTypes.bool,
|
||||||
location: PropTypes.shape({
|
location: PropTypes.shape({
|
||||||
pathname: PropTypes.string,
|
pathname: PropTypes.string,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
|
@ -15,6 +15,29 @@ const Wrapper = styled.div`
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: ${props => props.theme.main.sizes.leftMenu.width};
|
width: ${props => props.theme.main.sizes.leftMenu.width};
|
||||||
background: ${props => props.theme.main.colors.strapi['blue-darker']};
|
background: ${props => props.theme.main.colors.strapi['blue-darker']};
|
||||||
|
|
||||||
|
// scrollbar overrides
|
||||||
|
* {
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-track,
|
||||||
|
::-webkit-scrollbar-track:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
background-color: rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// firefox
|
||||||
|
scrollbar-color: rgba(255, 255, 255, 0.5) rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
Wrapper.defaultProps = {
|
Wrapper.defaultProps = {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const ListWrapper = styled.div`
|
const ListWrapper = styled.div`
|
||||||
overflow: hidden;
|
|
||||||
max-height: 116px;
|
max-height: 116px;
|
||||||
|
|
||||||
> ul {
|
> ul {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user