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

Table Updates: Styles #4671

Merged
merged 14 commits into from
May 27, 2024
Merged

Table Updates: Styles #4671

merged 14 commits into from
May 27, 2024

Conversation

margaree
Copy link
Contributor

@margaree margaree commented May 10, 2024

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:

  • Update the look and feel of the 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)
  • All cells should have 0.7rem of padding

Copy link
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-4671/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

Copy link
Contributor Author

@margaree margaree left a 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

Comment on lines 31 to 34
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));
}
Copy link
Contributor Author

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

Comment on lines 42 to 67
.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);
}
}
Copy link
Contributor Author

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.

--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;
Copy link
Contributor Author

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-buttons on siblings (default is 4px)

Comment on lines -260 to -262
--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;
Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

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);
Copy link
Contributor Author

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.

Copy link
Member

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);
Copy link
Contributor Author

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;
Copy link
Contributor Author

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

@margaree margaree marked this pull request as ready for review May 13, 2024 18:54
@margaree margaree requested a review from a team as a code owner May 13, 2024 18:54
Copy link
Member

@dlockhart dlockhart left a 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!

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);
Copy link
Member

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.

margaree and others added 4 commits May 14, 2024 15:47
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
@margaree margaree merged commit 7137456 into main May 27, 2024
6 checks passed
@margaree margaree deleted the table-updates-styles4 branch May 27, 2024 18:23
Copy link

🎉 This PR is included in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants