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

fix: refine arrowStyles CSS to avoid overcast issues with drop shadows #1814

Merged
merged 3 commits into from
May 30, 2024

Conversation

ze-flo
Copy link
Contributor

@ze-flo ze-flo commented May 23, 2024

Description

Improves arrowStyles to avoid overcast issues on arrow border when drop shadows are applied to the arrow container.

Using an extreme case to highlight the impact of drop shadows on the arrow border
Screenshot 2024-05-23 at 10 01 03β€―AM

Detail

  • Two boxes clipped into a triangular shape lay over each other
    • ::before (in pink) inherits the border styles from container. The clipping mask is set so that the border smoothly merges with the container's (using inset == 0). The overlap is meant to prevent a gap due to pixel rounding.
    • ::after (in green) has a transparent border and a clipping mask that slightly extends upward to conceal the container's border without hiding its content.

Screenshot 2024-05-22 at 3 12 11β€―PM

Checklist

Screenshot 2024-05-23 at 7 12 32β€―AM
Screenshot 2024-05-23 at 7 12 21β€―AM
Screenshot 2024-05-23 at 7 11 36β€―AM
Screenshot 2024-05-23 at 7 11 18β€―AM
Screenshot 2024-05-23 at 7 08 35β€―AM
Screenshot 2024-05-23 at 7 08 06β€―AM

reviewer)

  • 🌐 demo is up-to-date (npm start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • 🀘 renders as expected with Bedrock CSS (?bedrock)
  • πŸ’‚β€β™‚οΈ includes new unit tests. Maintain existing coverage (always >= 96%)
  • β™Ώ tested for WCAG 2.1 AA accessibility compliance
  • πŸ“ tested in Chrome, Firefox, Safari, and Edge

@coveralls
Copy link

coveralls commented May 23, 2024

Coverage Status

coverage: 96.074% (-0.001%) from 96.075%
when pulling 9358f94 on ze-flo/arrow-tweaks
into 2649a2a on next.

@ze-flo ze-flo changed the title fix(arrowStyles): refine css to avoid issues with drop-shadows fix: refine arrowStyle css to avoid issues with drop-shadows May 23, 2024
@ze-flo ze-flo changed the title fix: refine arrowStyle css to avoid issues with drop-shadows fix: refine arrowStyle css to avoid issues with drop shadows May 23, 2024
@ze-flo ze-flo changed the title fix: refine arrowStyle css to avoid issues with drop shadows fix: refine arrowStyle CSS to avoid overcast issues with drop shadows May 23, 2024
@@ -34,7 +34,7 @@ export const StyledMenu = styled(StyledListbox).attrs({
props.arrowPosition &&
arrowStyles(props.arrowPosition, {
size: `${props.theme.space.base * 2}px`,
inset: '2px',
inset: '1.5px', // More consistent cross-browser positioning with 1.5px
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Safari handles positioning differently than other browsers. 😠

@ze-flo ze-flo marked this pull request as ready for review May 23, 2024 20:14
@ze-flo ze-flo requested a review from a team as a code owner May 23, 2024 20:14
@jzempel jzempel changed the title fix: refine arrowStyle CSS to avoid overcast issues with drop shadows fix: refine arrowStyles CSS to avoid overcast issues with drop shadows May 30, 2024
Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

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

This is feeling really good. Can we pick up the story updates from #1812 to get a more precise match with real component usage.

packages/theming/src/utils/arrowStyles.ts Show resolved Hide resolved
Comment on lines 78 to 79
* 1. Arrow positioning on the base element.
* 2. Rotate the clipping mask depending on arrow position.
Copy link
Member

Choose a reason for hiding this comment

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

[nit] please re-order so the comments read top-to-bottom with the CSS below

const inset = options.inset || '0';
const squareSize = math(`${size} * 2 / sqrt(2)`, exponentialSymbols);
const size = options.size === undefined ? 6 : (stripUnit(options.size) as number);
const squareSize = `${Math.round((size * 2) / Math.sqrt(2))}px`;
Copy link
Member

Choose a reason for hiding this comment

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

I'm glad this works. I was having problems and needed Math.floor.

Comment on lines 133 to 136
* 4. Clip the inner square forming the arrow body into a triangle so that it
* doesn't interfere with container content.
* 5. Clip the outer square forming the arrow border into a triangle so that the
* border merge with the container's.
Copy link
Member

Choose a reason for hiding this comment

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

[nit] ditto re: top-to-bottom order

@jzempel jzempel mentioned this pull request May 30, 2024
7 tasks
@ze-flo ze-flo merged commit bb96a5c into next May 30, 2024
5 checks passed
@ze-flo ze-flo deleted the ze-flo/arrow-tweaks branch May 30, 2024 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants