Closed evtyz closed 3 years ago
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/loo-labs/waterpark/6zN74hdzFgyVCUQhcjJELf7Xv5U5
✅ Preview: https://waterpark-git-171-cleanup-media-queries-loo-labs.vercel.app
Purpose
Closes #171.
Approach
Previously, many files had their own const strings for
mobile
,tablet
, andlaptop
. They also had their ownsmallerThan()
andlargerThan()
functions.Also, the main file that was supposed to regulate breakpoints,
styles/device.ts
, was not organized well. It exported adevice
object that was supposed to give templates for different breakpoints, but did not cover all possible use cases and was extremely inconsistent. E.g.laptop
would bemax-width
anddesktop
would bemin-width
for whatever reason. Apparently people got sick of this and just started using their own breakpoints, which is detrimental to code quality.The solution I chose was to export the original
width
object instyles/device.ts
that had the original const strings for all device sizes. Then, I also madesmallerThan()
andlargerThan()
functions that were exported too. This covers all possible use-cases for breakpoints (bothmin-width
andmax-width
for eight different breakpoints inwidth
.)Then I refactored all references to media queries in the client to refer to this file.
Testing
Visual inspection shows that the website functions just like before.
Miscellaneous
You may notice that there are still some media queries (namely in
navbar
) that are not properly implemented yet. This will be handled in the navbar PR (https://github.com/loolabs/waterpark/pull/173) in the near future.