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

Make <Background /> component responsive #4767

Merged
merged 3 commits into from
Apr 12, 2024
Merged

Conversation

ady-beraud
Copy link
Contributor

  • Adjusted the height of the background image to fit every possible screen
  • Added the proper rotation degree to the background
  • Refactored gradient colour stop into CONST to make sure each background image starts at the same level

To be noted :
I had to use Javascript and useEffect to make the div take the entire height of the page (turn it into a "use client" component). This was necessary because absolute positioning by default makes the element's sizing relative to its nearest positioned ancestor, not the entire document.

@FelixMalfait
Copy link
Member

FelixMalfait commented Apr 3, 2024

Thanks for this first PR!

Going with a JS-first approach for CSS issues is usually a last-resort, it can be avoid in most cases and probably here too.

JS is harder to maintain and often leads to edge-cases as it does here:

Screenshot 2024-04-03 at 07 41 50 Screenshot 2024-04-03 at 07 41 58

Had you tried something with ::before and ::after selector?
Very basic example to give you an idea, not tested

.dotted-container {
  position: relative;
  background-repeat: repeat;
  background-image: url('image.png');
  min-height: xx vh;
}

.dotted-container::before, .dotted-container::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 300px;
  z-index: 1;
  pointer-events: none;
}

.dotted-container::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,1), rgba(255,255,255,0));
}

.dotted-container::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(255,255,255,1), rgba(255,255,255,0));
}

@ady-beraud
Copy link
Contributor Author

@FelixMalfait I partly implemented your suggestions, and it should be working much better now :)

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

Much better this way! Thanks!

@FelixMalfait FelixMalfait merged commit 990f9ae into main Apr 12, 2024
5 checks passed
@FelixMalfait FelixMalfait deleted the contributors-design branch April 12, 2024 08:16
arnavsaxena17 pushed a commit to arnavsaxena17/twenty that referenced this pull request Oct 6, 2024
- Adjusted the height of the background image to fit every possible
screen
- Added the proper rotation degree to the background
- Refactored gradient colour stop into CONST to make sure each
background image starts at the same level

**To be noted :** 
I had to use Javascript and useEffect to make the div take the entire
height of the page (turn it into a "use client" component). This was
necessary because absolute positioning by default makes the element's
sizing relative to its nearest positioned ancestor, not the entire
document.

---------

Co-authored-by: Ady Beraud <a.beraud96@gmail.com>
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.

4 participants