π Click here to see on browser
What's used in this app ? | How use third party libraries | Author |
---|---|---|
React - component | Take a look at my portfolio | |
React - props | Visit me on Linkedin | |
React - sass | npm i sass or yarn add sass:1 | |
Deploy with GitHub Pages |
yarn create react-app . or npx create-react-app .
yarn add sass or npm i sass
- App.test.js
- reportWebVitals.js
- setupTests.js
- favicon.ico
- logo192.png
- logo512.png
- manifest.json
- robots.txt
yarn start or npm start
OR
-
Clone the Repo
git clone
-
Install NPM packages
npm install or yarn
-
Run the project
npm start or yarn start
-
Open the project on your browser
http://localhost:3000/
Horoscope App(folder)
|
|----public (folder)
β βββ index.html
|----src (folder)
| |--- components (folder)
| | |ββ header(folder)
β β | βββ Header.jsx
β β | βββ Header.scss
β β | βββ Header.css
β β |
| | |ββ main(folder)
β β | βββ Main.jsx
β β | βββ Main.scss
β β | βββ Main.css
β β | βββ Card.jsx
β β |
| | |ββ navbar(folder)
β β βββ Navbar.jsx
β β βββ Navbar.scss
β β βββ Navbar.css
β β
| |--- helper (folder)
| | |ββ data.js
β β |ββ logo.png
β β
β |--- scss (folder)
| | βββ _reset.scss
| | βββ _mixins.scss
| | βββ _variables.scss
| |
| |
β β--- App.js
β β--- App.scss
β β--- App.css
β β--- data.js
β β--- index.js
β
β
|--- .gitignore
|ββ package-lock.json
βββ package.json
|ββ README.md
|ββ yarn.lock
-
sass with react
// src/scss/_reset.scss * { margin: 0; padding: 0; box-sizing: border-box; } // src/scss/_variables.scss //? Colors $backgroundColor:#ace0f9; $cardNavBgColor: #171b20; // src/scss/_mixins.scss @mixin media-xsm { @media screen and (min-width: 0px) { @content; } } @mixin media-sm { @media screen and (min-width: 576px) { @content; } } // src/scss/app.scss @import './scss/reset', './scss/variables'; @import url('https://fonts.googleapis.com/css2?family=Amatic+SC:wght@700&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Hubballi&display=swap'); body{ background-color: $backgroundColor; font-family: 'Amatic SC', cursive; } p{ font-family: 'Hubballi', cursive; }
-
Parent Component icinde json datayi map() leme
// src/components/main/Main.jsx Parent component import { data } from "../../helpers/data"; import "./Main.scss"; import Card from "./Card"; const Main = () => { // console.log(data); return ( <div className="card-container"> {data.map((item, i) => ( // !props // ?asagi data gΓΆndermenin 1.yolu // <Card item={item} /> // bΓΆyle gΓΆnderirsek diger tarafta props.item.title seklinde yakalamaliyim // ?asagi data gΓΆndermenin 2.yolu <Card key={item.id} {...item} /> ))} </div> ); }; export default Main; // src/components/main/Card.jsx Child component const Card = (data) => { // console.log("ne geliyo", data); const { id, title, image, desc } = data; return ( <div key={id} className="cards"> <div className="title"> <h1>{title}</h1> </div> <img src={image} alt="" /> <div className="card-over"> <p>{desc}</p> </div> </div> ); }; export default Card;
-
Deploy with GitHub Pages
// src
npm i gh-pages or yarn add gh-pages
// src/package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "yarn run build",
"deploy": "gh-pages -d build"
},
π» add github.io link as homepage: "homepage": "https://kaplanh.github.io/horoscope_app", π
// src/package.json
{
"homepage": "https://kaplanh.github.io/horoscope_app",
"name": "horoscope_app",
"version": "0.1.0",
"private": true,
"dependencies": {
"gh-pages": "^6.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"sass": "^1.70.0"
},
yarn run deploy or npm run deploy
https://kaplanh.github.io/horoscope_app
-
Image ΓΌzerine geldiginde alttan yukari dogru scrolsΓΌz metin kaydirma
const Card = ({ title, date, image, desc }) => { // const { title, date, image, desc } = props; // console.log("ne geliyor", props); return ( <div className="cards"> <div className="title"> <h1>{title}</h1> </div> <div className="date"> <h2>{date}</h2> </div> <img src={image} alt="" /> <div className="card-over"> <p>{desc}</p> </div> </div> ); };
.cards { width: 500px; height: 350px; position: relative; overflow: hidden; &:hover .card-over { transform: translate(0%); } &:hover img { opacity: 1; } .card-over { width: 500px; position: absolute; bottom: 0; left: 0; background-color: rgba(0, 0, 0, 0.8); font-size: 1.5rem; z-index: 3; padding: 1rem; transform: translateY(100%); transition: transform 0.7s; max-height: 75%; overflow: auto; // ?scrollbari kaybetmek icin &::-webkit-scrollbar{ display: none; } } }
I value your feedback and suggestions. If you have any comments, questions, or ideas for improvement regarding this project or any of my other projects, please don't hesitate to reach out. I'm always open to collaboration and welcome the opportunity to work on exciting projects together. Thank you for visiting my project. I hope you have a wonderful experience exploring it, and I look forward to connecting with you soon!
β Happy Coding β
Footnotes
-
- App.js de bu sekilde import edilmeli import './App.scss';