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

feat: enable transparent or custom background for content #2429

Merged
merged 3 commits into from
Nov 16, 2023

Conversation

ianjon3s
Copy link
Contributor

@ianjon3s ianjon3s commented Nov 15, 2023

What does this PR do?

The current version of the Content component has the option for a custom background colour but by default is published with a white (transparent) background.

Horizontal and vertical padding is added to the content container by default to compensate for a background colour, meaning that the default behaviour is to push the content out of alignment with the parent container.

The PR introduces options for transparent and custom containers.

https://2429.planx.pizza/testing/content-colour-test/preview

Preview

Before (above) & after (below):

image

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

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

One small question which you might already have looked into on this one. Also happy to be another pair of eyes here if required!

I suspect that we can check if a color is set (or if it's set back to white) to get the same data point.

Either way - this is a great one to have picked up and fixed thank you 👏

@@ -1,6 +1,7 @@
import { MoreInformation, parseMoreInformation } from "../shared";

export interface Content extends MoreInformation {
customBackground: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way we could derive this information from the props already passed in as opposed to adding a new prop?

Is customBackground always the same as color !== "#FFF" or whatever the default that's set is?

Copy link
Member

Choose a reason for hiding this comment

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

Need the pizza to build to confirm this - but I think if we introduce a new required prop like this, all existing Content components will break / need to be updated which is less an than ideal! Another reason to: try to derive from existing props, or at minimum introduce this as an optional prop!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout and I appreciate the logic introduced here may not be optimal (and I hadn't considered the implications of a new prop breaking existing components).

I'll try to rework so that the padding is introduced only if the background colour is changed from the default to see if that would be a simpler solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DafyddLlyr @jessicamcinchak I've now updated this to be much simpler, doing as Daf suggested and checking whether or not the background is white rather than introducing a new option.

I am however struggling to get it working as expected, if no background colour is selected the prop is passed through empty, however trying to target this with undefined is not working.

I've also tried adding #ffffff (equivalent white output by the colour picker) as a default prop and this is still not working.

Note: I've also disabled the alpha/transparency slider in the colour picker as this appears to be non-functional, at least in Chrome and Safari.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the update - I'll take a look @ianjon3s - checking for a negative is always hard!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's a pizza with three content components:

  1. Content with default background (no background colour selected)
  2. Content with white background selected
  3. Content with other custom background colour selected

https://2429.planx.pizza/testing/content-colour-test/preview

Copy link
Contributor

Choose a reason for hiding this comment

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

Pizza looks great - thanks for the link ✅

Copy link

github-actions bot commented Nov 16, 2023

Removed vultr server and associated DNS entries

@ianjon3s ianjon3s merged commit 8ce1579 into main Nov 16, 2023
12 checks passed
@ianjon3s ianjon3s deleted the ian/content-background-padding branch November 16, 2023 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants