-
Notifications
You must be signed in to change notification settings - Fork 4.7k
QuickEdit: Add Featured Image Control #64496
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
Changes from 1 commit
785085b
dd7e0a3
77f2217
433e45f
f890963
c32622e
9a39fe6
5419b0a
68ef300
cd923f8
94335a4
030a28d
baf7a82
4095dab
23d8695
ec715ed
ea29690
106af4d
cc46724
b11e923
c6dffd7
3c262d6
c053a9a
57faa8f
d2eeb0e
05f0d1a
c4db3b9
cd9fe2f
8356977
e27dec1
a187591
8815e5a
a461d85
fcc2e6e
577f836
a3449c4
2366429
1b84ac0
6ca01ff
8e612d4
c448c49
2b595c2
9cc6d80
01a57a8
7b1e40a
6592d36
c2994e0
b039310
42f90f4
ea8e941
e77b93b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'; | ||
|
|
@@ -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> | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -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" | ||
| 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' | ||
| ) { | ||
|
||
| 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> | ||
| ); | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related comment: https://github.com/WordPress/gutenberg/pull/64496/files#r1728584779