-
Notifications
You must be signed in to change notification settings - Fork 22
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
Table Updates: Styles #4671
Table Updates: Styles #4671
Conversation
Thanks for the PR! 🎉 We've deployed an automatic preview for this PR - you can see your changes here:
Note The build needs to finish before your changes are deployed. |
…event movement when button goes from nosort to sort
… into table-updates-styles4
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.
Nicole is interested in having it so that if there are multiple things in the cell (e.g., multiple table-col-sort-button, table-col-sort-button + button-icon) that when they wrap, if one is focused and the other is hovered then those two styles just touch in order to reduce height. I have found trying to do this to be difficult (perhaps I'm missing something totally obvious) so let me know if you have suggestions on that. Figured this out
components/table/table-wrapper.js
Outdated
d2l-button-icon { | ||
--d2l-button-icon-min-height: calc(var(--d2l-table-cell-overall-height) - 2 * var(--d2l-table-cell-col-sort-button-size-offset)); | ||
--d2l-button-icon-min-width: calc(var(--d2l-table-cell-overall-height) - 2 * var(--d2l-table-cell-col-sort-button-size-offset)); | ||
} |
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.
We want button-icons to be the same size as the d2l-table-col-sort-button
.
Considerations:
d2l-dropdown-context-menu
would not be targeted by this- This does go against letting consumers control their own styles for the content of the table cells
components/table/table-wrapper.js
Outdated
.d2l-checkbox, | ||
d2l-input-checkbox, | ||
d2l-selection-select-all, | ||
d2l-selection-input { | ||
margin-block: calc(0.5 * (var(--d2l-table-cell-height) - ${cssSizes.inputBoxSize}rem)); | ||
} | ||
.d2l-table > * > tr.d2l-table-selected-first d2l-input-checkbox, | ||
.d2l-table > * > tr.d2l-table-selected-first d2l-selection-input, | ||
.d2l-table > * > tr.d2l-table-selected-first .d2l-checkbox { | ||
margin-bottom: calc(0.5 * (var(--d2l-table-cell-height) - ${cssSizes.inputBoxSize}rem)); | ||
margin-top: calc(0.5 * (var(--d2l-table-cell-height) - ${cssSizes.inputBoxSize}rem) - 1px); | ||
} | ||
@supports selector(:has(a, b)) { | ||
.d2l-table > * > tr > :has(.d2l-checkbox), | ||
.d2l-table > * > tr > :has(d2l-selection-select-all), | ||
.d2l-table > * > tr > :has(d2l-input-checkbox), | ||
.d2l-table > * > tr > :has(d2l-selection-input) { | ||
padding-block: calc(0.5 * (var(--d2l-table-cell-overall-height) - ${cssSizes.inputBoxSize}rem)); | ||
} | ||
.d2l-table > * > tr.d2l-table-selected-first > :has(.d2l-checkbox), | ||
.d2l-table > * > tr.d2l-table-selected-first > :has(d2l-input-checkbox), | ||
.d2l-table > * > tr.d2l-table-selected-first > :has(d2l-selection-input) { | ||
padding-bottom: calc(0.5 * (var(--d2l-table-cell-overall-height) - ${cssSizes.inputBoxSize}rem)); | ||
padding-top: calc(0.5 * (var(--d2l-table-cell-overall-height) - ${cssSizes.inputBoxSize}rem) - 1px); | ||
} | ||
} |
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.
The checkbox inputs add extra height that we don't want so we shrink the padding accordingly.
components/table/table-wrapper.js
Outdated
--d2l-table-col-sort-button-additional-padding-inline-end: 0px; /* stylelint-disable-line length-zero-no-unit */ | ||
} | ||
d2l-table-col-sort-button:not(:only-child):first-child { | ||
--d2l-table-col-sort-button-margin-inline-end: 1px; |
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.
Minimize space between d2l-table-col-sort-button
s on siblings (default is 4px)
--d2l-table-cell-height: 1.15rem; /* min-height to be 48px including border */ | ||
--d2l-table-cell-padding: 0.6rem; | ||
--d2l-table-cell-padding-alt: calc(0.6rem - 1px) 0.6rem 0.6rem 0.6rem; |
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.
Light type padding and height is now to be consistent with default
--d2l-table-col-sort-button-width: calc(100% - 2 * var(--d2l-table-cell-col-sort-button-size-offset)); | ||
} | ||
:host([nosort]) { | ||
--d2l-table-col-sort-button-additional-padding-inline-end: calc(0.6rem + 18px); |
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.
This is to account for extra space for the icon + icon's margin when the button is in nosort
state. It's a cssvar in order to be able to set it for different cases when there are siblings.
components/table/table-wrapper.js
Outdated
padding-inline-end: calc(0.6rem + 18px); | ||
} | ||
.d2l-table-header-col-sortable :not(d2l-table-col-sort-button) { | ||
margin: var(--d2l-table-cell-col-sort-button-size-offset); |
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.
This adds a margin to non-table-col-sort-buttons that are in a cell with one. In our demos it looks weird without this, however consumers can be setting their own spacing on their cell contents so I don't know that it's right for us to be dictating that. Let me know any thoughts. I'm open to removing it from here and moving it elsewhere for the demo.
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.
Yeah this seems a bit invasive to me, and likely best handled by consumer code wherever it comes up.
@@ -368,6 +437,7 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme | |||
r.classList.toggle('d2l-table-selected-first', firstNonHeaderRow && isSelected); | |||
|
|||
Array.from(r.cells).forEach((c, index) => { | |||
if (isHeader && !CSS.supports('selector(:has(a, b))')) this._checkSiblingSortableCells(c); |
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.
With :has
we are able to do everything without js, so that's why there is a separate :has
section in the css. This can be removed once we only support browsers with :has
--d2l-table-cell-height: calc(var(--d2l-table-cell-overall-height) - 2 * var(--d2l-table-cell-padding)); | ||
--d2l-table-cell-padding: 0.7rem; | ||
--d2l-table-cell-padding-alt: calc(0.7rem - 1px) 0.7rem 0.7rem 0.7rem; | ||
--d2l-table-cell-col-sort-button-size-offset: 4px; |
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.
This corresponds to the 4px of buffer we want on all sides of the table-col-sort-button
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.
Crazy how complex all the positioning ended up being, nice job!
components/table/table-wrapper.js
Outdated
padding-inline-end: calc(0.6rem + 18px); | ||
} | ||
.d2l-table-header-col-sortable :not(d2l-table-col-sort-button) { | ||
margin: var(--d2l-table-cell-col-sort-button-size-offset); |
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.
Yeah this seems a bit invasive to me, and likely best handled by consumer code wherever it comes up.
… one and move into demo
…ther items, tweak demo table
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ck for --d2l-table-cell-col-sort-button-size-offset css var
🎉 This PR is included in version 3.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Due to the potential downstream impact of table style changes, I wanted to get hopefully all of them in one PR, so it is a bit large.
This PR covers the following stories:
In summary, we want to do the following:
d2l-table-col-sort-button
to take up the whole cell if it can (nothing else in the cell) and have fallback styles if not (10px padding on each side in the shared cell case)