-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(styles): add display property for custom HTML elements #12050
Conversation
DCO Assistant Lite bot All contributors have signed the DCO. |
I have read the DCO document and I hereby sign the DCO. |
✅ Deploy Preview for carbon-components-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for carbon-elements ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
It would be good to run VRT against multiple browsers locally for this one. I anticipate that adding |
@Akshat55 It appears Angular has addressed this via the
It seems like that might be a more appropriate solution rather than duplicating the default |
@tay1orjones We are already using the approach listed, but this is applying Another issue with inline styles is that if the users want to make changes to the style by applying a class to the element, then they will have to use We hope to achieve something similar to what Angular Material has done, where the display properties are defined in the styles. Now we can override the classes on our end, but since we are already applying the wrapper classes from carbon, it makes sense to apply this change directly to the styles package. Also, I don't think this is duplicating the display property since that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, thanks @Akshat55!
Thanks @tay1orjones! We've discovered a few more, should I include them as well in this PR or should I create another PR? Specifically for setting display properties for UI-shell side navigation items ( |
@Akshat55 A separate PR would be great! |
bump for review @abbeyhrt |
Closes #11579
Specify
display
CSS property for specific wrapper classes.In Angular, we have custom tags
<ibm-table></ibm-table>
unlike React, which uses traditional HTML tags (div
,span
, etc).This results in browsers not knowing what the display style property of the tag should be (block, inline, etc). Where applicable, we have assigned a carbon class to the host e.g.
<ibm-table class="bx--data-table-content"></ibm-table>
. But there are cases where those classes have not specified the display property, table is one of them. (Not assigningdisplay: block
breaks horizontal scrolling)This change will allow custom HTML elements such as
<ibm-table class="bx--data-table-content"></ibm-table>
(in Angular) to instruct the browser to use specific display property instead ofinline
by default. It will also allow us (carbon-components-angular team) to not specify styles within the component template.Changelog
New
display
property for wrapper classes of accordion item, table, & context menu components.Testing / Reviewing
styles.scss
(packages/react/.storybook/styles.scss
)I have reviewed React package code & verified via storybook to ensure these changes do not impact the package.
You can also verify if the display properties make sense to the element they are applied to, for example,
.cds--accordion__item
class is applied to list (<li></li>
) which the browser assigns the default display property oflist-item
.Another example would be,
.cds--data-table-content
. This class is applied to a<div>
, which browsers assignblock
as the display value.Hence, these changes should not impact React package but will greatly benefit custom HTML elements (like the one's used in carbon-components-angular).