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

[AMP Stories] Add overlay settings to Page #2046

Merged
merged 6 commits into from
Apr 3, 2019

Conversation

miina
Copy link
Contributor

@miina miina commented Apr 2, 2019

See #2013.

Adds Overlay settings to page which includes two color settings and opacity.
If one color is selected then the background is filled with the color, otherwise gradient is used.

Screen Shot 2019-04-02 at 12 41 44 PM

@googlebot googlebot added the cla: yes Signed the Google CLA label Apr 2, 2019
@miina
Copy link
Contributor Author

miina commented Apr 2, 2019

I'm wondering if it would be better to add a radio button for using Gradient. This way it would also be possible to use gradient with transparent.

At this moment if the "main" color is not selected and the second is then the gradient is created from transparent to the second color. However, the opposite case is not possible.

So perhaps it's better to have a radio to specifically set if the user wants to use gradient or not and then display either one or two color settings accordingly. Or maybe you have better alternatives in mind? Thoughts?

cc @swissspidy @westonruter

return (
<Fragment>
<InspectorControls key="controls">
<PanelColorSettings
title={ __( 'Color Settings', 'amp' ) }
title={ __( 'Overlay Settings', 'amp' ) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
title={ __( 'Overlay Settings', 'amp' ) }
title={ __( 'Background Color', 'amp' ) }

If one just wants to use a solid background color without any gradient, I think this wording makes more sense.

Thanks to the opacity control further down, one will quickly discover that this can be used as an overlay for the background image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I was thinking that Overlay is a word that is valid for both cases since Overlay doesn't necessarily have to be an overlay for an image -- it can be overlay for the Page block without the image, too. Also, technically it'll be a new Fill layer (aka overlay) and not use the background color.

Since the user will not necessarily open the Panel to see what's inside then maybe Background Color could be deceiving, it would be great if the title would be self-explanatory without having to know what's inside. Maybe there's another option instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Background Settings maybe? Then it could be combined with the background media panel.

Technically it's a fill layer, but for the user it's basically a background color setting with some optional opacity.

For me, "background" is easier to grasp than "overlay", and also easier to localize.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Background Settings makes sense 👍

Copy link
Member

Choose a reason for hiding this comment

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

Since from the user perspective the net effect of this setting is providing a background color/fill, I would consider Background Color over `Settings. We want to make the language and UI as straightforward and intuitive as possible.

@swissspidy
Copy link
Collaborator

What if we want to support three or more colors in the future?

For that, I like Weston's suggestion of making this a repeatable field.

By default you'll only see the one background color option with the opacity control.

Below the color option could be an "Add Color" button to add a second color. In the future we'd allow adding a third, fourth, etc. color as well.

To make this flexible and future-proof enough, there could only be a single background attribute that is a JSON-encoded object that looks more like this:

{
  "background": {
    "opacity": 0.5,
    "colors": [
      {
        "color": "#ffffff"
      },
      {
        "color": "#000000"
      }
    ]
  }
}

For a regular solid background:

{
  "background": {
    "opacity": 1,
    "colors": [
      {
        "color": "#ababab"
      }
    ]
  }
}

Eventually, we'd need to look at adding a gradient picker à la http://www.colorzilla.com/gradient-editor/, for which we'd just need to extend it like this:

{
  "background": {
    "opacity": 0.5,
    "direction": 57,
    "colors": [
      {
        "color": "#ffffff",
        "step": 0
      },
      {
        "color": "#777777",
        "step": 0.5
      },
      {
        "color": "#000000",
        "step": 1
      }
    ]
  }
}

This way we don't have rename block attributes in the future and things like that.

Hope that makes sense.

Also, FWIW, there are a few React gradient picker components out there from which we could draw inspiration from.

@miina
Copy link
Contributor Author

miina commented Apr 2, 2019

This way we don't have rename block attributes in the future and things like that.

Yep, it makes sense, thought that adding a repeating field just for two colors would be too much. However, it's true that we might need it in the future and reworking this wouldn't be the best option later.

Will add the repeating field for the two colors for now, probably we can add other improvements later (considering the timeframe).

@swissspidy
Copy link
Collaborator

Yep, it makes sense, thought that adding a repeating field just for two colors would be too much.

For two colors in the beginning we could label the button "Add Gradient"

@miina
Copy link
Contributor Author

miina commented Apr 2, 2019

We'll also need to add remove button as well then.

Copy link
Collaborator

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

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

I fixed some issues around edge cases, e.g. clicking on "Add Gradient" crashed the block when the first color hasn't been set yet. Now it seems to work fine.

@swissspidy
Copy link
Collaborator

Test_AMP_Validation_Manager::test_add_block_source_comments seems to be failing on Travis with the latest_posts data set. Opened an issue for that as it's unrelated to this PR: #2053

@swissspidy swissspidy merged commit bc6339a into amp-stories-redux Apr 3, 2019
@swissspidy swissspidy deleted the amp-story/2013-page_gradient branch April 3, 2019 11:18
@westonruter westonruter added this to the v1.2 milestone May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Signed the Google CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants