mobile fixes

This commit is contained in:
Jeff Colombo 2019-03-24 18:27:52 -04:00
parent ed723f4354
commit c7bd19a32a
21 changed files with 190 additions and 42 deletions

14
dist/app.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/global.css vendored

File diff suppressed because one or more lines are too long

14
dist/main-bundle.js vendored

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@
"lint": "tslint --project tslint.json", "lint": "tslint --project tslint.json",
"package": "yarn build --config webpack.config.prod.js --bail --display-used-exports -p", "package": "yarn build --config webpack.config.prod.js --bail --display-used-exports -p",
"package-for-test": "yarn build --config webpack.config.test.js --bail --display-used-exports", "package-for-test": "yarn build --config webpack.config.test.js --bail --display-used-exports",
"start": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.config.js --progress --colors --debug --output-pathinfo --port 8000 --env.WARN_ON_LINT", "start": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.config.js --progress --colors --debug --output-pathinfo --port 8000 --host 0.0.0.0 --env.WARN_ON_LINT",
"build": "node ./node_modules/webpack/bin/webpack.js --cache=true --display-error-details --profile", "build": "node ./node_modules/webpack/bin/webpack.js --cache=true --display-error-details --profile",
"clean": "rm -rf ./dist/*", "clean": "rm -rf ./dist/*",
"tsnode": "node -r ts-node/register -r tsconfig-paths/register", "tsnode": "node -r ts-node/register -r tsconfig-paths/register",
@ -78,6 +78,8 @@
"webpack-shell-plugin": "^0.5.0" "webpack-shell-plugin": "^0.5.0"
}, },
"dependencies": { "dependencies": {
"@types/body-scroll-lock": "^2.6.0",
"body-scroll-lock": "^2.6.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"history": "^4.9.0", "history": "^4.9.0",
"nes.css": "^2.0.0", "nes.css": "^2.0.0",
@ -87,6 +89,7 @@
"react": "^16.7.0", "react": "^16.7.0",
"react-dom": "^16.7.0", "react-dom": "^16.7.0",
"react-measure": "^2.2.2", "react-measure": "^2.2.2",
"react-media": "^1.9.2",
"react-redux": "^6.0.0", "react-redux": "^6.0.0",
"react-router-dom": "^4.3.1", "react-router-dom": "^4.3.1",
"react-window": "^1.5.0", "react-window": "^1.5.0",

1
src/scss/Components.scss Normal file
View File

@ -0,0 +1 @@
$navigation-width: 72px;

View File

@ -1,10 +1,29 @@
@import '~nes.css/scss/base/color-palette'; @import '~nes.css/scss/base/color-palette';
@import '~nes.css/scss/base/variables'; @import '~nes.css/scss/base/variables';
// 320 x 568
// 360 x 640
// 375 x 667
// 411 x 731
// 414 x 736
// 768 x 1024
// 1024 x 1366
// 1280 x 800
// 1440 x 900
$min-large-desktop-width: 1200px;
$max-desktop-width: 1199px;
$min-desktop-width: 993px;
$max-tablet-width: 992px;
$min-tablet-width: 768px;
$max-mobile-width: 767px;
$min-mobile-width: 360px;
$max-small-mobile-width: 359px;
$container-width: ( $container-width: (
desktop: 425px, desktop: 425px,
tablet: 425px, tablet: 425px,
mobile: 425px mobile: 320px
); );
$game-boy-1: #e3eec0; $game-boy-1: #e3eec0;

View File

@ -4,8 +4,15 @@
html, html,
body { body {
height: 100vh;
margin: 0; margin: 0;
@media only screen and (max-width: $max-mobile-width) {
font-size: 13px;
}
@media only screen and (max-width: $max-small-mobile-width) {
font-size: 10px;
}
} }
a { a {
@ -102,6 +109,7 @@ a.list-item {
} }
.nes-container.with-title > .title { .nes-container.with-title > .title {
font-size: 1em;
background-color: $main-background-color; background-color: $main-background-color;
} }

View File

@ -141,6 +141,13 @@ $scale: 4;
width: 16px * $pokeball-scale; width: 16px * $pokeball-scale;
transform-origin: 50% 75%; transform-origin: 50% 75%;
&.icon-large {
background-size: 32px * $pokeball-scale * 1.5 80px * $pokeball-scale * 1.5;
background-position: 0 * $pokeball-scale * 1.5 0 * $pokeball-scale * 1.5;
height: 16px * $pokeball-scale * 1.5;
width: 16px * $pokeball-scale * 1.5;
}
&:hover { &:hover {
animation: shake 1.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both infinite; animation: shake 1.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both infinite;
} }
@ -159,6 +166,10 @@ $scale: 4;
&.premier-ball { &.premier-ball {
background-position: 0 * $pokeball-scale -64px * $pokeball-scale; background-position: 0 * $pokeball-scale -64px * $pokeball-scale;
&.icon-large {
background-position: 0 * $pokeball-scale * 1.5 -64px * $pokeball-scale * 1.5;
}
} }
&.ball-open { &.ball-open {

View File

@ -11,7 +11,7 @@ import * as ActionsPokemonExplorer from 'app/components/PokemonExplorer/actions'
import * as ActionsPokemonSelectList from 'app/components/PokemonSelectList/actions'; import * as ActionsPokemonSelectList from 'app/components/PokemonSelectList/actions';
import { IPokemonAppDispatch, IRouterProps } from 'app/types'; import { IPokemonAppDispatch, IRouterProps } from 'app/types';
import { convertFormParamToPokemonForm, convertIdParamToPokemonId } from 'app/utils/navigation'; import { convertFormParamToPokemonForm, convertIdParamToPokemonId, convertLeagueParamToLeague } from 'app/utils/navigation';
import { Footer } from 'app/components/Footer'; import { Footer } from 'app/components/Footer';
import { Header } from 'app/components/Header'; import { Header } from 'app/components/Header';
@ -50,6 +50,7 @@ class PokemonApp extends React.Component<IConnectedPokemonAppProps, IState> {
const { const {
id, id,
form, form,
league,
} = match.params; } = match.params;
await Promise.all([ await Promise.all([
@ -64,6 +65,11 @@ class PokemonApp extends React.Component<IConnectedPokemonAppProps, IState> {
if (pokemonId !== null && pokemonForm !== null) { if (pokemonId !== null && pokemonForm !== null) {
this.handleActivatePokemon(pokemonId, pokemonForm); this.handleActivatePokemon(pokemonId, pokemonForm);
} }
const activeLeague = convertLeagueParamToLeague(league);
if (activeLeague !== null) {
dispatch(ActionsPokemonExplorer.setActiveLeague(activeLeague));
}
} }
public render() { public render() {

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import Media from 'react-media';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import classNames from 'classnames'; import classNames from 'classnames';
@ -25,6 +26,16 @@ export class Header extends React.Component<IHeaderProps> {
styles.header, styles.header,
); );
const iconCss = classNames(
'icon',
'icon-large',
'pixel',
'sprite',
'pokeball',
'premier-ball',
''
);
// const linkTo = { // const linkTo = {
// // pathname: '/courses', // // pathname: '/courses',
// search: appendQueryString(location, { // search: appendQueryString(location, {
@ -37,12 +48,15 @@ export class Header extends React.Component<IHeaderProps> {
return ( return (
<header className={ headerCss }> <header className={ headerCss }>
<Link <Link
to="/explorer/1/0" to="/explorer"
// style={ style } // style={ style }
// className={ anchorCss } // className={ anchorCss }
// onClick={ this.reload } // onClick={ this.reload }
> >
PVPokemon <i className={ iconCss } />
<Media query={ { minWidth: 768 } }>
<span>PVPokémon</span>
</Media>
</Link> </Link>
{ /* <Link { /* <Link
to="/explorer" to="/explorer"

View File

@ -2,6 +2,7 @@ import React from 'react';
import { ContentRect, default as Measure } from 'react-measure'; import { ContentRect, default as Measure } from 'react-measure';
import { FixedSizeList } from 'react-window'; import { FixedSizeList } from 'react-window';
import { clearAllBodyScrollLocks, disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
import classNames from 'classnames'; import classNames from 'classnames';
import { CombatMoveStats, IPokemonMove } from 'app/models/Pokemon'; import { CombatMoveStats, IPokemonMove } from 'app/models/Pokemon';
@ -27,6 +28,8 @@ export interface IMovesDropdownProps {
interface IState { interface IState {
listRef : React.RefObject<FixedSizeList>; listRef : React.RefObject<FixedSizeList>;
overlayRef : React.RefObject<HTMLDivElement>;
isBodyScrollDisabled : boolean;
dimensions : { dimensions : {
width : number; width : number;
height : number; height : number;
@ -41,16 +44,30 @@ interface IRowFactory {
export class MovesDropdown extends React.Component<IMovesDropdownProps, IState> { export class MovesDropdown extends React.Component<IMovesDropdownProps, IState> {
public static getDerivedStateFromProps(nextProps : IMovesDropdownProps, previousState : IState) { public static getDerivedStateFromProps(nextProps : IMovesDropdownProps, previousState : IState) {
if (!nextProps.isMenuOpen) { let isBodyScrollDisabled = previousState.isBodyScrollDisabled;
return { let dimensions = previousState.dimensions;
...previousState,
dimensions: { if (nextProps.isMenuOpen) {
width: -1, if (!previousState.isBodyScrollDisabled && previousState.overlayRef.current) {
height: -1, disableBodyScroll(previousState.overlayRef.current);
} isBodyScrollDisabled = true;
}
} else {
if (previousState.isBodyScrollDisabled && previousState.overlayRef.current) {
enableBodyScroll(previousState.overlayRef.current);
isBodyScrollDisabled = false;
}
dimensions = {
width: -1,
height: -1,
}; };
} }
return null;
return {
...previousState,
isBodyScrollDisabled,
dimensions,
};
} }
constructor(props : IMovesDropdownProps) { constructor(props : IMovesDropdownProps) {
@ -58,6 +75,8 @@ export class MovesDropdown extends React.Component<IMovesDropdownProps, IState>
this.state = { this.state = {
listRef: React.createRef(), listRef: React.createRef(),
overlayRef: React.createRef(),
isBodyScrollDisabled: false,
dimensions: { dimensions: {
width: -1, width: -1,
height: -1, height: -1,
@ -124,7 +143,7 @@ export class MovesDropdown extends React.Component<IMovesDropdownProps, IState>
{ moveName } { moveName }
</div> </div>
{ isMenuOpen && { isMenuOpen &&
<div className={ menuCss }> <div ref={ this.state.overlayRef } className={ menuCss }>
<h3 className="title">{ menuLabel }</h3> <h3 className="title">{ menuLabel }</h3>
<Measure <Measure
bounds={ true } bounds={ true }

View File

@ -9,7 +9,9 @@
} }
:global(.nes-field.is-inline).fieldRow { :global(.nes-field.is-inline).fieldRow {
font-size: 0.9em;
justify-content: space-between; justify-content: space-between;
align-items: baseline;
label { label {
flex-grow: 0; flex-grow: 0;

View File

@ -73,9 +73,9 @@
:global(.title).ivContainerTitle { :global(.title).ivContainerTitle {
margin-bottom: 0; margin-bottom: 0;
margin-right: -$border-offset; margin-right: -$border-offset - 1;
margin-left: -$border-offset; margin-left: -$border-offset - 1;
padding: 0 2.5rem; padding: 0 1.5em;
} }
} }
} }

View File

@ -28,6 +28,14 @@
margin-left: -1 * map-get($container-width, 'desktop') / 2; margin-left: -1 * map-get($container-width, 'desktop') / 2;
padding: 0; padding: 0;
@media only screen and (max-width: $max-mobile-width) {
// font-size:
width: auto;
margin: 0 1em;
left: 0;
right: 0;
}
:global(.list-item):global(.active)::before, :global(.list-item):global(.active)::before,
:global(.list-item):hover::before { :global(.list-item):hover::before {
top: 8px; top: 8px;
@ -50,6 +58,11 @@
white-space: nowrap; white-space: nowrap;
text-transform: capitalize; text-transform: capitalize;
@media only screen and (max-width: $max-mobile-width) {
padding-right: 0;
font-size: 0.9em;
}
& > * { & > * {
flex: 0 1 auto; flex: 0 1 auto;
} }

View File

@ -1,4 +1,5 @@
@import '~styles/Variables.scss'; @import '~styles/Variables.scss';
@import '~styles/Components.scss';
.highlight { .highlight {
composes: highlight from '../../../styles/PokemonApp.scss'; composes: highlight from '../../../styles/PokemonApp.scss';

View File

@ -1,3 +1,5 @@
@import '~styles/Variables.scss';
.baseStatRow { .baseStatRow {
display: flex; display: flex;
align-items: center; align-items: center;
@ -13,5 +15,9 @@
height: 1em; height: 1em;
border-image-outset: 1; border-image-outset: 1;
padding: 2px; padding: 2px;
@media only screen and (max-width: $max-mobile-width) {
height: 1.2em;
}
} }
} }

View File

@ -75,7 +75,7 @@
.indicatorWrapper { .indicatorWrapper {
display: grid; display: grid;
grid-template-columns: repeat(auto-fill, minmax(7em, auto)); grid-template-columns: repeat(auto-fill, minmax(33%, auto)); // was 7em
justify-content: space-between; justify-content: space-between;
& > * { & > * {

View File

@ -16,9 +16,9 @@ export const LeagueLabels : Array<{ id : League, label : string }> = [{
}, { }, {
id: League.MASTER, id: League.MASTER,
label: 'Master' label: 'Master'
}, { // }, {
id: League.CUSTOM, // id: League.CUSTOM,
label: 'Custom' // label: 'Custom'
}]; }];
export interface IMaxCpByLeague { export interface IMaxCpByLeague {

View File

@ -1,4 +1,5 @@
@import '~styles/Variables.scss'; @import '~styles/Variables.scss';
@import '~styles/Components.scss';
$overlay-opacity: 0.7; $overlay-opacity: 0.7;
$footer-height: 60px; $footer-height: 60px;
@ -7,7 +8,7 @@ $footer-height: 60px;
display: flex; display: flex;
flex-flow: column nowrap; flex-flow: column nowrap;
align-items: stretch; align-items: stretch;
height: 100vh; // height: 100vh;
.body { .body {
background-color: $main-background-color; background-color: $main-background-color;
@ -28,6 +29,7 @@ $footer-height: 60px;
} }
.header { .header {
display: flex;
flex: 0 0 auto; flex: 0 0 auto;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@ -37,6 +39,7 @@ $footer-height: 60px;
a { a {
display: inline-block; display: inline-block;
display: flex;
} }
} }
@ -50,19 +53,24 @@ $footer-height: 60px;
.header, .header,
.footer { .footer {
display: flex;
margin: 0.1em; margin: 0.1em;
z-index: 10; z-index: 10;
} }
.navigation { .navigation {
margin-right: -72px; // offset so the displayWrapper is centered margin-right: -1 * $navigation-width; // offset so the displayWrapper is centered
padding: 1em; padding: 1em;
position: sticky; position: sticky;
top: 90px; top: 90px;
display: inline-flex; display: inline-flex;
flex-flow: column nowrap; flex-flow: column nowrap;
align-self: flex-start; align-self: flex-start;
@media only screen and (max-width: $max-mobile-width) {
position: absolute;
top: 0;
right: $navigation-width;
}
} }
.header, .header,
@ -101,6 +109,11 @@ $footer-height: 60px;
& > * { & > * {
width: map-get($container-width, 'desktop'); width: map-get($container-width, 'desktop');
margin: 0 1em; margin: 0 1em;
@media only screen and (max-width: $max-mobile-width) {
width: auto;
margin: 0 0.1em;
}
} }
} }

View File

@ -789,6 +789,11 @@
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=
"@types/body-scroll-lock@^2.6.0":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@types/body-scroll-lock/-/body-scroll-lock-2.6.0.tgz#f5b3e9acffc646793633e88aa571999cda8adc5b"
integrity sha512-T6ZmLK1CBXURdwsi256hLYSU6SOWQWs2p7X9TL9d95q30SyZrv1FPwUMtS5YE3H4FulCyFLPfNjhsIeSkUb9Hg==
"@types/classnames@^2.2.7": "@types/classnames@^2.2.7":
version "2.2.7" version "2.2.7"
resolved "https://registry.yarnpkg.com/@types/classnames/-/classnames-2.2.7.tgz#fb68cc9be8487e6ea5b13700e759bfbab7e0fefd" resolved "https://registry.yarnpkg.com/@types/classnames/-/classnames-2.2.7.tgz#fb68cc9be8487e6ea5b13700e759bfbab7e0fefd"
@ -1536,6 +1541,11 @@ body-parser@1.18.3:
raw-body "2.3.3" raw-body "2.3.3"
type-is "~1.6.16" type-is "~1.6.16"
body-scroll-lock@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/body-scroll-lock/-/body-scroll-lock-2.6.1.tgz#3782ff37404886faaee366968ceee40c3964d8f2"
integrity sha512-fsDsq10+BJrk/+eGADqxspyZpGiKSh3dK8ByE6KuDK0REmPB99U05p1t9xVTAM9J6j9PJGm6W/W+HsCPnOFj+Q==
bonjour@^3.5.0: bonjour@^3.5.0:
version "3.5.0" version "3.5.0"
resolved "https://registry.yarnpkg.com/bonjour/-/bonjour-3.5.0.tgz#8e890a183d8ee9a2393b3844c691a42bcf7bc9f5" resolved "https://registry.yarnpkg.com/bonjour/-/bonjour-3.5.0.tgz#8e890a183d8ee9a2393b3844c691a42bcf7bc9f5"
@ -4106,6 +4116,13 @@ json-stringify-safe@~5.0.1:
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=
json2mq@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/json2mq/-/json2mq-0.2.0.tgz#b637bd3ba9eabe122c83e9720483aeb10d2c904a"
integrity sha1-tje9O6nqvhIsg+lyBIOusQ0skEo=
dependencies:
string-convert "^0.2.0"
json3@^3.3.2: json3@^3.3.2:
version "3.3.2" version "3.3.2"
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1"
@ -5593,7 +5610,7 @@ promise-inflight@^1.0.1:
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=
prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2: prop-types@^15.5.10, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2" version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
@ -5791,6 +5808,16 @@ react-measure@^2.2.2:
prop-types "^15.6.2" prop-types "^15.6.2"
resize-observer-polyfill "^1.5.0" resize-observer-polyfill "^1.5.0"
react-media@^1.9.2:
version "1.9.2"
resolved "https://registry.yarnpkg.com/react-media/-/react-media-1.9.2.tgz#423ee12f952e1d69f1b994a58d3cbed21a92b370"
integrity sha512-JUYECMcJIm0V61LSVKd1e+II4ZTYO0GuR7xtlvKETlmThZ416BqZjZdJ1uGqgmMAGFeJ3TG4TX/3Kg4qbR3EJw==
dependencies:
"@babel/runtime" "^7.2.0"
invariant "^2.2.2"
json2mq "^0.2.0"
prop-types "^15.5.10"
react-redux@^6.0.0: react-redux@^6.0.0:
version "6.0.1" version "6.0.1"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-6.0.1.tgz#0d423e2c1cb10ada87293d47e7de7c329623ba4d" resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-6.0.1.tgz#0d423e2c1cb10ada87293d47e7de7c329623ba4d"
@ -6700,6 +6727,11 @@ stream-shift@^1.0.0:
resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952"
integrity sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI= integrity sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=
string-convert@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/string-convert/-/string-convert-0.2.1.tgz#6982cc3049fbb4cd85f8b24568b9d9bf39eeff97"
integrity sha1-aYLMMEn7tM2F+LJFaLnZvznu/5c=
string-width@^1.0.1, string-width@^1.0.2: string-width@^1.0.1, string-width@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"