-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
'text-style'/'variant' prop in Maker Text / Maker Heading #269
Comments
Due to both of these, I think we should look at deprecating the heading component and adding However, I would like to suggest that the names of those variants be a bit different. Specifically I think we should define our two currently supported text and heading options based on the Theme UI Spec in typography with |
would this "variant" be independent of the "size" prop or not? would the only variants be: headline, title, body, label OR would they be: headline-1, headline-2, ..., label-1, label-2, etc. |
fair question. Yes, independent- e.g. Context: When we have a Text Variant Size e.g. Finally, it renders an MHeading component with This mapping process is just for text that's customisable in the Editor Options. For MText elements with static values, we don't have to think about mapping, we just add a variant and absolute size. |
@bashunaimiroy what should have precedence? should the variant override fontFamily and fontWeight, or should those override the variant? wait, nevermind, it should go in order of specificity, and since fontFamily and fontWeight are more specific those should always override the variant |
Solution released in v11 |
Feature request
What
A prop in the Maker Text / Maker Heading components, called
text-style
,variant
,text-type
, or any name that would be most clear (probably should avoid something conflated with a CSS property likefont-style
, let's discuss)Prop Values: The value would refer to one of the four Text Styles(Figma link) e.g. "headline", "title", "body", "label" that have a Font Weight and Font Family set via the Editor.
Behaviour: If we pass one of these values in the
text-style
prop, e.g.the MText component will internally resolve a Font Family and Font Weight for the passed value. In this case, Headline Font Family and Headline Font Weight.
These properties would be resolved within MText/MHeading using the MTheme object, similarly to how they're being resolved now (github link). e.g.
^ this is a draft, size and color will probably be resolved differently.
Why?
Background
The ECOM Website app is moving towards offering sellers four Text Styles to customise. eg:
The seller will customise these in the Global Font Settings panel (figma link) with a font family and font weight for each Text Style.
So far, we've only discussed how Text Styles apply to Section Elements that are customisable via the options, e.g. a Title Element in a Banner. In this case, the seller would assign that element a Text Style in the Editor Sidebar (figma link), e.g. "Headline" or "Title" as they see fit. This element then takes on the Family and Weight that was set in the Global Settings. Important note: These are usually rendered via the Makerized Text Component (Coda link) which wraps an MText/MHeading component.
Another application of Text Styles is to the non-custom text elements. There are many Text elements that are not customisable via options. For example, Cart Item Title text (Github link). Since we're converting these directly to MText/MHeading too (Coda Link), we could also assign a Text Style- for example Cart Item Titles might be Body or Title.
In both of these cases, we'll need some way to render the seller-set Family and Weight values for each Text Style in the MText/MHeading component. I'm suggesting this new prop.
Alternatives
@pretzelhammer has pointed out we could also achieve this same functionality by simply passing font-family and font-weight props, e.g.
We'd need to update the fontWeight prop validator to accept vars (github link) but this would achieve the same effect, since these CSS vars will also contain the values of the Headline Font Family/Weight, and MText components will probably be in the scope of these CSS vars.
The advantage of this new prop is:
line-height="var(--headline-line-height)
.<m-text text-style="headline" font-weight="900"> headline here </m-text>
creates a 900-weight headline element.${this.textStyle}-font-weight
etc. If we add this prop to MText/MHeading, we can simply bind it straight through in TextComponentWithMaker, and reuse the prop resolving logic within MText/MHeading (github link) to resolve the styles for the passedtextStyle
.Additional context
Maker Conversion release notes in Coda
The text was updated successfully, but these errors were encountered: