Fix PR feedback

Signed-off-by: HichamELBSI <elabbassih@gmail.com>
This commit is contained in:
HichamELBSI 2021-08-06 14:43:58 +02:00
parent 34eb798578
commit 073bea95c8
5 changed files with 40 additions and 24 deletions

View File

@ -1,12 +1,12 @@
import React from 'react'; import React from 'react';
import { ThemeProvider } from 'styled-components'; import { ThemeProvider } from 'styled-components';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
// import GlobalStyle from '../GlobalStyle'; import GlobalStyle from '../GlobalStyle';
import Fonts from '../Fonts'; import Fonts from '../Fonts';
const Theme = ({ children, theme }) => ( const Theme = ({ children, theme }) => (
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
{/* <GlobalStyle /> */} <GlobalStyle />
<Fonts /> <Fonts />
{children} {children}
</ThemeProvider> </ThemeProvider>

View File

@ -14,6 +14,7 @@ import {
TrackingContext, TrackingContext,
} from '@strapi/helper-plugin'; } from '@strapi/helper-plugin';
import { SkipToContent } from '@strapi/parts'; import { SkipToContent } from '@strapi/parts';
import { useIntl } from 'react-intl';
import PrivateRoute from '../../components/PrivateRoute'; import PrivateRoute from '../../components/PrivateRoute';
import { createRoute, makeUniqueRoutes } from '../../utils'; import { createRoute, makeUniqueRoutes } from '../../utils';
import AuthPage from '../AuthPage'; import AuthPage from '../AuthPage';
@ -27,6 +28,7 @@ const AuthenticatedApp = lazy(() =>
function App() { function App() {
const toggleNotification = useNotification(); const toggleNotification = useNotification();
const { formatMessage } = useIntl();
const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false }); const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false });
const authRoutes = useMemo(() => { const authRoutes = useMemo(() => {
@ -106,7 +108,7 @@ function App() {
return ( return (
<Suspense fallback={<LoadingIndicatorPage />}> <Suspense fallback={<LoadingIndicatorPage />}>
<SkipToContent>Skip to content</SkipToContent> <SkipToContent>{formatMessage({ id: 'skipToContent' })}</SkipToContent>
<TrackingContext.Provider value={uuid}> <TrackingContext.Provider value={uuid}>
<Switch> <Switch>
{authRoutes} {authRoutes}

View File

@ -3,11 +3,11 @@ import { Box, Stack, H1, Text, Subtitle, Button, Checkbox, TextInput, Main } fro
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import styled from 'styled-components'; import styled from 'styled-components';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { Formik, Form } from 'formik'; import { Formik } from 'formik';
import { Column } from '../../../../layouts/UnauthenticatedLayout'; import { Column } from '../../../../layouts/UnauthenticatedLayout';
import { useConfigurations } from '../../../../hooks'; import { useConfigurations } from '../../../../hooks';
import FormikFocusError from './FormikFocusError'; import Form from './Form';
const AuthButton = styled(Button)` const AuthButton = styled(Button)`
display: inline-block; display: inline-block;
@ -32,9 +32,8 @@ const Login = ({ onSubmit, schema }) => {
> >
{({ values, errors, handleChange }) => ( {({ values, errors, handleChange }) => (
<Form noValidate> <Form noValidate>
<FormikFocusError />
<Column> <Column>
<img src={authLogo} alt="strapi-app-logo" style={{ height: '72px' }} /> <img src={authLogo} alt="" aria-hidden style={{ height: '72px' }} />
<Box paddingTop="6" paddingBottom="1"> <Box paddingTop="6" paddingBottom="1">
<H1 id="welcome">{formatMessage({ id: 'Auth.form.welcome.title' })}</H1> <H1 id="welcome">{formatMessage({ id: 'Auth.form.welcome.title' })}</H1>
</Box> </Box>

View File

@ -1,7 +1,7 @@
import { useEffect } from 'react'; import React, { useEffect } from 'react';
import { useFormikContext, getIn } from 'formik'; import { Form, useFormikContext, getIn } from 'formik';
const FormikFocusError = () => { const FormWithFocus = props => {
const { isSubmitting, isValidating, errors, touched } = useFormikContext(); const { isSubmitting, isValidating, errors, touched } = useFormikContext();
useEffect(() => { useEffect(() => {
@ -30,7 +30,7 @@ const FormikFocusError = () => {
} }
}, [errors, isSubmitting, isValidating, touched]); }, [errors, isSubmitting, isValidating, touched]);
return null; return <Form {...props} noValidate />;
}; };
export default FormikFocusError; export default FormWithFocus;

View File

@ -1,7 +1,8 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Text, Row, Grid, GridItem } from '@strapi/parts'; import { Text, Row, Grid, GridItem, Tooltip } from '@strapi/parts';
import styled from 'styled-components'; import styled from 'styled-components';
import { useIntl } from 'react-intl';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
const SSOButton = styled.a` const SSOButton = styled.a`
@ -12,7 +13,11 @@ const SSOButton = styled.a`
height: ${48 / 16}rem; height: ${48 / 16}rem;
border: 1px solid ${({ theme }) => theme.colors.neutral150}; border: 1px solid ${({ theme }) => theme.colors.neutral150};
border-radius: ${({ theme }) => theme.borderRadius}; border-radius: ${({ theme }) => theme.borderRadius};
text-decoration: none; text-decoration: inherit;
&:link {
text-decoration: none;
}
color: ${({ theme }) => theme.colors.neutral600};
`; `;
const SSOProvidersWrapper = styled(Row)` const SSOProvidersWrapper = styled(Row)`
@ -29,13 +34,15 @@ const SSOProvidersWrapper = styled(Row)`
const SSOProviderButton = ({ provider }) => { const SSOProviderButton = ({ provider }) => {
return ( return (
<SSOButton href={`${strapi.backendURL}/admin/connect/${provider.uid}`}> <Tooltip label={provider.displayName}>
{provider.icon ? ( <SSOButton href={`${strapi.backendURL}/admin/connect/${provider.uid}`}>
<img src={provider.icon} alt={provider.displayName} height="32px" /> {provider.icon ? (
) : ( <img src={provider.icon} aria-hidden alt="" height="32px" />
<Text>{provider.displayName}</Text> ) : (
)} <Text>{provider.displayName}</Text>
</SSOButton> )}
</SSOButton>
</Tooltip>
); );
}; };
@ -48,6 +55,8 @@ SSOProviderButton.propTypes = {
}; };
const SSOProviders = ({ providers, displayAllProviders }) => { const SSOProviders = ({ providers, displayAllProviders }) => {
const { formatMessage } = useIntl();
if (displayAllProviders) { if (displayAllProviders) {
return ( return (
<Grid gap={4}> <Grid gap={4}>
@ -69,9 +78,15 @@ const SSOProviders = ({ providers, displayAllProviders }) => {
</GridItem> </GridItem>
))} ))}
<GridItem col={4}> <GridItem col={4}>
<SSOButton as={Link} to="/auth/providers"> <Tooltip
<span></span> label={formatMessage({
</SSOButton> id: 'Auth.form.button.login.providers.see-more',
})}
>
<SSOButton as={Link} to="/auth/providers">
<span aroa-hidden></span>
</SSOButton>
</Tooltip>
</GridItem> </GridItem>
</Grid> </Grid>
); );