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] Adjust the tabs and layout selection design #41084

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d1b5b92
tweak the tabs design and add icons
danilo-leal Feb 13, 2024
7847a27
use a menu approach rather than toggle button for the layout selection
danilo-leal Feb 13, 2024
0c544be
adjust the capitalized type names in related files
danilo-leal Feb 13, 2024
b921518
bonus: use a p tag instead of span for proper styles in description t…
danilo-leal Feb 13, 2024
863320d
shorten the demos translation to just "Demos"
danilo-leal Feb 13, 2024
5f107f0
add an end icon to the view-switching Menu button
danilo-leal Feb 14, 2024
8092d7a
change the API tabs icon
danilo-leal Feb 14, 2024
12bc7bf
cleaning up
danilo-leal Feb 14, 2024
e798fd5
minor button style adjustement
danilo-leal Feb 14, 2024
7c495b0
minor adjustment on the API note item
danilo-leal Feb 14, 2024
62da65f
Merge branch 'master' into docs-infra-improve-tabs-and-layout-selection
danilo-leal Feb 14, 2024
9860f49
cleaning up
danilo-leal Feb 14, 2024
7f83bd5
fix lint CI
danilo-leal Feb 14, 2024
367958d
trigger CI checks
danilo-leal Feb 15, 2024
996ec7e
trigger CI checks
danilo-leal Feb 15, 2024
e0f5208
small style adjustments to the menu bottom
danilo-leal Feb 16, 2024
ec01c29
run prettier
danilo-leal Feb 16, 2024
ee16ec7
trigger CI checks
danilo-leal Feb 19, 2024
ec43a44
fix outline visibility and simplify styles
danilo-leal Feb 19, 2024
2642eae
fix prettier thingy on the branding theme file
danilo-leal Feb 19, 2024
edf5178
Merge branch 'master' into docs-infra-improve-tabs-and-layout-selection
danilo-leal Feb 20, 2024
abdd4d2
ditch the tab icons
danilo-leal Feb 23, 2024
c08fe6c
increase gap between tabs
danilo-leal Feb 23, 2024
e9f1d98
tweak button styles and spacing
danilo-leal Feb 26, 2024
31625b8
Merge branch 'master' into docs-infra-improve-tabs-and-layout-selection
danilo-leal Feb 26, 2024
b6d9b91
add margin bottom on other places
danilo-leal Feb 27, 2024
e868433
revert back to lowercase display options
danilo-leal Feb 27, 2024
5cde8ff
fix focus-visible state of the menu item component
danilo-leal Feb 27, 2024
a717369
update capitalized menu item values
danilo-leal Feb 27, 2024
434e776
update secondary button dark mode box-shadows
danilo-leal Feb 27, 2024
1fd765d
Merge branch 'master' into docs-infra-improve-tabs-and-layout-selection
danilo-leal Feb 27, 2024
568d282
update demos tab name again post master merge
danilo-leal Feb 27, 2024
a17a848
Merge branch 'master' into docs-infra-improve-tabs-and-layout-selection
danilo-leal Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/src/modules/brandingTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export function getThemedComponents(): ThemeOptions {
borderColor: (theme.vars || theme).palette.primaryDark[100],
boxShadow: `${alpha(theme.palette.grey[50], 0.5)} 0 2px 0.5px inset, ${alpha(
theme.palette.grey[100],
0.8,
0.5,
)} 0 -2px 0 inset, ${alpha(theme.palette.grey[200], 0.5)} 0 1px 2px 0`,
'&:hover': {
background: (theme.vars || theme).palette.primaryDark[50],
Expand All @@ -514,10 +514,7 @@ export function getThemedComponents(): ThemeOptions {
color: (theme.vars || theme).palette.primaryDark[100],
borderColor: alpha(theme.palette.primaryDark[600], 0.5),
backgroundColor: alpha(theme.palette.primaryDark[700], 0.4),
boxShadow: `${alpha(theme.palette.primaryDark[600], 0.2)} 0 2px 0 inset, ${alpha(
theme.palette.primaryDark[900],
0.5,
)} 0 -3px 1px inset, ${theme.palette.common.black} 0 1px 2px 0`,
boxShadow: `${alpha(theme.palette.primaryDark[600], 0.1)} 0 2px 0 inset, ${alpha(theme.palette.primaryDark[900], 0.5)} 0 -2px 1px inset, ${theme.palette.common.black} 0 1px 2px 0`,
'&:hover': {
backgroundColor: (theme.vars || theme).palette.primaryDark[700],
},
Expand Down Expand Up @@ -788,6 +785,9 @@ export function getThemedComponents(): ThemeOptions {
'&:hover, &:focus': {
backgroundColor: (theme.vars || theme).palette.grey[50],
},
'&:focus-visible': {
outline: 'none',
},
'&.Mui-selected': {
fontWeight: 500,
color: (theme.vars || theme).palette.primary[600],
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/ApiPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export default function ApiPage(props) {
`)}
language="jsx"
/>
<span dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
<p dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
{componentDescription ? (
<React.Fragment>
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ const Root = styled('div')<{ ownerState: { type?: DescriptionType } }>(
p: { marginBottom: theme.spacing(1.5) },
},
'& .MuiApi-item-note': {
fontSize: 11,
marginLeft: 6,
fontSize: 12,
marginLeft: 2,
letterSpacing: '1px',
textTransform: 'uppercase',
color: `var(--muidocs-palette-success-800, ${lightTheme.palette.success[800]})`,
Expand Down
172 changes: 85 additions & 87 deletions docs/src/modules/components/ApiPage/sections/ToggleDisplayOption.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import Tooltip, { TooltipProps } from '@mui/material/Tooltip';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import ToggleButton, { ToggleButtonProps } from '@mui/material/ToggleButton';
import CalendarViewDayRoundedIcon from '@mui/icons-material/CalendarViewDayRounded';
import TableChartRoundedIcon from '@mui/icons-material/TableChartRounded';
import ReorderRoundedIcon from '@mui/icons-material/ReorderRounded';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import CheckIcon from '@mui/icons-material/Check';
import ArrowDropDownRoundedIcon from '@mui/icons-material/ArrowDropDownRounded';
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';

export type ApiDisplayOptions = 'collapsed' | 'expanded' | 'table';
Expand Down Expand Up @@ -71,26 +71,6 @@ export function useApiPageOption(
return [option, updateOption];
}

// Fix Toggle buton highlight (taken from https://github.com/mui/material-ui/issues/18091)
type TooltipToggleButtonProps = ToggleButtonProps & {
/**
* The title passed to the Tooltip
*/
title: string;
TooltipProps?: Omit<TooltipProps, 'children' | 'title'>;
};

// Catch props and forward to ToggleButton
const TooltipToggleButton = React.forwardRef<HTMLButtonElement, TooltipToggleButtonProps>(
({ title, TooltipProps: tooltipProps, ...props }, ref) => {
return (
<Tooltip {...tooltipProps} title={title}>
<ToggleButton ref={ref} {...props} />
</Tooltip>
);
},
);

interface ToggleDisplayOptionProps {
displayOption: ApiDisplayOptions;
setDisplayOption: (newValue: ApiDisplayOptions) => void;
Expand All @@ -103,72 +83,90 @@ interface ToggleDisplayOptionProps {
export default function ToggleDisplayOption(props: ToggleDisplayOptionProps) {
const { displayOption, setDisplayOption, sectionType } = props;

const handleAlignment = (
event: React.MouseEvent<HTMLElement>,
newDisplayOption: ApiDisplayOptions | null,
) => {
if (newDisplayOption === null) {
return;
}
const [anchorEl, setAnchorEl] = React.useState<HTMLElement | null>(null);
const [open, setOpen] = React.useState(false);

const handleMenuClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
setOpen(true);
};

const handleClose = () => {
setAnchorEl(null);
setOpen(false);
};

const handleMenuItemClick = (newDisplayOption: ApiDisplayOptions) => {
setDisplayOption(newDisplayOption);
handleClose();
};

return (
<ToggleButtonGroup
size="small"
value={displayOption}
exclusive
onChange={handleAlignment}
aria-label="API display option"
sx={{
'& .MuiSvgIcon-root': {
height: '18px',
width: '18px',
},
'&.MuiToggleButtonGroup-root .MuiToggleButton-root': {
padding: '4px 6px',
borderRadius: '6px',
'&.MuiToggleButtonGroup-grouped:not(:last-of-type)': {
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
},
'&.MuiToggleButtonGroup-grouped:not(:first-of-type)': {
borderTopLeftRadius: 0,
borderBottomLeftRadius: 0,
},
},
}}
>
<TooltipToggleButton
value="collapsed"
aria-label="colapsed list"
title="Collapse list view"
data-ga-event-category="layout"
data-ga-event-action={sectionType}
data-ga-event-label="collapsed"
>
<ReorderRoundedIcon size="small" />
</TooltipToggleButton>
<TooltipToggleButton
value="expanded"
aria-label="expanded list"
title="Expand list view"
data-ga-event-category="layout"
data-ga-event-action={sectionType}
data-ga-event-label="expanded"
<React.Fragment>
<Button
size="small"
variant="outlined"
color="secondary"
id="view-switching-button"
aria-controls={open ? 'view-switching-button' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleMenuClick}
endIcon={<ArrowDropDownRoundedIcon />}
sx={{ height: '1.875rem', p: '6px 4px 6px 8px', textTransform: 'capitalize' }}
>
<CalendarViewDayRoundedIcon />
</TooltipToggleButton>
<TooltipToggleButton
value="table"
aria-label="table"
title="Table view"
data-ga-event-category="layout"
data-ga-event-action={sectionType}
data-ga-event-label="table"
<Box component="span" sx={{ fontWeight: 'medium', mr: 0.5 }}>
View:
</Box>
{displayOption}
</Button>
<Menu
id="view-options-menu"
anchorEl={anchorEl}
open={open}
onClose={handleClose}
sx={{ mt: 1, '.MuiMenuItem-root': { pl: 1 } }}
>
<TableChartRoundedIcon />
</TooltipToggleButton>
</ToggleButtonGroup>
<MenuItem
value="table"
onClick={() => handleMenuItemClick('table')}
selected={displayOption === 'table'}
data-ga-event-category="layout"
data-ga-event-action={sectionType}
data-ga-event-label="table"
>
<CheckIcon
sx={{ fontSize: '0.85rem', mr: 1, opacity: displayOption === 'table' ? 1 : 0 }}
/>
Table
</MenuItem>
<MenuItem
value="expanded"
onClick={() => handleMenuItemClick('expanded')}
selected={displayOption === 'expanded'}
data-ga-event-category="layout"
data-ga-event-action={sectionType}
data-ga-event-label="expanded"
>
<CheckIcon
sx={{ fontSize: '0.85rem', mr: 1, opacity: displayOption === 'expanded' ? 1 : 0 }}
/>
Expanded list
</MenuItem>
<MenuItem
value="collapsed"
onClick={() => handleMenuItemClick('collapsed')}
selected={displayOption === 'collapsed'}
data-ga-event-category="layout"
data-ga-event-action={sectionType}
data-ga-event-label="collapsed"
>
<CheckIcon
sx={{ fontSize: '0.85rem', mr: 1, opacity: displayOption === 'collapsed' ? 1 : 0 }}
/>
Collapsed list
</MenuItem>
</Menu>
</React.Fragment>
);
}
49 changes: 18 additions & 31 deletions docs/src/modules/components/ComponentPageTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Tabs, { tabsClasses } from '@mui/material/Tabs';
import Tab, { tabClasses } from '@mui/material/Tab';
import { useTranslate } from '@mui/docs/i18n';
import { useTranslate } from 'docs/src/modules/utils/i18n';
import { Link } from '@mui/docs/Link';

export const HEIGHT = 50;

const StyledTab = styled(Tab)(({ theme }) => ({
padding: theme.spacing(1),
marginBottom: theme.spacing(1),
marginRight: theme.spacing(1),
fontWeight: 600,
minHeight: 32,
padding: theme.spacing(0.5),
border: '1px solid',
borderColor: 'transparent',
fontWeight: theme.typography.fontWeightSemiBold,
minHeight: 30,
minWidth: 0,
borderRadius: '12px',
borderRadius: '8px',
'&:hover': {
background: (theme.vars || theme).palette.grey[50],
borderColor: (theme.vars || theme).palette.divider,
color: (theme.vars || theme).palette.text.primary,
},
...theme.applyDarkStyles({
'&:hover': {
borderColor: (theme.vars || theme).palette.divider,
background: (theme.vars || theme).palette.primaryDark[700],
},
'&.Mui-selected': {
Expand Down Expand Up @@ -54,21 +57,16 @@ export default function ComponentPageTabs(props) {
sx={{
position: 'sticky',
top: 65, // to be positioned below the app bar
mt: 1,
pt: 1,
mx: {
xs: -2,
sm: 0,
},
px: {
xs: 2,
sm: 0,
},
backgroundColor: (theme) =>
theme.palette.mode === 'dark' ? theme.palette.primaryDark[900] : 'rgba(255,255,255)',
mt: 2,
mx: -1,
backgroundColor: 'background.default',
borderBottom: 1,
borderColor: 'divider',
zIndex: 1000,
[`& .${tabsClasses.flexContainer}`]: {
p: 1,
gap: 1,
},
[`& .${tabsClasses.indicator}`]: {
transition: 'none',
},
Expand All @@ -82,20 +80,11 @@ export default function ComponentPageTabs(props) {
},
}}
>
<StyledTab
component={Link}
shallow
scroll
href={demosHref}
label={t('api-docs.demos')}
value=""
/>
<StyledTab component={Link} href={demosHref} label={t('api-docs.demos')} value="" />
{headers.components?.length > 0 && (
<StyledTab
className="skip-algolia-crawler" // For more details, see https://github.com/mui/material-ui/pull/37539.
component={Link}
shallow
scroll
href={componentsHref}
label={t('api-docs.componentsApi')}
value="components-api"
Expand All @@ -105,8 +94,6 @@ export default function ComponentPageTabs(props) {
<StyledTab
className="skip-algolia-crawler" // For more details, see https://github.com/mui/material-ui/pull/37539.
component={Link}
shallow
scroll
href={hooksHref}
label={t('api-docs.hooksApi')}
value="hooks-api"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/ComponentsApiContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default function ComponentsApiContent(props) {
<Heading hash={componentNameKebabCase} text={`${componentName} API`} />
<Heading text="import" hash={`${componentNameKebabCase}-import`} level="h3" />
<HighlightedCode code={importInstructions} language="jsx" />
<span dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
<p dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
<PropertiesSection
properties={componentProps}
propertiesDescriptions={propDescriptions}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/HooksApiContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function HooksApiContent(props) {
<Heading hash={hookNameKebabCase} text={`${hookName} API`} />
<Heading text="import" hash={`${hookNameKebabCase}-import`} level="h3" />
<HighlightedCode code={importInstructions} language="jsx" />
<span dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
<p dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
{Object.keys(parameters).length > 0 ? (
<PropertiesSection
properties={parameters}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-docs/src/translations/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"defaultComponent": "Default component",
"defaultValue": "Default value",
"defaultHTMLTag": "Default HTML tag",
"demos": "Component demos",
"demos": "Demos",
"deprecated": "Deprecated",
"description": "Description",
"globalClass": "Global class",
Expand Down