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

Add style fields to theme modules #358

Merged
merged 17 commits into from
Jul 22, 2021
Merged

Conversation

jasonnrosa
Copy link
Member

@jasonnrosa jasonnrosa commented Jul 14, 2021

Types of change

  • Bug fix (change which fixes an issue)
  • Enhancement (change which improves upon an existing feature)
  • New feature (change which adds new functionality)

Description

This pull request implements the new style fields feature on the boilerplate's modules. The style fields feature allows developers to add style related fields in the "style" tab of a module.

styles

Best practices
Changelog
Sign up to participate in the style fields beta

Notes

We're currently omitting adding style fields to the menu as we are aiming to do a larger rebuild in the near future that will include some accessibility improvements.

Checklist

People to notify
CC: @TheWebTech

@jasonnrosa jasonnrosa added the enhancement Improves upon an existing feature label Jul 14, 2021
@jasonnrosa jasonnrosa marked this pull request as draft July 14, 2021 19:55

.card {
{% if module.styles.card.background.background_type == "color" && module.styles.card.background.color.color %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we support .css on color field?
I may be remembering wrong. Your code though would still function just fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not that I'm aware of. I've generally been following this doc for where the .css property is supported and I tried following the original PR. We do have the .css for gradient. I'm happy to update if .css is available for the color field. That would be nice to keep the code a bit shorter.

Copy link
Contributor

@TheWebTech TheWebTech left a comment

Choose a reason for hiding this comment

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

I read through all of the code, it all looked good and made sense. I didn't see any issues.

I have not tested the changes in my own account. Given the amount of CSS and HTML changes to support the new fields. I think it's worth myself or someone else testing the branch in their account first. I will try to spend some time to test this tomorrow.

@jasonnrosa
Copy link
Member Author

Thanks for checking this out Jon! Here is an example page if you wanted a quick reference to the editor. Please excuse my beautiful choice of test styles 😆

Copy link
Contributor

@TheWebTech TheWebTech left a comment

Choose a reason for hiding this comment

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

Tested in Chrome, Firefox, and Safari. Looked good.

Did notice an issue completely unrelated to the stylefields change.

The menu module when used outside of the header - because it's closer to the left side of the page, the dropdown gets cut off.

This is unlikely to happen in real sites often, but an easy solution is to add a :first-child selector and transform:unset;

You will need to also move the :before so that it lines up better with the first <li>

@jasonnrosa jasonnrosa marked this pull request as ready for review July 22, 2021 18:31
@jasonnrosa jasonnrosa merged commit 4228c0c into main Jul 22, 2021
@JacobLett
Copy link

Is there a way to set a style when adding a module to a template? How would you modify this to make the text color white? {% dnd_module path='@hubspot/header', header_tag='h1', value='title', horizontal_alignment="CENTER" %}{% end_dnd_module %}

@TheWebTech
Copy link
Contributor

Hi @JacobLett, this update adds style fields to the modules in the boilerplate.

You set style field values at the template level very similarly to content fields, more on this can be found at:
https://developers.hubspot.com/en/docs/cms/building-blocks/modules/using-modules-in-templates#setting-template-level-default-values-for-style-fields

Right now default modules do not yet use style fields. So you would need to use CSS or a custom module instead and add a style field.

When modules use style fields you'll notice a field group in the fields.json or in the Design Manager fields listed as "Styles".

@JacobLett
Copy link

Right now default modules do not yet use style fields. So you would need to use CSS or a custom module instead and add a style field.
Hi @TheWebTech thank you for explaining this because I was thinking the default modules already had this and I was missing something.

@jasonnrosa jasonnrosa deleted the module-style-fields-additional branch July 23, 2021 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves upon an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants