Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
785085b
Page Edit View: Implement Featured image page field
gigitux Aug 14, 2024
dd7e0a3
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Aug 14, 2024
77f2217
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Aug 21, 2024
433e45f
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Aug 21, 2024
f890963
improve flow and style
gigitux Aug 22, 2024
c32622e
fix list layout
gigitux Aug 22, 2024
9a39fe6
improve design
gigitux Aug 23, 2024
5419b0a
remove not necessary style
gigitux Aug 23, 2024
68ef300
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Aug 26, 2024
cd923f8
improve style
gigitux Aug 27, 2024
94335a4
improve default image control
gigitux Aug 27, 2024
030a28d
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Aug 27, 2024
baf7a82
fix style
gigitux Aug 29, 2024
4095dab
remove not necessary configuration
gigitux Aug 29, 2024
23d8695
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Aug 29, 2024
ec715ed
format _z-index.scss file
gigitux Aug 29, 2024
ea29690
improve style
gigitux Aug 29, 2024
106af4d
remove not necessary code
gigitux Aug 29, 2024
cc46724
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Aug 29, 2024
b11e923
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Sep 9, 2024
c6dffd7
fix focus
gigitux Sep 9, 2024
3c262d6
remove image field type
gigitux Sep 9, 2024
c053a9a
add comment
gigitux Sep 9, 2024
57faa8f
fix warning
gigitux Sep 9, 2024
d2eeb0e
fix image for deleted pages
gigitux Sep 9, 2024
05f0d1a
remove filename
gigitux Sep 10, 2024
c4db3b9
add border-radius
gigitux Sep 10, 2024
cd9fe2f
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Sep 18, 2024
8356977
migrate featured image to fields package
gigitux Sep 18, 2024
e27dec1
fix CSS
gigitux Sep 19, 2024
a187591
remove not necessary changes
gigitux Sep 19, 2024
8815e5a
fix type
gigitux Sep 19, 2024
a461d85
remove empty space
gigitux Sep 19, 2024
fcc2e6e
fix z-index gallery
gigitux Sep 19, 2024
577f836
fix overlapping and style
gigitux Sep 19, 2024
a3449c4
improve codestyle
gigitux Sep 19, 2024
2366429
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Sep 20, 2024
1b84ac0
use same placeholder style grid/list layout
gigitux Sep 20, 2024
6ca01ff
fix tsconfig
gigitux Sep 20, 2024
8e612d4
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Oct 22, 2024
c448c49
add type
gigitux Oct 22, 2024
2b595c2
remove mediaField from layout table
gigitux Oct 22, 2024
9cc6d80
update type
gigitux Oct 22, 2024
01a57a8
use text as type
gigitux Oct 22, 2024
7b1e40a
use media-utils package
gigitux Oct 22, 2024
6592d36
fix tsconfig
gigitux Oct 22, 2024
c2994e0
remove view prop
gigitux Oct 22, 2024
b039310
revert changes
gigitux Oct 22, 2024
42f90f4
generate package-lock.json
gigitux Oct 22, 2024
ea8e941
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux Oct 23, 2024
e77b93b
generate package-lock.json
gigitux Oct 23, 2024
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
Prev Previous commit
Next Next commit
improve design
  • Loading branch information
gigitux committed Aug 23, 2024
commit 9a39fe6a8d758d27479d8910d47e3eac708dfc49
172 changes: 96 additions & 76 deletions packages/edit-site/src/components/post-fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import {
} from '@wordpress/icons';
import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
__experimentalText as Text,
__experimentalGrid as Grid,
Icon,
Placeholder,
Button,
Flex,
FlexItem,
} from '@wordpress/components';
import { useSelect } from '@wordpress/data';
Expand Down Expand Up @@ -424,14 +425,14 @@ function usePostFields( viewType ) {

if ( ! url ) {
return (
<div
style={ {
backgroundColor:
'rgba(var(--wp-admin-theme-color--rgb), 0.08)',
width: '20px',
height: '20px',
} }
/>
<Flex gap={ 8 }>
<FlexItem>
<span className="edit-site-post-featured-image-placeholder" />
</FlexItem>
<FlexItem>
<span>{ __( 'Choose an image…' ) }</span>
</FlexItem>
</Flex>
);
}

Expand Down Expand Up @@ -469,77 +470,96 @@ function usePostFields( viewType ) {
return (
<fieldset className="edit-site-dataviews-controls__featured-image">
<div className="edit-side-dataviews-controls__featured-image-container">
<HStack>
<MediaUpload
onSelect={ ( selectedMedia ) =>
onChangeControl( selectedMedia.id )
}
allowedTypes={ [ 'image' ] }
render={ ( { open } ) => {
return (
<Button
className="edit-site-dataviews-controls__featured-image-upload-button"
onClick={ () => open() }
<MediaUpload
onSelect={ ( selectedMedia ) =>
onChangeControl( selectedMedia.id )
}
allowedTypes={ [ 'image' ] }
render={ ( { open } ) => {
return (
<div
role="button"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tabIndex={ 0 }
onClick={ ( event ) => {
const element =
event.target.tagName.toLowerCase();
// Prevent opening the media modal when clicking on the button/icon.
if (
element !== 'button' &&
element !== 'svg'
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue is that there's a button within a clickable area, and clicking the button triggers a separate action. I'm not sure if this is the best way to handle it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we should avoid nested buttons. We had a similar issue in data views list layout... this UI:

Screenshot 2024-08-23 at 11 41 02

Perhaps some of the techniques there can be borrowed?

open();
}
} }
onKeyDown={ open }
>
<Grid
rowGap={ 0 }
columnGap={ 8 }
templateColumns="24px 1fr 0.5fr"
rows={ url ? 2 : 0 }
>
{ url && (
<HStack justify="space-between">
<FlexItem className="edit-site-dataviews-controls__featured-image-element">
<img
alt=""
src={ url }
/>
</FlexItem>
<FlexItem>
<VStack>
<span>
{
title
}
</span>
<span className="edit-site-dataviews-controls__featured-image-filename">
{
filename
}
</span>
</VStack>
</FlexItem>
</HStack>
<>
<img
alt=""
src={ url }
className="edit-site-dataviews-controls__featured-image-element"
/>
<Text
as="span"
truncate
numberOfLines={
0
}
>
{ title }
</Text>
</>
) }
{ ! url && (
<HStack
justify="flex-start"
className="dataviews-controls__featured-image-placeholder-container"
>
<FlexItem>
<Placeholder
className="dataviews-controls__featured-image-placeholder"
withIllustration
/>
</FlexItem>
<FlexItem>
<span>
{ __(
'Choose an image…'
) }
</span>
</FlexItem>
</HStack>
<>
<span className="edit-site-post-featured-image-placeholder" />
<span>
{ __(
'Choose an image…'
) }
</span>
</>
) }
{ url && (
<>
<Button
size="small"
className="edit-site-dataviews-controls__featured-image-remove-button"
icon={
lineSolid
}
onClick={ () =>
onChangeControl(
0
)
}
/>
<Text
className="edit-site-dataviews-controls__featured-image-filename"
as="span"
ellipsizeMode="middle"
limit={ 35 }
truncate
numberOfLines={
0
}
>
{ filename }
</Text>
</>
) }
</Button>
);
} }
/>

{ url && (
<Button
className="edit-site-dataviews-controls__featured-image-remove-button"
icon={ lineSolid }
onClick={ () =>
onChangeControl( 0 )
}
/>
) }
</HStack>
</Grid>
</div>
);
} }
/>
</div>
</fieldset>
);
Expand Down
38 changes: 27 additions & 11 deletions packages/edit-site/src/components/post-fields/style.scss
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
.edit-site-post-featured-image {
width: 20px;
height: 20px;
width: 24px;
height: 24px;
border: $radius-small;
}

.edit-site-post-featured-image-placeholder {
width: 24px;
height: 24px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
display: inline-block;
padding: 0;
background:
$white
linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
}

.edit-site-dataviews-controls__featured-image {
.edit-side-dataviews-controls__featured-image-container {
border: var(--wp-admin-border-width-focus) solid $gray-300;
border: $border-width solid $gray-300;
padding: 8px 12px;
cursor: pointer;
&:hover {
background-color: $gray-300;
background-color: $gray-100;
}
}

img {
width: 20px;
height: 20px;
width: 24px;
height: 24px;
border: $radius-small;
}

span {
align-self: center;
text-align: start;
margin-left: $grid-unit-15;
text-overflow: ellipsis;
overflow: hidden;
width: 200px;
white-space: nowrap;
}

.edit-site-dataviews-controls__featured-image-filename {
color: $gray-700;
font-size: 10px;
grid-area: 2 / 2 / 2 / 4;
line-height: 16px;
font-size: 12px;
}

.edit-site-dataviews-controls__featured-image-upload-button {
padding: 0;
height: fit-content;
&:hover,
&:focus {
Expand All @@ -44,6 +59,7 @@
}

.edit-site-dataviews-controls__featured-image-remove-button {
place-self: end;
align-self: baseline;
}
}
Expand Down