Skip to content

Commit

Permalink
feat: add compatible desktop solutions
Browse files Browse the repository at this point in the history
add compatible desktop solutions
  • Loading branch information
cycjimmy committed Nov 23, 2021
1 parent 1b0bcad commit 3738649
Show file tree
Hide file tree
Showing 23 changed files with 323 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ h5-webpack-starter
│ ├─preloader/ # Preloader component folder
│ ├─theme/ # Global and public styles
│ ├─shared/ # Public component or method
│ ├─setting.config.json # Global setting config
│ └─...
├─mock/ # Mock data entry folder
│ ├─api/
Expand Down
19 changes: 19 additions & 0 deletions app/pages/backCover/backCover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,22 @@
font-size: $fontL;
line-height: calcVW(80);
}

:global(.desktop) {
$radius: calcPX(7.5);
$space: calcPX(15);

.thanks {
font-size: calcPX(48);
}

.backBtn {
height: calcPX(80);
padding: 0 $space * 1.6;
margin: calcPX(50) 0;

border-width: calcPX(2);
border-radius: $radius;
line-height: calcPX(80);
}
}
6 changes: 6 additions & 0 deletions app/pages/basedOn/basedOn.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
@include bg-image-full(url("../../../static/images/icon-core.svg"));
}
}

:global(.desktop) {
.title {
font-size: calcPX(48);
}
}
24 changes: 24 additions & 0 deletions app/pages/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,27 @@
@include bg-image-full(url('../../static/images/icon-link.svg'));
}
}

:global(.desktop) {
.pointsWrapper {
width: calcPX(500);
padding: calcPX(20);
margin-bottom: calcPX(80);

> li {
padding: calcPX(10);
font-size: calcPX(36);
}
}

.icon {
width: calcPX(36);
height: calcPX(36);
margin: 0 calcPX(10);

&::before {
width: calcPX(30);
height: calcPX(30);
}
}
}
32 changes: 32 additions & 0 deletions app/pages/cover/cover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,35 @@ $picH: calcVW(240);
background-color: $fontColor;
}
}

:global(.desktop) {
$space: calcPX(15);
$radius: calcPX(7.5);

.title {
font-size: calcPX(48);
}

$picH: calcPX(240);
.logoWrap {
height: $picH;
width: $picH;
margin-bottom: $picH / 6;
}

.logo {
&::before {
perspective: $picH / 6;
}
}

.gotoGithub {
margin-top: $space * 2;
padding: 0 $space * 1.6;
height: calcPX(80);

border-width: calcPX(2);
border-radius: $radius;
line-height: calcPX(80);
}
}
6 changes: 6 additions & 0 deletions app/pages/features/features.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
list-style: decimal;
}
}

:global(.desktop) {
.title {
font-size: calcPX(48);
}
}
19 changes: 19 additions & 0 deletions app/pages/nestedSwiperDemo/nestedSwiperDemo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,22 @@
background: lighten($bgc, 10%);
}
}

:global(.desktop) {
.title {
font-size: calcPX(48);
}

.container {
width: calcPX(600);
height: calcPX(450);
margin: calcPX(40) auto;
}

.content1,
.content2,
.content3,
.content4 {
font-size: calcPX(36);
}
}
6 changes: 6 additions & 0 deletions app/pages/otherRecommended/otherRecommended.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
list-style: disc;
}
}

:global(.desktop) {
.title {
font-size: calcPX(48);
}
}
6 changes: 6 additions & 0 deletions app/pages/pageX/pageX.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
font-size: calcVW(48);
font-weight: bold;
}

:global(.desktop) {
.tip {
font-size: calcPX(48);
}
}
19 changes: 19 additions & 0 deletions app/pages/popupDemo/popupDemo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,22 @@
font-size: $fontL;
line-height: calcVW(80);
}

:global(.desktop) {
$radius: calcPX(7.5);
$space: calcPX(15);

.title {
font-size: calcPX(48);
}

.popupBtn {
height: calcPX(80);
padding: 0 $space * 1.6;
margin: calcPX(50) 0;

border-width: calcPX(2);
border-radius: $radius;
line-height: calcPX(80);
}
}
16 changes: 15 additions & 1 deletion app/pages/root.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
@import "../theme/utilities";

.root {
background-color: $bgc;
background-color: darken($bgc, 3%);

> :global(.swiper-container) {
background-color: $bgc;
}

&:global(.desktop) {
> :global(.swiper-container) {
width: $pcRootWidth;
max-height: round($pcRootWidth * $designDrawingBestHeight / $designDrawingWidth);
overflow: hidden;

@include fix-center(0);
}
}
}

.pagination {
Expand Down
28 changes: 28 additions & 0 deletions app/popups/popupX/popupX.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,31 @@ $popupXFontSize: calcVW(30);
line-height: $popupXFontSize * 1.5;
}

:global(.desktop) {
$popupXFontSize: calcPX(30);
$radius: calcPX(7.5);
$space: calcPX(15);

.box {
width: calcPX(340);
padding: calcPX(40);

border-width: calcPX(2);
border-radius: $radius * 2;
font-size: $popupXFontSize;
}

.info {
font-size: $popupXFontSize;
margin-bottom: $space;
}

.closeBtn {
padding: $space * 1.5;

border-width: calcVW(2);
border-radius: $radius;
font-size: $popupXFontSize;
line-height: $popupXFontSize * 1.5;
}
}
67 changes: 51 additions & 16 deletions app/popups/promptMobile/promptMobile.component.ins.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { Popup } from '@cycjimmy/h5-pages';
import { h5Pages, Popup } from '@cycjimmy/h5-pages';
import isMobile from '@cycjimmy/awesome-js-funcs/esm/handheld/isMobile';
import functionToPromise from '@cycjimmy/awesome-js-funcs/esm/typeConversion/functionToPromise';
import debounce from '@cycjimmy/awesome-js-funcs/esm/event/debounce';

import template from './promptMobile.pug';
import _style from './promptMobile.scss';
import QRCodeImg from '../../../static/images/QRCode.png';
import { needSupportDesktop } from '../../setting.config.json';

/**
* createQRCodeDesktop
* @returns {Promise<unknown>}
*/
const createQRCodeDesktop = () => Promise.resolve()
.then(() => functionToPromise(() => {
const QRCodeEl = document.createElement('div');
QRCodeEl.classList.add(_style.QRCodeDesktop);
h5Pages.root.appendChild(QRCodeEl);
}));

export default new class extends Popup {
constructor() {
Expand All @@ -13,27 +26,49 @@ export default new class extends Popup {
}

load() {
if (isMobile()) {
this.isMobile = true;
return Promise.resolve();
}
return Promise.resolve()
.then(() => createQRCodeDesktop())
.then(() => this._render())
.then(() => this._eventBind());
}

this.isMobile = false;
getIsMobile() {
return this.isMobile;
}

_render() {
return Promise.resolve()
.then(() => functionToPromise(() => {
this.isMobile = false;
this.popup.classList.add(_style.wrapper);
this.isMobile = isMobile();
}))
.then(() => this.render(template({
_style,
QRCodeImg,
suggest: 'Scan code for better experience.',
})))
.then(() => Promise.reject(new Error('not mobile device')));
.then(() => {
if (this.isMobile) {
h5Pages.root.classList.remove('desktop');
return Promise.resolve();
}

if (needSupportDesktop) {
h5Pages.root.classList.add('desktop');
return Promise.resolve();
}

return Promise.resolve()
.then(() => functionToPromise(() => {
this.popup.classList.add(_style.wrapper);
}))
.then(() => this.render(template({
_style,
QRCodeImg,
suggest: 'Scan code for better experience.',
})))
.then(() => Promise.reject(new Error('not mobile device')));
});
}

getIsMobile() {
return this.isMobile;
_eventBind() {
window.addEventListener(
'resize',
() => debounce(() => this._render(), 100)(),
);
}
}();
33 changes: 33 additions & 0 deletions app/popups/promptMobile/promptMobile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,36 @@ $promptMobileFontColor: $fontColor;
font-size: 14px;
}

$QRCodeDesktopWidth: 100px;

.QRCodeDesktop {
@extend %abs;
width: 0;
height: 0;
display: none;
@include fix-center(0);

&::before {
content: "";
display: block;
@extend %abs;
left: round($pcRootWidth * .5 + 20);
top: - round($pcRootWidth * .3 + $QRCodeDesktopWidth * .5);
width: $QRCodeDesktopWidth;
height: $QRCodeDesktopWidth;

border: 2px solid darken($bgc, 5%);
border-radius: 12px;
overflow: hidden;
@include bg-image-full(url("../../../static/images/QRCode.png"));
}
}

:global(.desktop) {
@media screen and (min-width: $pcRootWidth * 1.5) {
.QRCodeDesktop {
display: block;
}
}
}

6 changes: 6 additions & 0 deletions app/popups/promptOrientation/promptOrientation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ $lockOrientation: portrait;
}
}

:global(.desktop) {
.wrapper {
display: none;
}
}

Loading

0 comments on commit 3738649

Please sign in to comment.