mirror of
https://github.com/strapi/strapi.git
synced 2025-08-09 01:07:27 +00:00
fix: design amends
This commit is contained in:
parent
9481178889
commit
5a2effd2bc
@ -81,6 +81,7 @@ const RelationInput = ({
|
|||||||
publicationStateTranslations,
|
publicationStateTranslations,
|
||||||
required,
|
required,
|
||||||
relations: paginatedRelations,
|
relations: paginatedRelations,
|
||||||
|
toOneRelation,
|
||||||
searchResults,
|
searchResults,
|
||||||
size,
|
size,
|
||||||
}) => {
|
}) => {
|
||||||
@ -261,6 +262,8 @@ const RelationInput = ({
|
|||||||
}
|
}
|
||||||
}, [previewRelationsLength, relations]);
|
}, [previewRelationsLength, relations]);
|
||||||
|
|
||||||
|
const ariaDescriptionId = `${name}-item-instructions`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Field error={error} name={name} hint={description} id={id}>
|
<Field error={error} name={name} hint={description} id={id}>
|
||||||
<Relation
|
<Relation
|
||||||
@ -323,7 +326,7 @@ const RelationInput = ({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<RelationList overflow={overflow}>
|
<RelationList overflow={overflow}>
|
||||||
<VisuallyHidden id={`${name}-item-instructions`}>{listAriaDescription}</VisuallyHidden>
|
<VisuallyHidden id={ariaDescriptionId}>{listAriaDescription}</VisuallyHidden>
|
||||||
<VisuallyHidden aria-live="assertive">{liveText}</VisuallyHidden>
|
<VisuallyHidden aria-live="assertive">{liveText}</VisuallyHidden>
|
||||||
<List
|
<List
|
||||||
height={dynamicListHeight}
|
height={dynamicListHeight}
|
||||||
@ -332,7 +335,8 @@ const RelationInput = ({
|
|||||||
itemCount={totalNumberOfRelations}
|
itemCount={totalNumberOfRelations}
|
||||||
itemSize={RELATION_ITEM_HEIGHT + RELATION_GUTTER}
|
itemSize={RELATION_ITEM_HEIGHT + RELATION_GUTTER}
|
||||||
itemData={{
|
itemData={{
|
||||||
ariaDescribedBy: `${name}-item-instructions`,
|
ariaDescribedBy: ariaDescriptionId,
|
||||||
|
canDrag: !toOneRelation,
|
||||||
disabled,
|
disabled,
|
||||||
handleCancel: onCancel,
|
handleCancel: onCancel,
|
||||||
handleDropItem: onDropItem,
|
handleDropItem: onDropItem,
|
||||||
@ -342,7 +346,6 @@ const RelationInput = ({
|
|||||||
onRelationDisconnect,
|
onRelationDisconnect,
|
||||||
publicationStateTranslations,
|
publicationStateTranslations,
|
||||||
relations,
|
relations,
|
||||||
totalNumberOfRelations,
|
|
||||||
updatePositionOfRelation: handleUpdatePositionOfRelation,
|
updatePositionOfRelation: handleUpdatePositionOfRelation,
|
||||||
}}
|
}}
|
||||||
itemKey={(index, { relations: relationsItems }) => relationsItems[index].id}
|
itemKey={(index, { relations: relationsItems }) => relationsItems[index].id}
|
||||||
@ -395,16 +398,15 @@ RelationInput.defaultProps = {
|
|||||||
description: undefined,
|
description: undefined,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
error: undefined,
|
error: undefined,
|
||||||
iconButtonAriaLabel: 'Drag',
|
|
||||||
labelAction: null,
|
labelAction: null,
|
||||||
labelLoadMore: null,
|
labelLoadMore: null,
|
||||||
listAriaDescription: 'Press spacebar to grab and re-order',
|
|
||||||
liveText: undefined,
|
liveText: undefined,
|
||||||
onCancel: undefined,
|
onCancel: undefined,
|
||||||
onDropItem: undefined,
|
onDropItem: undefined,
|
||||||
onGrabItem: undefined,
|
onGrabItem: undefined,
|
||||||
required: false,
|
required: false,
|
||||||
relations: { data: [] },
|
relations: { data: [] },
|
||||||
|
toOneRelation: false,
|
||||||
searchResults: { data: [] },
|
searchResults: { data: [] },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -412,13 +414,13 @@ RelationInput.propTypes = {
|
|||||||
error: PropTypes.string,
|
error: PropTypes.string,
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
iconButtonAriaLabel: PropTypes.string,
|
iconButtonAriaLabel: PropTypes.string.isRequired,
|
||||||
id: PropTypes.string.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
label: PropTypes.string.isRequired,
|
label: PropTypes.string.isRequired,
|
||||||
labelAction: PropTypes.element,
|
labelAction: PropTypes.element,
|
||||||
labelLoadMore: PropTypes.string,
|
labelLoadMore: PropTypes.string,
|
||||||
labelDisconnectRelation: PropTypes.string.isRequired,
|
labelDisconnectRelation: PropTypes.string.isRequired,
|
||||||
listAriaDescription: PropTypes.string,
|
listAriaDescription: PropTypes.string.isRequired,
|
||||||
liveText: PropTypes.string,
|
liveText: PropTypes.string,
|
||||||
loadingMessage: PropTypes.string.isRequired,
|
loadingMessage: PropTypes.string.isRequired,
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
@ -439,6 +441,7 @@ RelationInput.propTypes = {
|
|||||||
published: PropTypes.string.isRequired,
|
published: PropTypes.string.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
required: PropTypes.bool,
|
required: PropTypes.bool,
|
||||||
|
toOneRelation: PropTypes.bool,
|
||||||
searchResults: SearchResults,
|
searchResults: SearchResults,
|
||||||
size: PropTypes.number.isRequired,
|
size: PropTypes.number.isRequired,
|
||||||
relations: RelationsResult,
|
relations: RelationsResult,
|
||||||
@ -451,6 +454,7 @@ RelationInput.propTypes = {
|
|||||||
const ListItem = ({ data, index, style }) => {
|
const ListItem = ({ data, index, style }) => {
|
||||||
const {
|
const {
|
||||||
ariaDescribedBy,
|
ariaDescribedBy,
|
||||||
|
canDrag,
|
||||||
disabled,
|
disabled,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
handleDropItem,
|
handleDropItem,
|
||||||
@ -460,12 +464,10 @@ const ListItem = ({ data, index, style }) => {
|
|||||||
onRelationDisconnect,
|
onRelationDisconnect,
|
||||||
publicationStateTranslations,
|
publicationStateTranslations,
|
||||||
relations,
|
relations,
|
||||||
totalNumberOfRelations,
|
|
||||||
updatePositionOfRelation,
|
updatePositionOfRelation,
|
||||||
} = data;
|
} = data;
|
||||||
const { publicationState, href, mainField, id } = relations[index];
|
const { publicationState, href, mainField, id } = relations[index];
|
||||||
const statusColor = publicationState === 'draft' ? 'secondary' : 'success';
|
const statusColor = publicationState === 'draft' ? 'secondary' : 'success';
|
||||||
const canDrag = totalNumberOfRelations > 1;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RelationItem
|
<RelationItem
|
||||||
@ -528,6 +530,7 @@ ListItem.defaultProps = {
|
|||||||
ListItem.propTypes = {
|
ListItem.propTypes = {
|
||||||
data: PropTypes.shape({
|
data: PropTypes.shape({
|
||||||
ariaDescribedBy: PropTypes.string.isRequired,
|
ariaDescribedBy: PropTypes.string.isRequired,
|
||||||
|
canDrag: PropTypes.bool.isRequired,
|
||||||
disabled: PropTypes.bool.isRequired,
|
disabled: PropTypes.bool.isRequired,
|
||||||
handleCancel: PropTypes.func,
|
handleCancel: PropTypes.func,
|
||||||
handleDropItem: PropTypes.func,
|
handleDropItem: PropTypes.func,
|
||||||
@ -547,7 +550,6 @@ ListItem.propTypes = {
|
|||||||
mainField: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
mainField: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
totalNumberOfRelations: PropTypes.number.isRequired,
|
|
||||||
updatePositionOfRelation: PropTypes.func.isRequired,
|
updatePositionOfRelation: PropTypes.func.isRequired,
|
||||||
}),
|
}),
|
||||||
index: PropTypes.number.isRequired,
|
index: PropTypes.number.isRequired,
|
||||||
|
@ -18,6 +18,10 @@ const ChildrenWrapper = styled(Flex)`
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const IconButtonWrapper = styled.div`
|
||||||
|
margin-right: ${(props) => props.theme.spaces[1]};
|
||||||
|
`;
|
||||||
|
|
||||||
const RELATION_ITEM_DRAG_TYPE = 'RelationItem';
|
const RELATION_ITEM_DRAG_TYPE = 'RelationItem';
|
||||||
|
|
||||||
export const RelationItem = ({
|
export const RelationItem = ({
|
||||||
@ -189,17 +193,18 @@ export const RelationItem = ({
|
|||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{canDrag ? (
|
{canDrag ? (
|
||||||
<IconButton
|
<IconButtonWrapper>
|
||||||
forwardedAs="div"
|
<IconButton
|
||||||
role="button"
|
forwardedAs="div"
|
||||||
tabIndex={0}
|
role="button"
|
||||||
marginRight={1}
|
tabIndex={0}
|
||||||
aria-label={iconButtonAriaLabel}
|
aria-label={iconButtonAriaLabel}
|
||||||
noBorder
|
noBorder
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
>
|
>
|
||||||
<Drag />
|
<Drag />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
</IconButtonWrapper>
|
||||||
) : null}
|
) : null}
|
||||||
<ChildrenWrapper justifyContent="space-between">{children}</ChildrenWrapper>
|
<ChildrenWrapper justifyContent="space-between">{children}</ChildrenWrapper>
|
||||||
{endAction && <Box paddingLeft={4}>{endAction}</Box>}
|
{endAction && <Box paddingLeft={4}>{endAction}</Box>}
|
||||||
|
@ -346,6 +346,7 @@ export const RelationInputDataManager = ({
|
|||||||
'isSuccess'
|
'isSuccess'
|
||||||
)}
|
)}
|
||||||
required={required}
|
required={required}
|
||||||
|
toOneRelation={toOneRelation}
|
||||||
searchResults={normalizeSearchResults(search, {
|
searchResults={normalizeSearchResults(search, {
|
||||||
mainFieldName: mainField.name,
|
mainFieldName: mainField.name,
|
||||||
})}
|
})}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user