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

[docs-infra] Update the Material logo + add copy functionality #42435

Merged
Merged
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
117 changes: 117 additions & 0 deletions docs/src/components/action/MuiLogoMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import * as React from 'react';
import copy from 'clipboard-copy';
import { Link } from '@mui/docs/Link';
import { Portal } from '@mui/base/Portal';
import Box from '@mui/material/Box';
import Snackbar from '@mui/material/Snackbar';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import Slide from '@mui/material/Slide';
import SvgMuiLogomark from 'docs/src/icons/SvgMuiLogomark';
import TextFieldsRoundedIcon from '@mui/icons-material/TextFieldsRounded';
import CheckCircleRoundedIcon from '@mui/icons-material/CheckCircleRounded';

const logoSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="#0073E6" fill-rule="evenodd" d="M24 5.601V1.592a.344.344 0 0 0-.514-.298l-2.64 1.508a.688.688 0 0 0-.346.597v4.009c0 .264.285.43.514.298l2.64-1.508A.688.688 0 0 0 24 5.6ZM.515 1.295l7.643 4.383a.688.688 0 0 0 .684 0l7.643-4.383a.344.344 0 0 1 .515.298v12.03c0 .235-.12.453-.319.58l-4.65 2.953 3.11 1.832c.22.13.495.127.713-.009l4.61-2.878a.344.344 0 0 0 .161-.292v-4.085c0-.254.14-.486.362-.606l2.507-1.346a.344.344 0 0 1 .506.303v7.531c0 .244-.13.47-.34.593l-7.834 4.592a.688.688 0 0 1-.71-.009l-5.953-3.681A.344.344 0 0 1 9 18.808v-3.624c0-.115.057-.222.153-.286l4.04-2.694a.688.688 0 0 0 .307-.572v-4.39a.137.137 0 0 0-.208-.117l-4.44 2.664a.688.688 0 0 1-.705.002L3.645 7.123a.138.138 0 0 0-.208.118v7.933a.344.344 0 0 1-.52.295L.5 14.019C.19 13.833 0 13.497 0 13.135V1.593c0-.264.286-.43.515-.298Z" clip-rule="evenodd"/></svg>`;

const logoWordmarkSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="115" height="37" fill="none"><path fill="#0073E6" d="M11.995 12.023.753 5.441A.5.5 0 0 0 0 5.872v16.779a1.5 1.5 0 0 0 .728 1.286l3.515 2.109a.5.5 0 0 0 .757-.43v-11.27a.2.2 0 0 1 .3-.173l6.7 3.86a1 1 0 0 0 1 0l6.7-3.862a.2.2 0 0 1 .3.173v6.096a1 1 0 0 1-.477.853l-6.284 3.856a.5.5 0 0 0-.239.426v5.637a.5.5 0 0 0 .25.432l8.74 5.06a1 1 0 0 0 1.015-.007l11.51-6.906a1 1 0 0 0 .485-.857v-11.05a.5.5 0 0 0-.757-.43l-3.758 2.255a1 1 0 0 0-.485.857v5.65a.5.5 0 0 1-.243.43l-6.786 4.072a1 1 0 0 1-.962.037L17.5 28.5l7.015-4.209a1 1 0 0 0 .485-.857V5.872a.5.5 0 0 0-.753-.431l-11.242 6.582a1 1 0 0 1-1.01 0Z"/><path fill="#0073E6" d="M35 5.883v5.55a1 1 0 0 1-.486.858l-3.757 2.255a.5.5 0 0 1-.757-.43v-5.55a1 1 0 0 1 .485-.857l3.758-2.255a.5.5 0 0 1 .757.43Z"/><path fill="#090B0B" d="M50.38 28V9.8h4.498l7.566 10.504-3.328-.026L66.708 9.8h4.446V28h-4.966v-5.018c0-1.49.035-2.86.104-4.108.07-1.265.208-2.54.416-3.822l.52 1.612-5.642 7.28H59.87l-5.616-7.358.572-1.534a34.34 34.34 0 0 1 .416 3.744c.07 1.248.104 2.643.104 4.186V28H50.38Zm34.881.156c-1.768 0-3.336-.347-4.706-1.04-1.352-.693-2.409-1.655-3.172-2.886-.745-1.23-1.118-2.626-1.118-4.186V9.8h5.2v10.088c0 .763.165 1.43.494 2.002a3.43 3.43 0 0 0 1.352 1.326c.572.312 1.222.468 1.95.468.763 0 1.44-.156 2.028-.468a3.347 3.347 0 0 0 1.404-1.326c.347-.572.52-1.24.52-2.002V9.8h5.044v10.244c0 1.56-.38 2.955-1.144 4.186-.745 1.23-1.794 2.193-3.146 2.886-1.334.693-2.903 1.04-4.706 1.04ZM99.672 28v-4.316h4.186v-9.568h-4.186V9.8h13.494v4.316h-4.16v9.568h4.16V28H99.672Z"/></svg>`;

interface MuiLogoMenuProps {
marginLeft?: boolean;
smallerMargin?: boolean;
}

export default function MuiLogoMenu({ smallerMargin, marginLeft }: MuiLogoMenuProps) {
const [contextMenu, setContextMenu] = React.useState<{
mouseX: number;
mouseY: number;
} | null>(null);

const handleContextMenu = (event: React.MouseEvent) => {
event.preventDefault();
setContextMenu(
contextMenu === null
? {
mouseX: event.clientX + 8,
mouseY: event.clientY - 8,
}
: null,
);
};

const handleClose = () => {
setContextMenu(null);
};

const [copied, setCopied] = React.useState(false);
const handleCopy = (svgSnippet: string) => {
setCopied(true);
copy(svgSnippet).then(() => {
setTimeout(() => setCopied(false), 3500);
handleClose();
});
};

return (
<React.Fragment>
<Box
component={Link}
href="/"
aria-label="Go to homepage"
onContextMenu={handleContextMenu}
sx={{
'& > svg': { m: '0 !important' }, // override the 2px margin-left coming from the Link component
mr: smallerMargin ? 1 : 1.5,
ml: marginLeft ? 1.5 : undefined,
cursor: 'default',
}}
>
<SvgMuiLogomark height={28} width={28} />
</Box>
<Menu
open={contextMenu !== null}
onClose={handleClose}
anchorReference="anchorPosition"
anchorPosition={
contextMenu !== null ? { top: contextMenu.mouseY, left: contextMenu.mouseX } : undefined
}
sx={(theme) => ({
'& .MuiMenuItem-root': {
'& * path, .MuiSvgIcon-root': {
fill: (theme.vars || theme).palette.text.tertiary,
color: (theme.vars || theme).palette.text.tertiary,
},
'&:hover, &:focus-visible': {
'& * path, .MuiSvgIcon-root': {
fill: (theme.vars || theme).palette.text.primary,
color: (theme.vars || theme).palette.text.primary,
},
},
},
})}
>
<MenuItem onClick={() => handleCopy(logoSvg)}>
<SvgMuiLogomark height={16} width={18} sx={{ mr: 1 }} />
Copy logo as SVG
</MenuItem>
<MenuItem onClick={() => handleCopy(logoWordmarkSvg)}>
<TextFieldsRoundedIcon sx={{ fontSize: '18px', mr: 1 }} />
Copy wordmark as SVG
</MenuItem>
</Menu>
Comment on lines +99 to +100
Copy link
Member

@oliviertassinari oliviertassinari May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could clearly see a "Visit brand guideline" menu item that points to the right Notion page. I would use this more than the two other menu items 🙏. Today, I use the Notion search, but I always find that it's slow, so it would likely become my default go-to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I know. I'm just holding off for a bit as this is still, technically speaking, the organization logo and not the "Material UI" logo. I think it's better to hold off until we have the organization vs. flagship product brand sorted out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would imagine the branding assets will all be on one page: https://www.notion.so/mui-org/Branding-book-42011f0b6ad44e7ba4e507c00b2da13a?pvs=4, covering Material UI, Pigment CSS, etc so I don't see timeline considerations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm visiting the Material UI docs, I'd expect to have its brand assets on its docs space instead of somewhere else (where I'd see brand assets from other products). The timeline impact that I see is:

  • You're in mui.com, which is technically the org website. You right-click and see the "View brand guidelines" menu item that redirects you to that page.
  • On that page, we'd display the MUI logo with the "MUI" wordmark instead of "Material UI" because we haven't fully/firmly decided on a new company name to unlock the logo back to Material UI.
  • Given that the menu item is also accessible via the Material UI docs space, if you're redirected to a page that tells you that logo means MUI, that 200% cement that MUI = Material UI. I'm totally up for doing this, but I'd prefer doing it once it doesn't conflict with the organization's brand (whatever that is).

Copy link
Member

@oliviertassinari oliviertassinari May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah OK. I guess I feel like a Notion page is good enough for this. It's simpler to execute, faster to keep up to date, and it matches the need for this, which feels rare. But no strong preferences. A dedicated page is undeniably more polished.

<Portal container={() => document.body}>
<Snackbar
open={copied}
onClose={handleClose}
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
TransitionComponent={Slide}
message={
<Box sx={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
<CheckCircleRoundedIcon sx={{ fontSize: '18px', color: 'success.main' }} />
Logo SVG copied to clipboard!
</Box>
}
/>
</Portal>
</React.Fragment>
);
}
8 changes: 4 additions & 4 deletions docs/src/icons/SvgMuiLogomark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ export default function SvgMuiLogomark(props: RootSvgProps) {
return (
<RootSvg
xmlns="http://www.w3.org/2000/svg"
width={36}
height={32}
viewBox="0 0 36 32"
width={24}
height={24}
viewBox="0 0 24 24"
fill="none"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M30.343 21.976a1 1 0 00.502-.864l.018-5.787a1 1 0 01.502-.864l3.137-1.802a1 1 0 011.498.867v10.521a1 1 0 01-.502.867l-11.839 6.8a1 1 0 01-.994.001l-9.291-5.314a1 1 0 01-.504-.868v-5.305c0-.006.007-.01.013-.007.005.003.012 0 .012-.007v-.006c0-.004.002-.008.006-.01l7.652-4.396c.007-.004.004-.015-.004-.015a.008.008 0 01-.008-.008l.015-5.201a1 1 0 00-1.5-.87l-5.687 3.277a1 1 0 01-.998 0L6.666 9.7a1 1 0 00-1.499.866v9.4a1 1 0 01-1.496.869l-3.166-1.81a1 1 0 01-.504-.87l.028-16.43A1 1 0 011.527.86l10.845 6.229a1 1 0 00.996 0L24.21.86a1 1 0 011.498.868v16.434a1 1 0 01-.501.867l-5.678 3.27a1 1 0 00.004 1.735l3.132 1.783a1 1 0 00.993-.002l6.685-3.839zM31 7.234a1 1 0 001.514.857l3-1.8A1 1 0 0036 5.434V1.766A1 1 0 0034.486.91l-3 1.8a1 1 0 00-.486.857v3.668z"
d="M24 5.601V1.592a.344.344 0 0 0-.514-.298l-2.64 1.508a.688.688 0 0 0-.346.597v4.009c0 .264.285.43.514.298l2.64-1.508A.688.688 0 0 0 24 5.6ZM.515 1.295l7.643 4.383a.688.688 0 0 0 .684 0l7.643-4.383a.344.344 0 0 1 .515.298v12.03c0 .235-.12.453-.319.58l-4.65 2.953 3.11 1.832c.22.13.495.127.713-.009l4.61-2.878a.344.344 0 0 0 .161-.292v-4.085c0-.254.14-.486.362-.606l2.507-1.346a.344.344 0 0 1 .506.303v7.531c0 .244-.13.47-.34.593l-7.834 4.592a.688.688 0 0 1-.71-.009l-5.953-3.681A.344.344 0 0 1 9 18.808v-3.624c0-.115.057-.222.153-.286l4.04-2.694a.688.688 0 0 0 .307-.572v-4.39a.137.137 0 0 0-.208-.117l-4.44 2.664a.688.688 0 0 1-.705.002L3.645 7.123a.138.138 0 0 0-.208.118v7.933a.344.344 0 0 1-.52.295L.5 14.019C.19 13.833 0 13.497 0 13.135V1.593c0-.264.286-.43.515-.298Z"
fill="#007FFF"
/>
</RootSvg>
Expand Down
7 changes: 2 additions & 5 deletions docs/src/layouts/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import Container from '@mui/material/Container';
import Tooltip from '@mui/material/Tooltip';
import IconButton from '@mui/material/IconButton';
import GitHubIcon from '@mui/icons-material/GitHub';
import SvgMuiLogomark from 'docs/src/icons/SvgMuiLogomark';
import MuiLogoMenu from 'docs/src/components/action/MuiLogoMenu';
import HeaderNavBar from 'docs/src/components/header/HeaderNavBar';
import HeaderNavDropdown from 'docs/src/components/header/HeaderNavDropdown';
import ThemeModeToggle from 'docs/src/components/header/ThemeModeToggle';
import { Link } from '@mui/docs/Link';
import { DeferredAppSearch } from 'docs/src/modules/components/AppFrame';
import { useTranslate } from '@mui/docs/i18n';

Expand Down Expand Up @@ -51,9 +50,7 @@ export default function AppHeader(props: AppHeaderProps) {
}}
/>
<Container sx={{ display: 'flex', alignItems: 'center', minHeight: HEIGHT }}>
<Box component={Link} href="/" aria-label="Go to homepage" sx={{ lineHeight: 0, mr: 2 }}>
<SvgMuiLogomark width={30} />
</Box>
<MuiLogoMenu />
<Box sx={{ display: { xs: 'none', md: 'initial' } }}>
<HeaderNavBar />
</Box>
Expand Down
15 changes: 4 additions & 11 deletions docs/src/modules/components/AppFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import SettingsIcon from '@mui/icons-material/SettingsOutlined';
import GitHubIcon from '@mui/icons-material/GitHub';
import NProgressBar from '@mui/docs/NProgressBar';
import { debounce } from '@mui/material/utils';
import NextLink from 'next/link';
import SvgHamburgerMenu from 'docs/src/icons/SvgHamburgerMenu';
import AppNavDrawer from 'docs/src/modules/components/AppNavDrawer';
import AppSettingsDrawer from 'docs/src/modules/components/AppSettingsDrawer';
Expand All @@ -23,7 +22,7 @@ import MarkdownLinks from 'docs/src/modules/components/MarkdownLinks';
import SkipLink from 'docs/src/modules/components/SkipLink';
import PageContext from 'docs/src/modules/components/PageContext';
import { useTranslate } from '@mui/docs/i18n';
import SvgMuiLogomark from 'docs/src/icons/SvgMuiLogomark';
import MuiLogoMenu from 'docs/src/components/action/MuiLogoMenu';
import AppFrameBanner from 'docs/src/components/banner/AppFrameBanner';

const nProgressStart = debounce(() => {
Expand Down Expand Up @@ -194,15 +193,9 @@ export default function AppFrame(props) {
>
<SvgHamburgerMenu />
</NavIconButton>
<NextLink href="/" passHref /* onClick={onClose} */ legacyBehavior>
<Box
component="a"
aria-label={t('goToHome')}
sx={{ display: { md: 'flex', lg: 'none' }, ml: 2 }}
>
<SvgMuiLogomark width={30} />
</Box>
</NextLink>
<Box sx={{ display: { md: 'flex', lg: 'none' } }}>
<MuiLogoMenu marginLeft />
</Box>
<Stack direction="row" spacing={1} useFlexGap sx={{ ml: 'auto' }}>
<BannerComponent />
<DeferredAppSearch />
Expand Down
9 changes: 2 additions & 7 deletions docs/src/modules/components/AppNavDrawer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import NextLink from 'next/link';
import Button from '@mui/material/Button';
import Divider from '@mui/material/Divider';
import { styled, ThemeProvider } from '@mui/material/styles';
Expand All @@ -15,7 +14,7 @@ import Box from '@mui/material/Box';
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
import ArrowDropDownRoundedIcon from '@mui/icons-material/ArrowDropDownRounded';
import DoneRounded from '@mui/icons-material/DoneRounded';
import SvgMuiLogomark from 'docs/src/icons/SvgMuiLogomark';
import MuiLogoMenu from 'docs/src/components/action/MuiLogoMenu';
import AppNavDrawerItem from 'docs/src/modules/components/AppNavDrawerItem';
import { pageToTitleI18n } from 'docs/src/modules/utils/helpers';
import PageContext from 'docs/src/modules/components/PageContext';
Expand Down Expand Up @@ -389,11 +388,7 @@ export default function AppNavDrawer(props) {
return (
<React.Fragment>
<ToolbarDiv>
<NextLink href="/" passHref legacyBehavior>
<Box component="a" onClick={onClose} aria-label={t('goToHome')} sx={{ mr: 1.5 }}>
<SvgMuiLogomark width={30} />
</Box>
</NextLink>
<MuiLogoMenu smallerMargin />
<ProductIdentifier
name={productIdentifier.name}
metadata={productIdentifier.metadata}
Expand Down
23 changes: 20 additions & 3 deletions packages/mui-docs/src/branding/brandingTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,11 +869,11 @@ export function getThemedComponents(): ThemeOptions {
},
},
'& .MuiMenuItem-root': {
padding: '6px 12px',
padding: '6px 8px',
borderRadius: '6px',
fontSize: theme.typography.pxToRem(14),
fontWeight: theme.typography.fontWeightMedium,
'&:hover, &:focus': {
'&:hover': {
backgroundColor: (theme.vars || theme).palette.grey[100],
color: (theme.vars || theme).palette.text.primary,
},
Expand All @@ -891,7 +891,7 @@ export function getThemedComponents(): ThemeOptions {
backgroundColor: (theme.vars || theme).palette.primaryDark[900],
borderColor: (theme.vars || theme).palette.primaryDark[700],
'& .MuiMenuItem-root': {
'&:hover, &:focus': {
'&:hover': {
backgroundColor: (theme.vars || theme).palette.primaryDark[700],
},
'&.Mui-selected': {
Expand Down Expand Up @@ -1323,6 +1323,23 @@ export function getThemedComponents(): ThemeOptions {
},
},
},
MuiSnackbar: {
Copy link
Member

@oliviertassinari oliviertassinari May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off-topic

The more we use the brandingTheme, the more it feels like we should remove this pattern, and replace it with a wrapper of each Material UI component. The file starts to feel bloated. I almost wish Material UI had a CLI to automate this extraction.

Now, I guess that with Pigment CSS, moving from JS to CSS would help with performance, but I don't know. What the reality is. Maybe styled(styled()) is actually smaller than the current pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to discuss this further — I don't see this file as bloated; I like that all major customizations live within the theme file. The styled() approach would work, but the biggest downside I can think of is that I'd now need to open several different files instead of scrolling up and down on the same one, which sounds like a big DX impact.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was focused on the UX part of the problem. For the DX, yeah, OK maybe.

styleOverrides: {
root: ({ theme }) => ({
'& .MuiSnackbarContent-root': {
backgroundColor: '#FFF',
color: (theme.vars || theme).palette.text.primary,
fontWeight: theme.typography.fontWeightMedium,
border: `1px solid ${(theme.vars || theme).palette.divider}`,
boxShadow: `0 4px 16px ${alpha(theme.palette.grey[400], 0.2)}`,
...theme.applyDarkStyles({
backgroundColor: (theme.vars || theme).palette.primaryDark[800],
boxShadow: '0 4px 16px hsl(0, 100%, 1%)',
}),
},
}),
},
},
MuiPaginationItem: {
styleOverrides: {
root: ({ theme }) => [
Expand Down