Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#80] apply desktopEnv #81

Merged
merged 5 commits into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/common/Category/BottomLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function BottomLink() {
export default BottomLink;

const wrapper = (theme: Theme) => css`
position: fixed;
position: sticky;
left: 0;
bottom: 0;
width: 100%;
Expand All @@ -40,7 +40,7 @@ const wrapper = (theme: Theme) => css`
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
justify-content: flex-end;

border-top: 1px solid ${theme.color.border};
background-color: ${theme.color.fullWhite};
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Main/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default Carousel;

const slider = css`
.slick-list {
width: 100vw;
width: 100%;
margin: 0 auto;
}
.slick-slide div {
Expand All @@ -69,7 +69,7 @@ const slider = css`

const wrapper = css`
position: relative;
width: 100vw;
width: 100%;
height: auto;
padding: 20px 0;
top: 0;
Expand Down
30 changes: 30 additions & 0 deletions src/hooks/useWindowSize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useEffect, useState } from "react";

interface Size {
width: number | undefined;
height: number | undefined;
}

function useWindowSize(): Size {
const [windowSize, setWindowSize] = useState<Size>({
width: undefined,
height: undefined,
});

useEffect(() => {
const handleResize = () => {
setWindowSize({
width: window.innerWidth,
height: window.innerHeight,
});
};

window.addEventListener("resize", handleResize);
handleResize();
return () => window.removeEventListener("resize", handleResize);
}, []);

return windowSize;
}

export default useWindowSize;
3 changes: 1 addition & 2 deletions src/pages/Category/Alone/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const fullSizeWrapper = (theme: Theme) => css`
position: relative;
width: 100%;
min-height: 100%;
padding-bottom: 3.85rem;
background-color: ${theme.color.fullWhite};
`;

Expand All @@ -89,7 +88,7 @@ const inWrapper = css`

const keywordMenu = (theme: Theme) => css`
width: 100%;
padding: 0.75rem 0.6rem;
padding: 0.35rem 0.6rem 0.75rem 0.6rem;
background-color: ${theme.color.fullWhite};
`;

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Category/CostEffect/Rank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const fullSizeWrapper = css`
flex-direction: column;
width: 100%;
min-height: 100%;
padding: 1.25rem 1rem 3.85rem 1rem;
padding: 1.25rem 1rem 0rem 1rem;
`;

const title = (theme: Theme) => css`
Expand Down
1 change: 0 additions & 1 deletion src/pages/Category/CostEffect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const fullSizeWrapper = (theme: Theme) => css`
position: relative;
width: 100%;
min-height: 100%;
padding-bottom: 3.85rem;
background-color: ${theme.color.fullWhite};
`;

Expand Down
1 change: 0 additions & 1 deletion src/pages/Category/Dining/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const fullSizeWrapper = (theme: Theme) => css`
position: relative;
width: 100%;
min-height: 100%;
padding-bottom: 3.85rem;
background-color: ${theme.color.fullWhite};
`;

Expand Down
1 change: 0 additions & 1 deletion src/pages/Category/Hangover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const fullSizeWrapper = (theme: Theme) => css`
position: relative;
width: 100%;
min-height: 100%;
padding-bottom: 3.85rem;
background-color: ${theme.color.fullWhite};
`;

Expand Down
4 changes: 2 additions & 2 deletions src/pages/Category/Ricefull/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export default Ricefull;
const fullSizeWrapper = (theme: Theme) => css`
position: relative;
width: 100%;
min-height: 100%;
padding-bottom: 3.85rem;
/* min-height: 100%; */
min-height: auto;
background-color: ${theme.color.fullWhite};
`;

Expand Down
3 changes: 1 addition & 2 deletions src/pages/Category/Ricefull/introduce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ const mainSizeWrapper = css`
position: relative;
min-height: 100%;
width: 100%;
padding-bottom: 3.85rem;
`;

const introSizeWrapper = css`
Expand Down Expand Up @@ -143,7 +142,7 @@ const cardWrapper = css`
const cardInWrapper = css`
display: flex;
flex-direction: row;
width: 100vw;
width: 100%;
cursor: grab;
`;

Expand Down
1 change: 0 additions & 1 deletion src/pages/Detail/[detailId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const fullSizeWrapper = css`
position: relative;
width: 100%;
min-height: 100%;
padding-bottom: 3.85rem;
margin-top: 0.9rem;
`;

Expand Down
1 change: 0 additions & 1 deletion src/pages/Inquiry/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const mainSizeWrapper = css`
position: relative;
min-height: 100%;
width: 100%;
padding-bottom: 3.85rem;
`;

const itemSizeWrapper = css`
Expand Down
1 change: 0 additions & 1 deletion src/pages/Introduce/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const mainSizeWrapper = css`
position: relative;
min-height: 100%;
width: 100%;
padding-bottom: 3.85rem;
`;

const itemSizeWrapper = css`
Expand Down
1 change: 0 additions & 1 deletion src/pages/Notice/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const mainSizeWrapper = css`
position: relative;
min-height: 100%;
width: 100%;
padding-bottom: 3.85rem;
`;

const itemWrapper = (theme: Theme) => css`
Expand Down
1 change: 0 additions & 1 deletion src/pages/Review/Introduce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const mainSizeWrapper = css`
position: relative;
min-height: 100%;
width: 100%;
padding-bottom: 3.85rem;
`;

const itemSizeWrapper = css`
Expand Down
1 change: 0 additions & 1 deletion src/pages/Review/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const itemSize = css`
display: flex;
flex-direction: column;
position: relative;
padding-bottom: 3.85rem;
`;

const itemPadding = css`
Expand Down
1 change: 0 additions & 1 deletion src/pages/Review/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const itemSize = css`
position: relative;
min-height: 100%;
width: 100%;
padding-bottom: 3.85rem;
`;

const itemPadding = css`
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const wrapper = css`
min-height: 100%;
position: relative;
width: 100%;
padding-bottom: 3.85rem;
`;

const textWrapper = css`
Expand All @@ -57,7 +56,7 @@ const cardWrapper = css`
flex-direction: row;
justify-content: center;
width: 100%;
height: auto;
min-height: 100vh;
flex-wrap: wrap;
`;

Expand Down
67 changes: 62 additions & 5 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { AppProps } from "next/app";
import { css } from "@emotion/react";
import Head from "next/head";
import { NextUIProvider } from "@nextui-org/react";
import { ThemeProvider } from "@emotion/react";
import Theme from "styles/Theme";
import GlobalStyle from "styles/GlobalStyle";
import { useEffect, useState } from "react";
import { PropsWithChildren, useEffect, useState } from "react";
import BottomLink from "components/common/Category/BottomLink";
import Nav from "components/Nav";
import WebWarning from "components/common/Main/WebWarning";
Expand All @@ -14,14 +15,18 @@ import { useRouter } from "next/router";
import * as gtag from "libs/gtag";
import Script from "next/script";
import { RecoilRoot } from "recoil";
import useWindowSize from "hooks/useWindowSize";

declare global {
interface Window {
Kakao: any;
}
}

let vh = 0;

function MyApp({ Component, pageProps }: AppProps) {
useASCIICode();
useEffect(() => {
const id = "kakao-sdk";
if (document.getElementById(id) == null) {
Expand Down Expand Up @@ -63,16 +68,21 @@ function MyApp({ Component, pageProps }: AppProps) {
<RecoilRoot>
<ThemeProvider theme={Theme}>
<GlobalStyle />
{isWeb ? <WebWarning /> : ""}
{/* {isWeb ? <WebWarning /> : ""} */}
<NextUIProvider>
<Script
defer
crossOrigin="anonymous"
src="https://developers.kakao.com/sdk/js/kakao.js"
/>
<Nav searchField={searchField} setSearchField={setSearchField} />
<Component {...pageProps} searchField={searchField} />
<BottomLink />
<Layout>
<Nav
searchField={searchField}
setSearchField={setSearchField}
/>
<Component {...pageProps} searchField={searchField} />
<BottomLink />
</Layout>
</NextUIProvider>
</ThemeProvider>
</RecoilRoot>
Expand All @@ -82,3 +92,50 @@ function MyApp({ Component, pageProps }: AppProps) {
}

export default MyApp;

function Layout({ children }: PropsWithChildren<{}>) {
const windowSize = useWindowSize();

useEffect(() => {
vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty("--vh", `${vh}px`);
}, [windowSize.height]);

return <div css={layoutCss}>{children}</div>;
}

const layoutCss = css`
min-height: calc(var(--var, 1vh) * 100);
max-width: 480px;
width: 100%;
margin: 0 auto;
height: 100vh;
`;

function useASCIICode() {
useEffect(() => {
if (typeof window !== "undefined") {
console.log(`
----------------------------------
----------------------------------
-----##-----------------(#--------
-----##-----------------#$--------
-----@@-----------------@##~###---
-----@;-----------------##--------
-----!#-----------------=@--------
-----##-----------------&#~;###---
-----##@#@:##;=@#-------@#--------
------------------------##--------
----------------------------------
-------##:$###+####;@@#$##--------
-------##---------------##--------
-------;#---------------##--------
-------##---------------:#--------
-------##---------------##--------
-------#=~##*@@###@@@@##=@--------
----------------------------------
----------------------------------
`);
}
});
}
1 change: 0 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const wrapper = css`
min-height: 100%;
position: relative;
width: 100%;
padding-bottom: 3.85rem;
overflow-x: hidden;
`;

Expand Down