Merge branch 'master' into colors-fix

This commit is contained in:
EzraEn 2022-01-10 17:03:41 +08:00 committed by GitHub
commit 7e9c449efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 264 additions and 132 deletions

View File

@ -17,7 +17,7 @@ const StyledBox = styled(Box)`
border-radius: ${pxToRem(26)}; border-radius: ${pxToRem(26)};
`; `;
const DzLabel = ({ label, labelAction, name, numberOfComponents, required }) => { const DzLabel = ({ label, labelAction, name, numberOfComponents, required, intlDescription }) => {
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const intlLabel = formatMessage({ id: label || name, defaultMessage: label || name }); const intlLabel = formatMessage({ id: label || name, defaultMessage: label || name });
@ -33,13 +33,25 @@ const DzLabel = ({ label, labelAction, name, numberOfComponents, required }) =>
shadow="filterShadow" shadow="filterShadow"
color="neutral500" color="neutral500"
> >
<Flex> <Flex direction="column" justifyContent="center">
<Typography fontSize={0} lineHeight={0} textColor="neutral600" fontWeight="bold"> <Flex maxWidth={pxToRem(356)}>
{intlLabel}&nbsp;({numberOfComponents}) <Typography variant="pi" textColor="neutral600" fontWeight="bold" ellipsis>
{intlLabel}&nbsp;
</Typography>
<Typography variant="pi" textColor="neutral600" fontWeight="bold">
({numberOfComponents})
</Typography> </Typography>
{required && <Typography textColor="danger600">*</Typography>} {required && <Typography textColor="danger600">*</Typography>}
{labelAction && <Box paddingLeft={1}>{labelAction}</Box>} {labelAction && <Box paddingLeft={1}>{labelAction}</Box>}
</Flex> </Flex>
{intlDescription && (
<Box paddingTop={1} maxWidth={pxToRem(356)}>
<Typography variant="pi" textColor="neutral600" ellipsis>
{formatMessage(intlDescription)}
</Typography>
</Box>
)}
</Flex>
</StyledBox> </StyledBox>
</Box> </Box>
</Flex> </Flex>
@ -47,12 +59,17 @@ const DzLabel = ({ label, labelAction, name, numberOfComponents, required }) =>
}; };
DzLabel.defaultProps = { DzLabel.defaultProps = {
intlDescription: undefined,
label: '', label: '',
labelAction: undefined, labelAction: undefined,
required: false, required: false,
}; };
DzLabel.propTypes = { DzLabel.propTypes = {
intlDescription: PropTypes.shape({
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired,
}),
label: PropTypes.string, label: PropTypes.string,
labelAction: PropTypes.element, labelAction: PropTypes.element,
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<DzLabel /> displays the labelAction correctly 1`] = ` exports[`<DzLabel /> displays the labelAction correctly 1`] = `
.c7 { .c10 {
border: 0; border: 0;
-webkit-clip: rect(0 0 0 0); -webkit-clip: rect(0 0 0 0);
clip: rect(0 0 0 0); clip: rect(0 0 0 0);
@ -23,10 +23,14 @@ exports[`<DzLabel /> displays the labelAction correctly 1`] = `
box-shadow: 0px 1px 4px rgba(33,33,52,0.1); box-shadow: 0px 1px 4px rgba(33,33,52,0.1);
} }
.c5 { .c8 {
padding-left: 4px; padding-left: 4px;
} }
.c4 {
max-width: 22.25rem;
}
.c0 { .c0 {
display: -webkit-box; display: -webkit-box;
display: -webkit-flex; display: -webkit-flex;
@ -46,6 +50,24 @@ exports[`<DzLabel /> displays the labelAction correctly 1`] = `
} }
.c3 { .c3 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.c5 {
display: -webkit-box; display: -webkit-box;
display: -webkit-flex; display: -webkit-flex;
display: -ms-flexbox; display: -ms-flexbox;
@ -59,32 +81,41 @@ exports[`<DzLabel /> displays the labelAction correctly 1`] = `
align-items: center; align-items: center;
} }
.c4 { .c6 {
font-weight: 600; font-weight: 600;
font-size: 0.6875rem;
line-height: 1.14;
color: #666687; color: #666687;
font-size: 0.875rem; display: block;
line-height: 1.43; white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 0.75rem;
line-height: 1.33;
}
.c7 {
font-weight: 600;
color: #666687;
font-size: 0.75rem;
line-height: 1.33;
} }
.c2 { .c2 {
border-radius: 1.625rem; border-radius: 1.625rem;
} }
.c6 { .c9 {
border: none; border: none;
padding: 0; padding: 0;
background: transparent; background: transparent;
} }
.c6 svg { .c9 svg {
width: 12px; width: 12px;
height: 12px; height: 12px;
fill: #8e8ea9; fill: #8e8ea9;
} }
.c6 svg path { .c9 svg path {
fill: #8e8ea9; fill: #8e8ea9;
} }
@ -100,23 +131,31 @@ exports[`<DzLabel /> displays the labelAction correctly 1`] = `
> >
<div <div
class="c3" class="c3"
>
<div
class="c4 c5"
> >
<span <span
class="c4" class="c6"
> >
dz dz
 (  
</span>
<span
class="c7"
>
(
1 1
) )
</span> </span>
<div <div
class="c5" class="c8"
> >
<span> <span>
<button <button
aria-describedby="tooltip-1" aria-describedby="tooltip-1"
aria-label="i18n" aria-label="i18n"
class="c6" class="c9"
tabindex="0" tabindex="0"
type="button" type="button"
> >
@ -148,8 +187,9 @@ exports[`<DzLabel /> displays the labelAction correctly 1`] = `
</div> </div>
</div> </div>
</div> </div>
</div>
<div <div
class="c7" class="c10"
> >
<p <p
aria-live="polite" aria-live="polite"
@ -174,7 +214,7 @@ exports[`<DzLabel /> displays the labelAction correctly 1`] = `
`; `;
exports[`<DzLabel /> displays the name of the dz when the label is empty 1`] = ` exports[`<DzLabel /> displays the name of the dz when the label is empty 1`] = `
.c5 { .c8 {
border: 0; border: 0;
-webkit-clip: rect(0 0 0 0); -webkit-clip: rect(0 0 0 0);
clip: rect(0 0 0 0); clip: rect(0 0 0 0);
@ -196,6 +236,10 @@ exports[`<DzLabel /> displays the name of the dz when the label is empty 1`] = `
box-shadow: 0px 1px 4px rgba(33,33,52,0.1); box-shadow: 0px 1px 4px rgba(33,33,52,0.1);
} }
.c4 {
max-width: 22.25rem;
}
.c0 { .c0 {
display: -webkit-box; display: -webkit-box;
display: -webkit-flex; display: -webkit-flex;
@ -215,6 +259,24 @@ exports[`<DzLabel /> displays the name of the dz when the label is empty 1`] = `
} }
.c3 { .c3 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.c5 {
display: -webkit-box; display: -webkit-box;
display: -webkit-flex; display: -webkit-flex;
display: -ms-flexbox; display: -ms-flexbox;
@ -228,13 +290,22 @@ exports[`<DzLabel /> displays the name of the dz when the label is empty 1`] = `
align-items: center; align-items: center;
} }
.c4 { .c6 {
font-weight: 600; font-weight: 600;
font-size: 0.6875rem;
line-height: 1.14;
color: #666687; color: #666687;
font-size: 0.875rem; display: block;
line-height: 1.43; white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 0.75rem;
line-height: 1.33;
}
.c7 {
font-weight: 600;
color: #666687;
font-size: 0.75rem;
line-height: 1.33;
} }
.c2 { .c2 {
@ -253,12 +324,20 @@ exports[`<DzLabel /> displays the name of the dz when the label is empty 1`] = `
> >
<div <div
class="c3" class="c3"
>
<div
class="c4 c5"
> >
<span <span
class="c4" class="c6"
> >
test test
 (  
</span>
<span
class="c7"
>
(
1 1
) )
</span> </span>
@ -266,8 +345,9 @@ exports[`<DzLabel /> displays the name of the dz when the label is empty 1`] = `
</div> </div>
</div> </div>
</div> </div>
</div>
<div <div
class="c5" class="c8"
> >
<p <p
aria-live="polite" aria-live="polite"
@ -292,7 +372,7 @@ exports[`<DzLabel /> displays the name of the dz when the label is empty 1`] = `
`; `;
exports[`<DzLabel /> renders and matches the snapshot 1`] = ` exports[`<DzLabel /> renders and matches the snapshot 1`] = `
.c5 { .c8 {
border: 0; border: 0;
-webkit-clip: rect(0 0 0 0); -webkit-clip: rect(0 0 0 0);
clip: rect(0 0 0 0); clip: rect(0 0 0 0);
@ -314,6 +394,10 @@ exports[`<DzLabel /> renders and matches the snapshot 1`] = `
box-shadow: 0px 1px 4px rgba(33,33,52,0.1); box-shadow: 0px 1px 4px rgba(33,33,52,0.1);
} }
.c4 {
max-width: 22.25rem;
}
.c0 { .c0 {
display: -webkit-box; display: -webkit-box;
display: -webkit-flex; display: -webkit-flex;
@ -333,6 +417,24 @@ exports[`<DzLabel /> renders and matches the snapshot 1`] = `
} }
.c3 { .c3 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.c5 {
display: -webkit-box; display: -webkit-box;
display: -webkit-flex; display: -webkit-flex;
display: -ms-flexbox; display: -ms-flexbox;
@ -346,13 +448,22 @@ exports[`<DzLabel /> renders and matches the snapshot 1`] = `
align-items: center; align-items: center;
} }
.c4 { .c6 {
font-weight: 600; font-weight: 600;
font-size: 0.6875rem;
line-height: 1.14;
color: #666687; color: #666687;
font-size: 0.875rem; display: block;
line-height: 1.43; white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 0.75rem;
line-height: 1.33;
}
.c7 {
font-weight: 600;
color: #666687;
font-size: 0.75rem;
line-height: 1.33;
} }
.c2 { .c2 {
@ -371,12 +482,20 @@ exports[`<DzLabel /> renders and matches the snapshot 1`] = `
> >
<div <div
class="c3" class="c3"
>
<div
class="c4 c5"
> >
<span <span
class="c4" class="c6"
> >
dz dz
 (  
</span>
<span
class="c7"
>
(
1 1
) )
</span> </span>
@ -384,8 +503,9 @@ exports[`<DzLabel /> renders and matches the snapshot 1`] = `
</div> </div>
</div> </div>
</div> </div>
</div>
<div <div
class="c5" class="c8"
> >
<p <p
aria-live="polite" aria-live="polite"

View File

@ -39,6 +39,9 @@ const DynamicZone = ({
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const [shouldOpenAddedComponent, setShouldOpenAddedComponent] = useState(false); const [shouldOpenAddedComponent, setShouldOpenAddedComponent] = useState(false);
const dynamicDisplayedComponentsLength = dynamicDisplayedComponents.length; const dynamicDisplayedComponentsLength = dynamicDisplayedComponents.length;
const intlDescription = metadatas.description
? { id: metadatas.description, defaultMessage: metadatas.description }
: null;
const [componentCollapses, setComponentsCollapses] = useState( const [componentCollapses, setComponentsCollapses] = useState(
createCollapses(dynamicDisplayedComponentsLength) createCollapses(dynamicDisplayedComponentsLength)
@ -159,11 +162,7 @@ const DynamicZone = ({
if (!isFieldAllowed && isCreatingEntry) { if (!isFieldAllowed && isCreatingEntry) {
return ( return (
<NotAllowedInput <NotAllowedInput
description={ description={intlDescription}
metadatas.description
? { id: metadatas.description, defaultMessage: metadatas.description }
: null
}
intlLabel={{ id: metadatas.label, defaultMessage: metadatas.label }} intlLabel={{ id: metadatas.label, defaultMessage: metadatas.label }}
labelAction={labelAction} labelAction={labelAction}
name={name} name={name}
@ -174,11 +173,7 @@ const DynamicZone = ({
if (!isFieldAllowed && !isFieldReadable && !isCreatingEntry) { if (!isFieldAllowed && !isFieldReadable && !isCreatingEntry) {
return ( return (
<NotAllowedInput <NotAllowedInput
description={ description={intlDescription}
metadatas.description
? { id: metadatas.description, defaultMessage: metadatas.description }
: null
}
intlLabel={{ id: metadatas.label, defaultMessage: metadatas.label }} intlLabel={{ id: metadatas.label, defaultMessage: metadatas.label }}
labelAction={labelAction} labelAction={labelAction}
name={name} name={name}
@ -191,6 +186,7 @@ const DynamicZone = ({
{dynamicDisplayedComponentsLength > 0 && ( {dynamicDisplayedComponentsLength > 0 && (
<Box> <Box>
<DzLabel <DzLabel
intlDescription={intlDescription}
label={metadatas.label} label={metadatas.label}
labelAction={labelAction} labelAction={labelAction}
name={name} name={name}

View File

@ -1,7 +1,6 @@
import React, { memo } from 'react'; import React, { memo } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import get from 'lodash/get'; import get from 'lodash/get';
import upperFirst from 'lodash/upperFirst';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { IconButton } from '@strapi/design-system/IconButton'; import { IconButton } from '@strapi/design-system/IconButton';
import { Flex } from '@strapi/design-system/Flex'; import { Flex } from '@strapi/design-system/Flex';
@ -94,7 +93,7 @@ function ListRow({
{loopNumber !== 0 && <Curve color={isFromDynamicZone ? 'primary200' : 'neutral150'} />} {loopNumber !== 0 && <Curve color={isFromDynamicZone ? 'primary200' : 'neutral150'} />}
<Stack paddingLeft={2} size={4} horizontal> <Stack paddingLeft={2} size={4} horizontal>
<AttributeIcon key={src} type={src} /> <AttributeIcon key={src} type={src} />
<Typography fontWeight="bold">{upperFirst(name)}</Typography> <Typography fontWeight="bold">{name}</Typography>
</Stack> </Stack>
</td> </td>
<td> <td>

View File

@ -1445,7 +1445,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Postal_code postal_code
</span> </span>
</div> </div>
</td> </td>
@ -1549,7 +1549,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Categories categories
</span> </span>
</div> </div>
</td> </td>
@ -1663,7 +1663,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Cover cover
</span> </span>
</div> </div>
</td> </td>
@ -1771,7 +1771,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Images images
</span> </span>
</div> </div>
</td> </td>
@ -1877,7 +1877,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
City city
</span> </span>
</div> </div>
</td> </td>
@ -1985,7 +1985,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Json json
</span> </span>
</div> </div>
</td> </td>
@ -2087,7 +2087,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Slug slug
</span> </span>
</div> </div>
</td> </td>
@ -2199,7 +2199,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Notrepeat_req notrepeat_req
</span> </span>
</div> </div>
</td> </td>
@ -2338,7 +2338,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Name name
</span> </span>
</div> </div>
</td> </td>
@ -2463,7 +2463,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Popo popo
</span> </span>
</div> </div>
</td> </td>
@ -2588,7 +2588,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Poq poq
</span> </span>
</div> </div>
</td> </td>
@ -2880,7 +2880,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Dede dede
</span> </span>
</div> </div>
</td> </td>
@ -3005,7 +3005,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Dada dada
</span> </span>
</div> </div>
</td> </td>
@ -3130,7 +3130,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Papi papi
</span> </span>
</div> </div>
</td> </td>
@ -3673,7 +3673,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Name name
</span> </span>
</div> </div>
</td> </td>
@ -3798,7 +3798,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Mail mail
</span> </span>
</div> </div>
</td> </td>
@ -3923,7 +3923,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Phone phone
</span> </span>
</div> </div>
</td> </td>
@ -4112,7 +4112,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Name name
</span> </span>
</div> </div>
</td> </td>
@ -4237,7 +4237,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Description description
</span> </span>
</div> </div>
</td> </td>
@ -4362,7 +4362,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Price price
</span> </span>
</div> </div>
</td> </td>
@ -4489,7 +4489,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Picture picture
</span> </span>
</div> </div>
</td> </td>
@ -4616,7 +4616,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Very_long_description very_long_description
</span> </span>
</div> </div>
</td> </td>
@ -4739,7 +4739,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Categories categories
</span> </span>
</div> </div>
</td> </td>
@ -4934,7 +4934,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Label label
</span> </span>
</div> </div>
</td> </td>
@ -5059,7 +5059,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Time time
</span> </span>
</div> </div>
</td> </td>
@ -5190,7 +5190,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Dishrep dishrep
</span> </span>
</div> </div>
</td> </td>
@ -5330,7 +5330,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Name name
</span> </span>
</div> </div>
</td> </td>
@ -5455,7 +5455,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Description description
</span> </span>
</div> </div>
</td> </td>
@ -5580,7 +5580,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Price price
</span> </span>
</div> </div>
</td> </td>
@ -5707,7 +5707,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Picture picture
</span> </span>
</div> </div>
</td> </td>
@ -5834,7 +5834,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Very_long_description very_long_description
</span> </span>
</div> </div>
</td> </td>
@ -5957,7 +5957,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Categories categories
</span> </span>
</div> </div>
</td> </td>
@ -6193,7 +6193,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Name name
</span> </span>
</div> </div>
</td> </td>
@ -6320,7 +6320,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Media media
</span> </span>
</div> </div>
</td> </td>
@ -6445,7 +6445,7 @@ exports[`<ListView /> renders and matches the snapshot 1`] = `
<span <span
class="c28 c34" class="c28 c34"
> >
Is_available is_available
</span> </span>
</div> </div>
</td> </td>