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

Rename experimental-theme.json #21583

Closed
jffng opened this issue Apr 14, 2020 · 9 comments · Fixed by #29981
Closed

Rename experimental-theme.json #21583

jffng opened this issue Apr 14, 2020 · 9 comments · Fixed by #29981
Assignees
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@jffng
Copy link
Contributor

jffng commented Apr 14, 2020

Hello!

Currently the global styles config file is named experimental-theme.json. Can we drop the experimental- and move to theme.json now?

A few arguments in favor of doing so now:

  • The config is not exposed unless the user has the FSE experiment enabled, making the naming redundant
  • It will save theme authors from having to rename this file later
  • block-templates and block-template-parts are not labeled experimental
  • People are already referring to it as theme.json in issues and PRs

Thanks! 😄 cc @kjellr @nosolosw @youknowriad

@kjellr kjellr added [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Apr 14, 2020
@oandregal
Copy link
Member

Perhaps I'm being overly cautious, but I feel that we may end up doing some things differently and that the format is not settled yet. So, to me, keeping it as __experimental-theme.json communicates that spirit of experimentation.

@youknowriad
Copy link
Contributor

I'm in favor of removing the experimental prefix in a release or two but yes, we need to discuss the format we want to show there and there are a few things we want to add there:

1- How to define styles that apply globally.
2- How to define styles that apply per block.
3- How to configure the theme supports and restrictions (Related #20623).
4- How to configure which UI to expose on the global styles panel.

My current thinking is that it should be something close to this:

{
   // Theme styles 
   global: {
      color: "var( --my-palette-color-one )"
      background: "var( --my-palette-color-two)"
      font-size: "var( --my-font-size)"
   }
   blocks: {
       "core/button": {
           font-size: "calc( var( --my-font-size) * 2 )"
       }
   }

   // Config: palette, font sizes, gradients...
   config: {
       color: {
           palette: [],
           allowCustomColors: true,
           gradientPalette: [],
           allowCustomGradients: true
       },
        typography: {
            fontSizes: [],
            allowCustomFontSize: true,
            allowDropCap: true
        },
        blocks: {
            core/paragraph: {
                color: {
                   palette: [],
                   allowCustomCoclors: false
                },
            }
        }
   },

   // Global styles UI
   ui: {
       colorPalette: true, // Display UI to tweak all palette colors
       custom: {
           --my-font-size: { type: 'fontsize' } // Display UI to tweak this font size variable
           --random-variable: { type: 'number' } // Display UI to tweak a random number
       }
   }
}

@kjellr
Copy link
Contributor

kjellr commented Apr 15, 2020

Perhaps I'm being overly cautious, but I feel that we may end up doing some things differently and that the format is not settled yet.

The format, as in whether it's JSON or some other file format like CSS? Or are you referring to the formatting of the json in the file itself?

As long as we're settled in on using JSON in general, I think it's fine to drop the prefix. It already doesn't work unless you specifically check a box marked "Experimental" in the plugin, so I think the experimental nature is pretty clear.

@oandregal
Copy link
Member

oandregal commented Apr 15, 2020

The format, as in whether it's JSON or some other file format like CSS? Or are you referring to the formatting of the json in the file itself?

From my point of view, even the format is open. Example of something we need to fix before stating this is the right format: translate strings in JSONs --- which is important if we want to incorporate things like Riad's suggestions above that now themes do in PHP (registering custom font sizes or colors). I'm perhaps being extra careful, but I do want to be very clear in communicating this is still open so there aren't any misunderstandings in the future.

Having said that, it's only a file name! I'm fine with any name, as long as people are willing to adapt if we find some roadblocks that force us to.

@gziolo
Copy link
Member

gziolo commented Apr 30, 2020

I’m digging into this world of global styles and full site editing templates. I discovered those two functions:

function gutenberg_experimental_global_styles_get_core() {
	return gutenberg_experimental_global_styles_get_from_file(
		dirname( dirname( __FILE__ ) ) . '/experimental-default-global-styles.json'
	);
}
function gutenberg_experimental_global_styles_get_theme() {
    return gutenberg_experimental_global_styles_get_from_file(
        locate_template( 'experimental-theme.json' )
    );
}

Now the question is whether we are ready to rename those config files to theme.json for consistency?

Should gutenberg_experimental_global_styles_get_from_file be renamed as well? How about gutenberg_get_theme_config knowing that it going to contain more config options, not only for global themes?

@jffng
Copy link
Contributor Author

jffng commented Apr 30, 2020

Now the question is whether we are ready to rename those config files to theme.json for consistency?

Will this config be stored or supplied by any other contexts than a theme and the Gutenberg default?


1- How to define styles that apply globally.
2- How to define styles that apply per block.
3- How to configure the theme supports and restrictions (Related #20623).
4- How to configure which UI to expose on the global styles panel.

From a philosophical standpoint, if themes are the primary mechanism to control and unify these four aspects of a site and potentially more, then theme.json or config.json (which lives in the theme) could make sense. But I hear @nosolosw's point; more experimentation is needed because merely declaring a file name won't make all of it possible, and maybe I opened this issue to remove the experimental flag too hastily.

@pattonwebz
Copy link
Member

pattonwebz commented Jun 3, 2020

I've been a lurker and following along for a while here. I think now is the time to move on this and remove the experimental- prefix. Even if we are still experimenting a bit there is an expectation that things are nearing completion and we can start to show that by making this file just theme.json.

@aristath
Copy link
Member

aristath commented Jun 3, 2020

+1 to what @pattonwebz just mentioned above... We are nearing completion, so removing the experimental- prefix makes perfect sense now.
Soon we'll start accepting FSE themes on w.org, all the ground work was done and we can start working on them properly. If the experimental thing stays any longer, it just increases the chances of things breaking down the line.

@youknowriad
Copy link
Contributor

Having the "theme.json" file is a great opportunity to solve some of the theme related issues on Gutenberg without breaking existing themes. Examples:

  • Fix alignments support (automatic support without having the theme provide any style)
  • Automatic CSS generation for palettes (fonts, gradients, colors)
  • Fix some block markup (buttons)

For these reasons, I think we should still keep this as experimental and take this opportunity to solve these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
7 participants