Skip to content

Conversation

@rogermparent
Copy link
Contributor

@rogermparent rogermparent commented Jul 11, 2022

#2005 <- this

fixes #1826

This PR makes the shadow on the sticky table header only appear when the table is scrolled a bit (set as 15px, but can be changed to anything if we want via rootMargin).

conditional-header-shadow-demo.mp4

Opted to rely on Chromatic for testing, as the result is purely visual. To do this, I added a new "Scrolled" story to the table stories that uses a custom viewport and scrolls to the bottom-right in its play function.

})
global.MutationObserver = mutationObserverMock

const intersectionObserverMock = jest.fn().mockImplementation(() => {

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

@rogermparent rogermparent changed the base branch from main to storybook-testing-library July 12, 2022 01:55
Comment on lines +18 to +25
const intersectionObserverMock = jest.fn().mockImplementation(() => {
return {
disconnect: jest.fn(),
observe: jest.fn(),
unobserve: jest.fn()
}
})
global.IntersectionObserver = intersectionObserverMock
Copy link
Contributor Author

@rogermparent rogermparent Jul 12, 2022

Choose a reason for hiding this comment

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

Does the job of keeping things from breaking and not much more. Could be made better if we wanted to actually puppet the observer, but I think we have better ways to test most scenarios it would apply to.

Base automatically changed from storybook-testing-library to main July 12, 2022 11:59
@rogermparent rogermparent self-assigned this Jul 12, 2022
@rogermparent rogermparent marked this pull request as ready for review July 12, 2022 15:00
@rogermparent rogermparent added the product PR that affects product label Jul 12, 2022
type: MessageFromWebviewType.REORDER_COLUMNS
})
}
const [ref, scrolled] = useInView({
Copy link
Contributor

@mattseddon mattseddon Jul 13, 2022

Choose a reason for hiding this comment

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

[C] Would be good to have an indicator here to know this is for the sticky header shadow. [ref, headerNeedsShadow]? Just something for the next person that comes along. that doesn't involve them following it through into the scss file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My first thought was scrolled because that's describing what the variable contains regardless of how we use it, but I can see how that would be helpful where it's only used in one place now.

@rogermparent rogermparent requested a review from julieg18 as a code owner July 13, 2022 16:46
@rogermparent rogermparent enabled auto-merge (squash) July 14, 2022 01:56
@rogermparent rogermparent disabled auto-merge July 14, 2022 01:57
@rogermparent rogermparent enabled auto-merge (squash) July 14, 2022 01:57
@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit 327e456 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

The test coverage on the diff in this pull request is 100.0% (85% is the threshold).

This pull request will bring the total coverage in the repository to 96.6% (0.0% change).

View more on Code Climate.

@rogermparent rogermparent merged commit 4f86658 into main Jul 14, 2022
@rogermparent rogermparent deleted the conditional-table-shadows branch July 14, 2022 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product PR that affects product

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add shadow to sticky header and footer

2 participants