Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Add caption styles in theme.json #219

Closed
ndiego opened this issue Sep 29, 2022 · 10 comments
Closed

Add caption styles in theme.json #219

ndiego opened this issue Sep 29, 2022 · 10 comments

Comments

@ndiego
Copy link
Member

ndiego commented Sep 29, 2022

I think it would be worthwhile to add caption styles in theme.json. In doing a bit of testing, there is a good amount of visual inconsistency between the Editor and Frontend. This is due to Editor specific styles that do not get loaded on the Frontend, which is a separate issue in my opinion. But until that is address/discussed in Gutenberg, simply adding theme-specific caption styles in theme.json would solve this.

Editor:

image

Frontend:

image

@carolinan
Copy link
Collaborator

Hi Nick!
Captions are already parts of theme.json elements, does it not work for you?
https://github.com/WordPress/gutenberg/blob/trunk/schemas/json/theme.json#L1256

{
	"version": 2,
	"styles": {
		"elements": {
			"caption": {
				"color": {
					"text": "#111111"
				},
				"typography": {
					"fontSize": "0.8rem",
					"lineHeight": ".7",
					"textTransform": "uppercase"
				}
			}
		}
	}
}

You may also be interested in WordPress/gutenberg#44094

@carolinan
Copy link
Collaborator

I am an idiot 😆 I mistook this for being in the Gutenberg repo, not TT3.

@mikachan mikachan added [Type] Enhancement New feature or request Good First Issue Good for newcomers labels Sep 29, 2022
@mikachan mikachan added this to the Beta 3 milestone Sep 29, 2022
@bgardner
Copy link

Not sure the best path forward here, as image captions currently have center text align per this, in theme.css:

.wp-block-image figcaption {
    color: #555;
    font-size: 13px;
    text-align: center;
}

But theme.json does not support text align for captions (in elements), which means visual parody is not possible. (Unless I'm missing something.)

@ndiego
Copy link
Member Author

ndiego commented Sep 29, 2022

Good call @bgardner.

@mikachan I just realized what the main issue is. We are not opting into WP block styles, i.e. add_theme_support( 'wp-block-styles' ); This is fine, but then you have to add them all yourself, which we are not doing. The issue arises with the Code block as well. It looks fine in the Editor, but the Frontend has no style. Enabling add_theme_support( 'wp-block-styles' ); fixes this, as it does with the caption styles.

@mikachan
Copy link
Member

Ahh I see, thanks for looking into this further. I've actually just opened an issue for something similar to this here: WordPress/gutenberg#44510

I noticed that the block styles stylesheet is included in the editor, even when the theme doesn't opt into wp-block-styles. I'm wondering if this is correct, as it causes issues like this, where the styles are different between the editor and the front end. But I could be missing some context on why we need this stylesheet to always be used in the editor.

@carolinan
Copy link
Collaborator

@aristath and I discussed this earlier this week, but did not start working on a solution:
#202 (comment)

@mikachan
Copy link
Member

Ugh sorry @carolinan, I completely forgot about that issue and I haven't kept up with the conversation there. The comment you've linked to is particularly interesting, I'll let you know if I manage to take a longer look into this.

@ndiego
Copy link
Member Author

ndiego commented Sep 29, 2022

I wonder if the inclusion of the theme.css file in the Editor when support for block styles is not added is simply a mistake or maybe there are backward compatibility reasons for non-block themes? 🤔

@mikachan mikachan added [Type] Gutenberg and removed [Type] Enhancement New feature or request Good First Issue Good for newcomers labels Sep 29, 2022
@mikachan mikachan removed this from the Beta 3 milestone Sep 30, 2022
@mikachan
Copy link
Member

mikachan commented Oct 4, 2022

WordPress/gutenberg#44640 may fix this issue 🎉

@mikachan
Copy link
Member

Fixed with WordPress/gutenberg#44640 🙏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants