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

refactor: [M3-6374, M3-6344] - MUI v5 Migration - Components > Placeholder & H1Header #9131

Merged
merged 5 commits into from
May 18, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

[M3-6374] - MUI v5 Migration - `Components > Placeholder` ([#9131](https://github.com/linode/manager/pull/9131))
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

[M3-6344] - MUI v5 Migration - `Components > H1Header` ([#9131](https://github.com/linode/manager/pull/9131))
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { makeStyles } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import Typography from 'src/components/core/Typography';
import EditableText from 'src/components/EditableText';
import H1Header from 'src/components/H1Header';
import { H1Header } from 'src/components/H1Header/H1Header';
import { EditableProps, LabelProps } from './types';

const useStyles = makeStyles((theme: Theme) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ClickAwayListener from 'src/components/core/ClickAwayListener';
import { makeStyles } from '@mui/styles';
import { Theme } from '@mui/material/styles';
import { TextFieldProps } from 'src/components/core/TextField';
import H1Header from 'src/components/H1Header';
import { H1Header } from 'src/components/H1Header/H1Header';
import TextField from '../TextField';

const useStyles = makeStyles((theme: Theme) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import DocsIcon from 'src/assets/icons/docs.svg';
import ExternalLinkIcon from 'src/assets/icons/external-link.svg';
import Placeholder from 'src/components/Placeholder';
import { Placeholder } from 'src/components/Placeholder/Placeholder';
import PointerIcon from 'src/assets/icons/pointer.svg';
import Typography from 'src/components/core/Typography';
import YoutubeIcon from 'src/assets/icons/youtube.svg';
Expand Down
38 changes: 16 additions & 22 deletions packages/manager/src/components/H1Header/H1Header.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
import * as React from 'react';
import { makeStyles } from '@mui/styles';
import { SxProps } from '@mui/system';
import Typography from 'src/components/core/Typography';

interface Props {
title: string;
interface H1HeaderProps {
className?: string;
dataQaEl?: string;
renderAsSecondary?: boolean;
sx?: SxProps;
title: string;
}

const useStyles = makeStyles({
root: {
'&:focus': {
outline: 'none',
},
},
});

// Accessibility Feature:
// The role of this component is to implement focus to the main content when navigating the application
// Since it is a one page APP, we need to help users focus on the main content when switching views
// It should serve as the only source for all H1s
const H1Header: React.FC<Props> = (props) => {
export const H1Header = (props: H1HeaderProps) => {
const h1Header = React.useRef<HTMLDivElement>(null);
const { className, title, dataQaEl, renderAsSecondary } = props;
const classes = useStyles();
const { className, dataQaEl, renderAsSecondary, sx, title } = props;

// React.useEffect(() => {
// if (h1Header.current !== null) {
Expand All @@ -34,17 +25,20 @@ const H1Header: React.FC<Props> = (props) => {

return (
<Typography
variant="h1"
className={className}
component={renderAsSecondary ? 'h2' : 'h1'}
className={`${classes.root} ${className}`}
// If we're rendering as an h2, we want to remove the autofocus functionality
ref={renderAsSecondary ? null : h1Header}
tabIndex={0}
data-qa-header={dataQaEl ? dataQaEl : ''}
ref={renderAsSecondary ? null : h1Header} // If we're rendering as an h2, we want to remove the autofocus functionality
tabIndex={0}
sx={{
'&:focus': {
outline: 'none',
},
...sx,
}}
variant="h1"
>
{title}
</Typography>
);
};

export default H1Header;
2 changes: 0 additions & 2 deletions packages/manager/src/components/H1Header/index.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/manager/src/components/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';

import ErrorOutline from '@mui/icons-material/ErrorOutline';

import Placeholder from 'src/components/Placeholder';
import { Placeholder } from 'src/components/Placeholder/Placeholder';

interface Props {
className?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
import Placeholder from '/src/components/Placeholder';
import { Placeholder } from 'src/components/Placeholder/Placeholder';

<Meta
title="Features/Entity Landing Page/Placeholders"
Expand Down
Loading