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

Post Lock: Fix the avatar position #49421

Merged
merged 2 commits into from
Mar 29, 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
116 changes: 56 additions & 60 deletions packages/editor/src/components/post-locked-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
Modal,
Button,
ExternalLink,
Flex,
FlexItem,
__experimentalHStack as HStack,
} from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { addQueryArgs } from '@wordpress/url';
Expand Down Expand Up @@ -175,55 +174,30 @@ export default function PostLockedModal() {
isDismissible={ false }
className="editor-post-locked-modal"
>
{ !! userAvatar && (
<img
src={ userAvatar }
alt={ __( 'Avatar' ) }
className="editor-post-locked-modal__avatar"
width={ 64 }
height={ 64 }
/>
) }
<div>
{ !! isTakeover && (
<p>
{ createInterpolateElement(
userDisplayName
? sprintf(
/* translators: %s: user's display name */
__(
'<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'
),
userDisplayName
)
: __(
'Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'
),
{
strong: <strong />,
PreviewLink: (
<ExternalLink href={ previewLink }>
{ __( 'preview' ) }
</ExternalLink>
),
}
) }
</p>
<HStack alignment="top" spacing={ 6 }>
{ !! userAvatar && (
<img
src={ userAvatar }
alt={ __( 'Avatar' ) }
className="editor-post-locked-modal__avatar"
width={ 64 }
height={ 64 }
/>
) }
{ ! isTakeover && (
<>
<div>
{ !! isTakeover && (
<p>
{ createInterpolateElement(
userDisplayName
? sprintf(
/* translators: %s: user's display name */
__(
'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'
'<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'
),
userDisplayName
)
: __(
'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'
'Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'
),
{
strong: <strong />,
Expand All @@ -235,33 +209,55 @@ export default function PostLockedModal() {
}
) }
</p>
<p>
{ __(
'If you take over, the other user will lose editing control to the post, but their changes will be saved.'
) }
</p>
</>
) }

<Flex
className="editor-post-locked-modal__buttons"
justify="flex-end"
expanded={ false }
>
) }
{ ! isTakeover && (
<FlexItem>
<>
<p>
{ createInterpolateElement(
userDisplayName
? sprintf(
/* translators: %s: user's display name */
__(
'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'
),
userDisplayName
)
: __(
'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'
),
{
strong: <strong />,
PreviewLink: (
<ExternalLink href={ previewLink }>
{ __( 'preview' ) }
</ExternalLink>
),
}
) }
</p>
<p>
{ __(
'If you take over, the other user will lose editing control to the post, but their changes will be saved.'
) }
</p>
</>
) }

<HStack
className="editor-post-locked-modal__buttons"
justify="flex-end"
>
{ ! isTakeover && (
<Button variant="tertiary" href={ unlockUrl }>
{ __( 'Take over' ) }
</Button>
</FlexItem>
) }
<FlexItem>
) }
<Button variant="primary" href={ allPostsUrl }>
{ allPostsLabel }
</Button>
</FlexItem>
</Flex>
</div>
</HStack>
</div>
</HStack>
</Modal>
);
}
6 changes: 1 addition & 5 deletions packages/editor/src/components/post-locked-modal/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
@include break-small() {
max-width: $break-mobile;
}

.components-modal__content {
display: flex;
}
}

.editor-post-locked-modal__buttons {
Expand All @@ -15,5 +11,5 @@
.editor-post-locked-modal__avatar {
border-radius: $radius-block-ui;
margin-top: $grid-unit-20;
margin-right: $grid-unit-30;
min-width: initial !important;
Copy link
Member Author

Choose a reason for hiding this comment

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

The HStack sets min-width: 0 to all its children. We must override that so the image can take up the entire width.

}