Skip to content

Commit

Permalink
feat: story now scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
ridhoperdana-wartek committed Dec 18, 2024
1 parent c1163f5 commit 40789a6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
9 changes: 9 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"react-lazyload": "^3.2.1",
"react-redux": "^9.1.2",
"react-router-dom": "^7.0.2",
"react-swipeable": "^7.0.2",
"react-toastify": "^10.0.6",
"redux": "^5.0.1",
"tailwindcss": "^3.4.16"
Expand Down
12 changes: 7 additions & 5 deletions src/AnimalStory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ const AnimalStory = () => {
</div>

{stories.map((story) => (
<div key={story.id} className='mb-4 flex-grow p-8 w-5/6 max-w-lg p-8 bg-white border-4 flex flex-col items-center mb-4 rounded-xl shadow-lg place-self-center'>
<h1 className="text-2xl font-bold mb-4">{story.animalName}</h1>
{story.stories.map((value, index) => (
<p key={index} className="mt-4">{value}</p>
))}
<div className="w-full" key={story.id}>
<h1 className="text-2xl font-bold mb-4 ml-8">{story.animalName}</h1>
<div className="mb-4 flex flex-row overflow-x-auto w-screen place-self-center">
{story.stories.map((value, index) => (
<div key={value} className='min-w-80 m-4 p-8 bg-white border-4 mb-4 rounded-xl shadow-lg place-self-center'><p key={index}>{value}</p></div>
))}
</div>
</div>
))};

Expand Down
6 changes: 5 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, {useEffect, useState} from 'react';
import { BrowserRouter as Router, Route, Routes, Link, useLocation, BrowserRouter } from 'react-router-dom';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
Expand All @@ -11,6 +11,10 @@ const App = () => {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const location = useLocation();

useEffect(() => {
setIsMenuOpen(false);
}, [location.pathname]);

return (
<div className="flex flex-col items-center min-h-screen bg-blue-50">
<ToastContainer />
Expand Down

0 comments on commit 40789a6

Please sign in to comment.