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

View File

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

View File

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

View File

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

View File

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