Skip to content

Commit

Permalink
Modify env files, add Iframe tc
Browse files Browse the repository at this point in the history
  • Loading branch information
tonytc13579 committed Dec 29, 2023
1 parent c97f29e commit 53f8d38
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_APP_ENV=develop
NEXT_PUBLIC_DOMAIN_URL="http://localhost:3000"
NEXT_PUBLIC_APP_ENV=local
NEXT_PUBLIC_DOMAIN_URL=http://localhost:3000
NEXT_PUBLIC_CDN_URL=https://cdn.newbitcoincity.com
NEXT_PUBLIC_API_URL=
2 changes: 1 addition & 1 deletion envs/.env.develop
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_APP_ENV=develop
NEXT_PUBLIC_DOMAIN_URL="http://localhost:3000"
NEXT_PUBLIC_DOMAIN_URL=https://dev.bvm.network
NEXT_PUBLIC_CDN_URL=https://cdn.newbitcoincity.com
NEXT_PUBLIC_API_URL=
2 changes: 1 addition & 1 deletion envs/.env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_APP_ENV=production
NEXT_PUBLIC_DOMAIN_URL="http://localhost:3000"
NEXT_PUBLIC_DOMAIN_URL=https://bvm.network
NEXT_PUBLIC_CDN_URL=https://cdn.newbitcoincity.com
NEXT_PUBLIC_API_URL=
2 changes: 1 addition & 1 deletion envs/.env.staging
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_APP_ENV=staging
NEXT_PUBLIC_DOMAIN_URL="http://localhost:3000"
NEXT_PUBLIC_DOMAIN_URL=https://bvm.network
NEXT_PUBLIC_CDN_URL=https://cdn.newbitcoincity.com
NEXT_PUBLIC_API_URL=
15 changes: 15 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ const nextConfig = {
`,
},

async redirects() {
return [
{
source: '/trustless-computers',
destination: '/tc',
permanent: false,
},
{
source: '/tc/dashboard',
destination: '/tc/computers',
permanent: false,
},
];
},

webpack: (config, { isServer, dev }) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"local": "cp ./envs/.env.local .env && next dev",
"dev": "cp ./envs/.env.develop .env && next dev",
"ld": "export PORT=3001 && cp ./envs/.env.develop .env && rm -rf .next && next dev",
"ls": "export PORT=3002 && cp ./envs/.env.staging .env && rm -rf .next && next dev",
Expand Down
2 changes: 1 addition & 1 deletion src/app/building-blocks/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const BuildingBlocksPage = () => {
return (
<MainLayout
headerProps={{
primaryColor: 'black',
color: 'black',
}}
>
<BuildingBlockModule />
Expand Down
26 changes: 26 additions & 0 deletions src/app/tc/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use client';

import IframeTC from '@/modules/iframe-tc';
import MainLayout from '@/layouts/MainLayout';
import { DOMAIN_URL, isProduction } from '@/config';

const MAIN_PATH = '/trustless-computers-iframe/';
// const IframeURLExtend = DOMAIN_URL + MAIN_PATH;
const IframeURLExtend =
'https://dev.newbitcoincity.com/trustless-computers-iframe/';

const TCPage = () => {
return (
<MainLayout
headerProps={{
color: 'black',
position: 'relative',
bgColor: 'white',
}}
>
<IframeTC iframeURL={IframeURLExtend} />
</MainLayout>
);
};

export default TCPage;
3 changes: 3 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export const API_UR: string = process.env.NEXT_PUBLIC_API_URL!;
export const DOMAIN_URL: string = process.env.NEXT_PUBLIC_DOMAIN_URL!;
export const CDN_URL: string = process.env.NEXT_PUBLIC_CDN_URL!;

export const isProduction: boolean = APP_ENV === 'production';
export const isDevelop: boolean = APP_ENV === 'develop';

export const CDN_URL_ICONS: string = CDN_URL + '/nbc/icons';

export { MetadataConfig, ViewportConfig };
4 changes: 4 additions & 0 deletions src/constants/breakpoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const XS_MOBILE_SCREEN = 500;
export const MOBILE_SCREEN = 768;
export const TABLET_SCREEN = 1024;
export const QHD_SCREEN = 2048;
90 changes: 90 additions & 0 deletions src/hooks/useWindowSize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import {
MOBILE_SCREEN,
QHD_SCREEN,
TABLET_SCREEN,
XS_MOBILE_SCREEN,
} from '@/constants/breakpoint';
import { useEffect, useState } from 'react';

interface Size {
sreenWidth: number;
heightWidth: number;
}

interface CheckMobile {
xSMobileScreen: boolean;
mobileScreen: boolean;
tabletScreen: boolean | undefined;
desktopScreen: boolean;
QHDScreen: boolean;
}

function useWindowSize(): Size & CheckMobile {
const [windowSize, setWindowSize] = useState<Size>({
sreenWidth: 0,
heightWidth: 0,
});
const [xSMobileScreen, setXSMobileScreen] = useState(true);
const [mobileScreen, setMobileScreen] = useState(true);
const [tabletScreen, setTabletScreen] = useState<boolean | undefined>(
undefined,
);
const [desktopScreen, setDesktopScreen] = useState(true);
const [QHDScreen, setQHDScreen] = useState(true);

useEffect(() => {
function handleResize() {
setWindowSize({
sreenWidth: window.innerWidth,
heightWidth: window.innerHeight,
});
}
window.addEventListener('resize', handleResize);
handleResize();
return () => window.removeEventListener('resize', handleResize);
}, []);

useEffect(() => {
if (windowSize?.sreenWidth && windowSize.sreenWidth <= XS_MOBILE_SCREEN) {
setXSMobileScreen(true);
} else {
setXSMobileScreen(false);
}

if (windowSize?.sreenWidth && windowSize.sreenWidth <= MOBILE_SCREEN) {
setMobileScreen(true);
} else {
setMobileScreen(false);
}

if (windowSize?.sreenWidth && windowSize.sreenWidth <= TABLET_SCREEN) {
setTabletScreen(true);
} else {
setTabletScreen(false);
}

if (windowSize?.sreenWidth && windowSize.sreenWidth >= QHD_SCREEN) {
setQHDScreen(true);
} else {
setQHDScreen(false);
}
}, [windowSize.sreenWidth]);

useEffect(() => {
setDesktopScreen(
!mobileScreen && !tabletScreen && !xSMobileScreen && !QHDScreen,
);
}, [tabletScreen, mobileScreen, xSMobileScreen, QHDScreen]);

return {
sreenWidth: windowSize.sreenWidth,
heightWidth: windowSize.heightWidth,
mobileScreen,
tabletScreen,
desktopScreen,
QHDScreen,
xSMobileScreen,
};
}

export default useWindowSize;
2 changes: 1 addition & 1 deletion src/layouts/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Box, Container, Stack, Text } from '@chakra-ui/react';

const Footer = () => {
return (
<Box bgColor={'black'}>
<Box bgColor={'black'} id="footer">
<Container
as={Stack}
maxW={'2xl'}
Expand Down
13 changes: 10 additions & 3 deletions src/layouts/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ import { MobileNav } from './components/MobileNav';
import Link from 'next/link';

export type HeaderProps = {
primaryColor?: 'black' | 'white';
color?: 'black' | 'white';
position?: 'absolute' | 'relative';
bgColor?: string;
};

const Header = (props: HeaderProps) => {
const primaryColor = props.primaryColor || 'white';
const primaryColor = props.color || 'white';
const position = props.position || 'absolute';
const bgColor = props.bgColor || 'transparent';

const { isOpen, onToggle } = useDisclosure();
const isMobile = useBreakpointValue({ base: true, md: false }) as boolean;

Expand All @@ -48,7 +53,8 @@ const Header = (props: HeaderProps) => {
return (
<>
<Box
position={'absolute'}
position={position === 'absolute' ? 'absolute' : 'relative'}
bgColor={bgColor}
display={'flex'}
justifyContent={'center'}
alignItems={'center'}
Expand All @@ -66,6 +72,7 @@ const Header = (props: HeaderProps) => {
display={'flex'}
flex={1}
align={'center'}
id="header"
>
{/* Left View */}
<Flex
Expand Down
46 changes: 46 additions & 0 deletions src/modules/iframe-tc/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use client';

import useWindowSize from '@/hooks/useWindowSize';
import s from './styles.module.scss';
import { useEffect } from 'react';

interface IProps {
iframeURL: string;
}

const IframeTC = (props: IProps) => {
const { heightWidth } = useWindowSize();
const elmHeader = document.getElementById('header');

useEffect(() => {
window.focus();
function blur(e: any) {
const elmHeader = document.getElementById('header-hidden');
if (elmHeader) {
elmHeader.click();
}
}
window.addEventListener('blur', blur);
return () => window.removeEventListener('blur', blur);
}, []);

return (
<div
className={s.container}
style={{
height:
heightWidth -
(elmHeader && elmHeader.offsetHeight ? elmHeader.offsetHeight : 80),
}}
>
<iframe
id="TC_PAGE_IFRAME"
src={props.iframeURL}
width="100%"
style={{ border: 'none' }}
/>
</div>
);
};

export default IframeTC;
9 changes: 9 additions & 0 deletions src/modules/iframe-tc/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.container {
display: flex;
flex-direction: row;
overflow: hidden;
}

.iframeGame {
width: 100%;
}

0 comments on commit 53f8d38

Please sign in to comment.