Skip to content

Commit

Permalink
fix: left menu
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaellis committed May 7, 2024
1 parent 33dab7a commit 9ebfd37
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';

import { Box } from '@strapi/design-system';
import styled from 'styled-components';
import { styled } from 'styled-components';

interface GridColSize {
S: number;
Expand Down
8 changes: 4 additions & 4 deletions packages/core/admin/admin/src/components/Layouts/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';

import { Box } from '@strapi/design-system';
import styled from 'styled-components';
import { styled } from 'styled-components';

import { ActionLayout } from './ActionLayout';
import { ContentLayout } from './ContentLayout';
Expand All @@ -13,9 +13,9 @@ interface LayoutProps {
sideNav?: React.ReactNode;
}

const GridContainer = styled(Box)<{ hasSideNav: boolean }>`
const GridContainer = styled(Box)<{ $hasSideNav: boolean }>`
display: grid;
grid-template-columns: ${({ hasSideNav }) => (hasSideNav ? `auto 1fr` : '1fr')};
grid-template-columns: ${({ $hasSideNav }) => ($hasSideNav ? `auto 1fr` : '1fr')};
`;

const OverflowingItem = styled(Box)`
Expand All @@ -24,7 +24,7 @@ const OverflowingItem = styled(Box)`

const RootLayout = ({ sideNav, children }: LayoutProps) => {
return (
<GridContainer hasSideNav={Boolean(sideNav)}>
<GridContainer $hasSideNav={Boolean(sideNav)}>
{sideNav}
<OverflowingItem paddingBottom={10}>{children}</OverflowingItem>
</GridContainer>
Expand Down
29 changes: 17 additions & 12 deletions packages/core/admin/admin/src/components/LeftMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';

import { Divider, Flex } from '@strapi/design-system';
import { Divider, Flex, FlexComponent } from '@strapi/design-system';
import { Feather, Lock, House } from '@strapi/icons';
import { useIntl } from 'react-intl';
import { useLocation } from 'react-router-dom';
import styled from 'styled-components';
import { styled } from 'styled-components';

import { useAuth } from '../features/Auth';
import { useTracking } from '../features/Tracking';
Expand All @@ -22,7 +22,7 @@ const NewNavLinkBadge = styled(NavLink.Badge)`
}
`;

const NavListWrapper = styled(Flex)`
const NavListWrapper = styled<FlexComponent<'ul'>>(Flex)`
overflow-y: auto;
`;

Expand Down Expand Up @@ -51,16 +51,16 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }: LeftMenuProps) =

<Divider />

<NavListWrapper as="ul" gap={3} direction="column" flex={1} paddingTop={3} paddingBottom={3}>
<NavListWrapper tag="ul" gap={3} direction="column" flex={1} paddingTop={3} paddingBottom={3}>
<Flex tag="li">
<NavLink.Link
to="/"
onClick={() => handleClickOnLink('/')}
aria-label={formatMessage({ id: 'global.home', defaultMessage: 'Home' })}
>
<NavLink.Tooltip label={formatMessage({ id: 'global.home', defaultMessage: 'Home' })}>
<NavLink.Icon>
<House fill="neutral500" />
<NavLink.Icon label={formatMessage({ id: 'global.home', defaultMessage: 'Home' })}>
<House width="2rem" height="2rem" fill="neutral500" />
</NavLink.Icon>
</NavLink.Tooltip>
</NavLink.Link>
Expand All @@ -80,8 +80,13 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }: LeftMenuProps) =
defaultMessage: 'Content Manager',
})}
>
<NavLink.Icon>
<Feather fill="neutral500" />
<NavLink.Icon
label={formatMessage({
id: 'global.content-manager',
defaultMessage: 'Content Manager',
})}
>
<Feather width="2rem" height="2rem" fill="neutral500" />
</NavLink.Icon>
</NavLink.Tooltip>
</NavLink.Link>
Expand All @@ -104,8 +109,8 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }: LeftMenuProps) =
aria-label={labelValue}
>
<NavLink.Tooltip label={labelValue}>
<NavLink.Icon>
<LinkIcon fill="neutral500" />
<NavLink.Icon label={labelValue}>
<LinkIcon width="2rem" height="2rem" fill="neutral500" />
</NavLink.Icon>
{badgeContent && (
<NavLink.Badge
Expand Down Expand Up @@ -141,8 +146,8 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }: LeftMenuProps) =
onClick={() => handleClickOnLink(link.to)}
>
<NavLink.Tooltip label={labelValue}>
<NavLink.Icon>
<LinkIcon fill="neutral500" />
<NavLink.Icon label={labelValue}>
<LinkIcon width="2rem" height="2rem" fill="neutral500" />
</NavLink.Icon>
{badgeContent && (
<NewNavLinkBadge label={badgeContent} backgroundColor="primary600">
Expand Down
8 changes: 4 additions & 4 deletions packages/core/admin/admin/src/components/MainNav/MainNav.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Flex, FlexProps } from '@strapi/design-system';
import styled from 'styled-components';
import { Flex, FlexComponent, FlexProps } from '@strapi/design-system';
import { styled } from 'styled-components';

const MainNavWrapper = styled(Flex)`
const MainNavWrapper = styled<FlexComponent<'nav'>>(Flex)`
border-right: 1px solid ${({ theme }) => theme.colors.neutral150};
`;

const MainNav = (props: FlexProps<'nav'>) => (
<MainNavWrapper
alignItems="normal"
as="nav"
tag="nav"
background="neutral0"
direction="column"
height="100vh"
Expand Down
16 changes: 6 additions & 10 deletions packages/core/admin/admin/src/components/MainNav/NavLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';

import { Tooltip, Flex, Badge, BadgeProps } from '@strapi/design-system';
import { Tooltip, Flex, Badge, BadgeProps, AccessibleIcon } from '@strapi/design-system';
import { NavLink as RouterLink, LinkProps } from 'react-router-dom';
import { styled } from 'styled-components';

Expand All @@ -15,6 +15,8 @@ const MainNavLinkWrapper = styled(RouterLink)`
color: ${({ theme }) => theme.colors.neutral500};
position: relative;
width: fit-content;
padding-block: 0.6rem;
padding-inline: 0.6rem;
&:hover,
&.active {
Expand Down Expand Up @@ -48,25 +50,19 @@ const LinkImpl = ({ children, ...props }: LinkProps) => {
const TooltipImpl = ({ children, label, position = 'right' }: NavLink.TooltipProps) => {
return (
<Tooltip position={position} label={label}>
<Flex justifyContent="center" width={7} height={7}>
{children}
</Flex>
<>{children}</>
</Tooltip>
);
};

/* -------------------------------------------------------------------------------------------------
* Icon
* -----------------------------------------------------------------------------------------------*/
const IconImpl = ({ children }: { children: React.ReactNode }) => {
const IconImpl = ({ label, children }: { label: string; children: React.ReactNode }) => {
if (!children) {
return null;
}
return (
<Flex justifyContent="center" aria-hidden tag="span" width={5} height={5}>
{children}
</Flex>
);
return <AccessibleIcon label={label}>{children}</AccessibleIcon>;
};

/* -------------------------------------------------------------------------------------------------
Expand Down

This file was deleted.

5 changes: 3 additions & 2 deletions packages/core/content-type-builder/admin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Layout } from '@strapi/icons';

import pluginPkg from '../../package.json';

import { PluginIcon } from './components/PluginIcon';
import { PERMISSIONS } from './constants';
import { pluginId } from './pluginId';
import { reducers } from './reducers';
Expand All @@ -15,7 +16,7 @@ export default {
app.addReducers(reducers);
app.addMenuLink({
to: `plugins/${pluginId}`,
icon: PluginIcon,
icon: Layout,
intlLabel: {
id: `${pluginId}.plugin.name`,
defaultMessage: 'Content Types Builder',
Expand Down
13 changes: 0 additions & 13 deletions packages/core/upload/admin/src/components/PluginIcon/index.jsx

This file was deleted.

5 changes: 3 additions & 2 deletions packages/core/upload/admin/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Images } from '@strapi/icons';

import pluginPkg from '../../package.json';

import { MediaLibraryDialog } from './components/MediaLibraryDialog';
import { MediaLibraryInput } from './components/MediaLibraryInput';
import PluginIcon from './components/PluginIcon';
import { PERMISSIONS } from './constants';
import pluginId from './pluginId';
import getTrad from './utils/getTrad';
Expand All @@ -14,7 +15,7 @@ export default {
register(app) {
app.addMenuLink({
to: `plugins/${pluginId}`,
icon: PluginIcon,
icon: Images,
intlLabel: {
id: `${pluginId}.plugin.name`,
defaultMessage: 'Media Library',
Expand Down

0 comments on commit 9ebfd37

Please sign in to comment.