- update layout to work for responsive screen sizes

This commit is contained in:
Amruth Pillai
2020-07-19 20:33:11 +05:30
parent 6a8775e31b
commit 9930cee309
5 changed files with 22 additions and 41 deletions

View File

@ -1,4 +1,4 @@
import React, { memo } from 'react'; import React, { memo, useEffect, useState } from 'react';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useSelector } from '../../../contexts/ResumeContext'; import { useSelector } from '../../../contexts/ResumeContext';
@ -13,9 +13,14 @@ import styles from './Artboard.module.css';
const Artboard = () => { const Artboard = () => {
const state = useSelector(); const state = useSelector();
const { t } = useTranslation(); const { t } = useTranslation();
const [width, setWidth] = useState(0);
const { id, name, metadata } = state; const { id, name, metadata } = state;
const { template } = metadata; const { template } = metadata;
useEffect(() => {
setWidth(typeof window !== `undefined` && window && window.innerWidth);
}, [typeof window !== `undefined` && window && window.innerWidth]);
return ( return (
<> <>
<Helmet> <Helmet>
@ -25,7 +30,12 @@ const Artboard = () => {
<link rel="canonical" href={`https://rxresu.me/app/builder/${id}`} /> <link rel="canonical" href={`https://rxresu.me/app/builder/${id}`} />
</Helmet> </Helmet>
<div className={styles.container}> <div
className={styles.container}
style={{
transform: `scale(${width / 1680})`,
}}
>
{template === 'onyx' && <Onyx data={state} />} {template === 'onyx' && <Onyx data={state} />}
{template === 'pikachu' && <Pikachu data={state} />} {template === 'pikachu' && <Pikachu data={state} />}
{template === 'gengar' && <Gengar data={state} />} {template === 'gengar' && <Gengar data={state} />}

View File

@ -1,22 +1,9 @@
@media screen { @media screen {
.container { .container {
width: 210mm; width: 794px;
height: 297mm; min-height: 1122px;
zoom: 0.5;
overflow: scroll; overflow: scroll;
box-shadow: var(--shadow); box-shadow: var(--shadow);
@apply my-16 bg-white rounded; @apply my-16 bg-white rounded;
} }
} }
@media screen and (min-width: 1366px) {
.container {
zoom: 0.65;
}
}
@media screen and (min-width: 1440px) {
.container {
zoom: 0.8;
}
}

View File

@ -1,6 +1,5 @@
.container { .container {
z-index: 10; z-index: 10;
box-shadow: var(--left-shadow);
@apply w-full h-screen overflow-scroll p-8; @apply w-full h-screen overflow-scroll p-8;
@apply grid gap-8; @apply grid gap-8;
} }

View File

@ -1,6 +1,5 @@
.container { .container {
z-index: 10; z-index: 10;
box-shadow: var(--right-shadow);
@apply w-full h-screen overflow-scroll p-8; @apply w-full h-screen overflow-scroll p-8;
@apply grid gap-8; @apply grid gap-8;
} }

View File

@ -1,33 +1,19 @@
.container { .container {
@apply w-screen h-screen grid grid-cols-10; @apply relative h-screen w-screen overflow-hidden flex items-start justify-center;
} }
.left { .left {
@apply col-span-3; width: calc(100vw / 4);
box-shadow: var(--left-shadow);
@apply bg-primary-50 absolute top-0 bottom-0 left-0 z-10;
} }
.center { .center {
@apply col-span-4 h-screen overflow-scroll bg-primary-100 grid justify-center items-center; @apply relative z-0 h-screen overflow-scroll;
} }
.right { .right {
@apply col-span-3; width: calc(100vw / 4);
} box-shadow: var(--right-shadow);
@apply bg-primary-50 absolute top-0 bottom-0 right-0 z-10;
@media screen and (min-width: 1440px) {
.container {
@apply grid-cols-11;
}
.left {
@apply col-span-3;
}
.center {
@apply col-span-5;
}
.right {
@apply col-span-3;
}
} }