Skip to content

Commit

Permalink
fix(project): update breakpoints to meet designs
Browse files Browse the repository at this point in the history
  • Loading branch information
royschut committed Aug 2, 2021
1 parent 6c65bee commit 880a1aa
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/components/Shelf/Shelf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import styles from './Shelf.module.scss';

export const tileBreakpoints: Breakpoints = {
[Breakpoint.xs]: 1,
[Breakpoint.sm]: 3,
[Breakpoint.md]: 4,
[Breakpoint.lg]: 5,
[Breakpoint.xl]: 6,
[Breakpoint.sm]: 2,
[Breakpoint.md]: 3,
[Breakpoint.lg]: 4,
[Breakpoint.xl]: 5,
};

export const featuredTileBreakpoints: Breakpoints = {
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/useBreakpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { useState, useEffect } from 'react';

import { addMediaQueryListChangeListener, removeMediaQueryListChangeListener } from '../utils/matchMedia';

const XS_MATCH_MEDIA: MediaQueryList = matchMedia('screen and (max-width: 599px)');
const SM_MATCH_MEDIA: MediaQueryList = matchMedia('screen and (min-width: 600px) and (max-width: 959px)');
const MD_MATCH_MEDIA: MediaQueryList = matchMedia('screen and (min-width: 960px) and (max-width: 1279px)');
const LG_MATCH_MEDIA: MediaQueryList = matchMedia('screen and (min-width: 1280px) and (max-width: 1919px)');
const XS_MATCH_MEDIA: MediaQueryList = matchMedia('screen and (max-width: 479px)'); // mobile
const SM_MATCH_MEDIA: MediaQueryList = matchMedia('screen and (min-width: 480px) and (max-width: 767px)'); // tablet
const MD_MATCH_MEDIA: MediaQueryList = matchMedia('screen and (min-width: 768px) and (max-width: 1023px)'); // tablet large
const LG_MATCH_MEDIA: MediaQueryList = matchMedia('screen and (min-width: 1024px) and (max-width: 1199px)'); // desktop

export enum Breakpoint {
xs,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Home/Home.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
padding: 0 variables.$base-spacing * 2;

&.featured {
padding: 24px variables.$base-spacing * 2;
padding: 24px 10%;
}
}
}
5 changes: 3 additions & 2 deletions src/screens/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ const Home = (): JSX.Element => {

const calculateHeight = (index: number): number => {
const item = content[index];
const isDesktop = breakpoint > Breakpoint.sm;
const isDesktop = breakpoint >= Breakpoint.lg;
const isMobile = breakpoint === Breakpoint.xs;
const isTablet = !isDesktop && !isMobile;

if (!item) return 0;
if (item.playlistId === PersonalShelf.ContinueWatching && !watchHistory.playlist.length) return 0;
Expand All @@ -105,7 +106,7 @@ const Home = (): JSX.Element => {
const calculateFeatured = () => {
const tilesToShow = featuredTileBreakpoints[breakpoint];
const shelfMetaHeight = 50;
const shelfHorizontalMargin = isDesktop ? document.body.offsetWidth * 0.4 : 0;
const shelfHorizontalMargin = isDesktop ? document.body.offsetWidth * 0.4 : isTablet ? document.body.offsetWidth * 0.2 : 0;
const cardWidth = (document.body.offsetWidth - shelfHorizontalMargin) / tilesToShow;
const cardHeight = cardWidth * (9 / 16);

Expand Down
6 changes: 4 additions & 2 deletions src/screens/Playlist/Playlist.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
@use '../../styles/mixins/responsive';

.playlist {

margin: 0 variables.$base-spacing * 4;
color: var(--primary-color);
font-family: var(--body-alt-font-family);
Expand All @@ -19,14 +18,17 @@
@include responsive.tablet-only() {
margin: 0 variables.$base-spacing * 2;
}

@include responsive.desktop-small-only() {
margin: 0 variables.$base-spacing * 3;
}
}

.main {
margin: -8px;
}

.header {

display: flex;
align-items: center;
height: 36px;
Expand Down
5 changes: 3 additions & 2 deletions src/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ $container-width-desktop: 800px !default;
// Responsive
// --------------------------------

$mobile-max-width: 595px !default;
$tablet-max-width: 959px !default;
$mobile-max-width: 479px !default;
$tablet-max-width: 1023px !default;

$tablet-min-width: $mobile-max-width + 1 !default;
$desktop-min-width: $tablet-max-width + 1 !default;
$desktop-large-min-width: 1200px !default;

//
// Header
Expand Down
6 changes: 6 additions & 0 deletions src/styles/mixins/_responsive.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
}
}

@mixin desktop-small-only {
@media screen and (min-width: variables.$desktop-min-width) and (max-width: variables.$desktop-large-min-width) {
@content;
}
}

@mixin desktop-only {
@media screen and (min-width: variables.$desktop-min-width) {
@content;
Expand Down

0 comments on commit 880a1aa

Please sign in to comment.