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

Clean up table head styles #3674

Merged
merged 3 commits into from
Apr 19, 2023

Conversation

julieg18
Copy link
Contributor

@julieg18 julieg18 commented Apr 12, 2023

2/4 main <= #3667 <= this <= #3681 <= #3707

  • move all selectors to one place
  • delete unused code
  • remove unneeded nesting

Part of #3597

* move all selectors to one place
* delete unused code
* remove unneeded nesting
@julieg18 julieg18 self-assigned this Apr 12, 2023
@julieg18 julieg18 mentioned this pull request Apr 12, 2023
)

expect(
headerCell.classList.contains(styles.sortingHeaderCellDesc)
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 sortingHeaderCellDesc and sortingHeaderCellDesc styles aren't actually being used outside of tests. I deleted the classes and corresponding tests, but if this was intentional for testing purposes, I can add them back :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the behaviour under test elsewhere (maybe that an arrow/indicator is shown)? If not then should add another test with maybe a data-testid. No reason to keep the class around just for this.

@@ -9,7 +9,7 @@ interface HeaderProps {
export const Header: React.FC<HeaderProps> = ({ name }) => {
return (
<OverflowHoverTooltip content={name}>
<div className={styles.headerCellWrapper}>
<div className={styles.headerCellText}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's just me, but headerCellWrapper gives me the impression that the class wraps the cell when in reality, it's inside the cell, wrapping the text. Renamed it to headerCellText.

[styles.sortingHeaderCellAsc]: sortOrder === SortOrder.ASCENDING,
[styles.sortingHeaderCellDesc]:
sortOrder === SortOrder.DESCENDING && !header.isPlaceholder,
[styles.oneRowHeaderCell]: onlyOneLine
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

menuEnabled, sortingHeaderCellAsc, and sortingHeaderCellDesc weren't used in the styles file so I deleted the classes.

@@ -104,7 +104,7 @@ export const TableHeaderCellContents: React.FC<{
setMenuSuppressed,
resizerHeight
}) => {
const isTimestamp = header.headerGroup.id === ColumnType.TIMESTAMP
const isTimestamp = header.id === 'Created'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funnily enough, there were two attempts in the code to move the timestamps icon menu to the right:

  • uses isTimestamp and a styles.moveToRight class
  • relies on createdHeaderCell class to move the icon menu to the right

The first way wasn't technically working so the second way was the one being applied to the actual cell. I decided to go the first way so I fixed the isTimestamp check and deleted the createdHeaderCell class.

height: auto;
background-color: $header-bg-color;

.dropTarget {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.dropTarget also not actually being used anywhere.

[styles.firstLevelHeaderCell]: isFirstLevelHeader(header.column.id),
[styles.leafHeaderCell]: header.subHeaders === undefined,
[styles.oneRowHeaderCell]: onlyOneLine,
[styles.dropTargetHeaderCell]: headerDropTargetId === header.id
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all of these object classes accomplish the same thing (applying extra styles to headerCell/placeHolderCell), I renamed them to all have the HeaderCell at the end, basing that off the first five.

@julieg18 julieg18 marked this pull request as ready for review April 12, 2023 17:16
Copy link
Member

@mattseddon mattseddon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q] Did you have a look at linters yet?

@julieg18 julieg18 merged commit 0c1568e into group-general-table-styles Apr 19, 2023
@julieg18 julieg18 deleted the group-table-head-styles branch April 19, 2023 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants