-
Notifications
You must be signed in to change notification settings - Fork 25
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
Helix styles are dependent on spacing #283
Comments
JSX BehaviorThe described behavior seems to be a result of how JSX compiles to HTML.
@mcortez1497 are you aware of any configuration options in React/JSX to modify this behavior? Tricky ProblemThe problem we have here is that we have to figure out how to support two different DOMs in CSS for the same palpable content. natural (preserve significant whitespace, only remove newlines) <p>
Text Node
<span>inline content</span>
</p> compiled (all "unnecessary" whitespace removed) <p>Text Node<span>inline content</span></p> For the situation above, we have an inline element after text content. In order to consistently apply a margin between the text node and the In cases where the inline element appears before the text content, we'd need to be able to target an inline element that precedes a white-space-only text node. This is impossible to do in CSS, because selectors can only match forward (never backward). |
I can think of two ways to potentially solve this.
|
There may be instances where we can fix this with CSS in |
Discoveries
What can be fixed
What cannot be fixedButton spacing cannot be fixed with CSS alone, because we cannot guarantee that two sibling buttons are arranged side-by-side, horizontally. This will require adding explicit white-space-only text nodes ( |
I've been looking at different loader options with Webpack, trying to see if there are any configuration options that allow for whitespace not to be trimmed in JSX, but there doesn't seem to be any. Looking at some related issues (facebook/react#4134), it seems like explicitly adding text nodes would likely be the best course of action in |
@mcortez1497: agreed. Though we'll still want to document compatibility quirks, just in case. I'm not sure if we can guarantee 100% coverage with Regardless, I'll be creating a defect story in JIRA to capture updating CSS in order to alleviate this issue as best we can via (thinking out loud) I wonder if by always adding an explicit white-space-only text node to the end of every JSX template would be a good or bad idea. (probably depends on the component) return (
<button className="hxBtn">
{this.props.children}
</button>
{' '}
) |
Created SURF-1219 to capture work that can be completed in |
Closing this story. We can continue discussions here, but necessary work should be documented in SURF-1219. |
Describe the Bug
Certain Helix styles have margin definitions that are dependent on spaces being present. This is mostly apparent when using React, since React strips out unneeded spaces.
Steps to Reproduce
Without React
(per Nicko Winner-Arroyo)
<hx-alert cta="burn it" status="spider">Nope! Nope! Nope! Nope! Nope!</hx-alert>
hx-alert
element with proper spacing betweenSPIDER: Nope! ...
With React
I've created a Codepen snippet that highlights a few of the inconsistencies I've found so far. They include:
status
and text value.hx-icon
s within buttons.Expected behavior
The stylings should be the same whether or not whitespace is being used.
Screenshots
Whitespace nodes are easily apparent in Firefox. Each of the spacing issues seem to have a width of 4px.
Whitespace nodes were not visible in the inspector when viewing the spacing for
hx-alert
's orhx-icon
s, though there is a 4px spacing that's visible.Environment
Please complete the following information:
Additional Context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: