Skip to content

Commit

Permalink
Merge pull request #2 from T1F5/feat/swiper
Browse files Browse the repository at this point in the history
test swiper & default layout config
  • Loading branch information
Geun-Oh authored Apr 6, 2024
2 parents fccb901 + 3ace900 commit 05bee1a
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 34 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@tanstack/react-query": "^5.28.14",
"@types/react-router-dom": "^5.3.3",
"axios": "^1.6.8",
"jotai": "^2.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3"
"react-router-dom": "^6.22.3",
"swiper": "^11.1.0"
},
"devDependencies": {
"@emotion/babel-plugin": "^11.11.0",
"@emotion/react": "^11.11.4",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
Expand Down
23 changes: 11 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { css } from "@emotion/react";
import Router from "./Router";
import styled from '@emotion/styled';

function App() {
return (
<div
css={css`
padding: 32px;
background-color: hotpink;
font-size: 24px;
border-radius: 4px;
`}
>
emotion test
</div>
<>
<Layout>
<Router />
</Layout>
</>
);
}

export default App;

const Layout = styled.div`
max-width: 768px;
width: 100vw;
border-left: 1px solid lightgray;
border-right: 1px solid lightgray;
`
2 changes: 1 addition & 1 deletion src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const Router = () => {
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/A" element={<A />} />
<Route path="/image-download" element={<ImageDownloadPage />} />
<Route path="/a" element={<A />} />
</Routes>
</BrowserRouter>
);
Expand Down
70 changes: 70 additions & 0 deletions src/components/TestSwiper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Swiper, SwiperSlide } from 'swiper/react';
import styled from '@emotion/styled';
import { css } from '@emotion/react'
import 'swiper/css';
import 'swiper/css/effect-coverflow';
import 'swiper/css/pagination';

import { EffectCards, Pagination } from 'swiper/modules';


const TestSwiper = () => {
return (
<Swiper
css={css`
width: 100%;
`}
effect={'cards'}
grabCursor={true}
centeredSlides={true}
slidesPerView={1.2}
coverflowEffect={{
rotate: 10,
stretch: 0,
depth: 500,
modifier: 2,
slideShadows: true,
}}
pagination={false}
modules={[EffectCards, Pagination]}
className="mySwiper"
>
<StyledSlide>
<img src="https://swiperjs.com/demos/images/nature-2.jpg" />
</StyledSlide>
<StyledSlide>
<img src="https://swiperjs.com/demos/images/nature-3.jpg" />
</StyledSlide>
<StyledSlide>
<img src="https://swiperjs.com/demos/images/nature-4.jpg" />
</StyledSlide>
<StyledSlide>
<img src="https://swiperjs.com/demos/images/nature-5.jpg" />
</StyledSlide>
<StyledSlide>
<img src="https://swiperjs.com/demos/images/nature-6.jpg" />
</StyledSlide>
<StyledSlide>
<img src="https://swiperjs.com/demos/images/nature-7.jpg" />
</StyledSlide>
<StyledSlide>
<img src="https://swiperjs.com/demos/images/nature-8.jpg" />
</StyledSlide>
<StyledSlide>
<img src="https://swiperjs.com/demos/images/nature-9.jpg" />
</StyledSlide>
</Swiper>
)
}

export default TestSwiper;

const StyledSlide = styled(SwiperSlide)`
background-position: center;
background-size: cover;
width: auto;
img {
display: block;
width: 100%;
}
`
7 changes: 7 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
html, body {
width: 100%;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
}
1 change: 1 addition & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";

import Router from "./Router";

Expand Down
4 changes: 3 additions & 1 deletion src/pages/A.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import TestSwiper from "../components/TestSwiper";

const A = () => {
return (
<div>
A
<TestSwiper />
</div>
)
}
Expand Down
22 changes: 15 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,33 @@
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"moduleResolution": "node",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
"include": [
"src"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}

0 comments on commit 05bee1a

Please sign in to comment.