Skip to content

Commit

Permalink
added bugs updated css for the tables to work better on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Trishadring committed Mar 7, 2022
1 parent fa82c0d commit 3c9a272
Show file tree
Hide file tree
Showing 11 changed files with 10,288 additions and 10,183 deletions.
10,089 changes: 5,044 additions & 5,045 deletions src/Data/bugData.js

Large diffs are not rendered by default.

10,248 changes: 5,124 additions & 5,124 deletions src/Data/fishData.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/components/BugTable/BugTable.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.hideMobile {
display: none;
}
21 changes: 21 additions & 0 deletions src/components/BugTable/BugTable.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";

import { Table, Icon } from "semantic-ui-react";
import './BugTable.css'


export default function BugTable({ bug }) {
return (
<Table.Row key={bug.id} id={bug.id}>
<Table.Cell><Icon name='check' /></Table.Cell>
<Table.Cell>
<img className="photo" src={`/imgs/${bug.img}`} alt={bug.bug_name} />
</Table.Cell>
<Table.Cell>{bug.bug_name}</Table.Cell>
<Table.Cell className="hideMobile">{bug.price}</Table.Cell>
<Table.Cell>{bug.location}</Table.Cell>
<Table.Cell collapsing className="hideMobile">{bug.time}</Table.Cell>
</Table.Row>
)

}
2 changes: 1 addition & 1 deletion src/components/Nav/Nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Nav({ handleLogout, setCurrentHemisphere }) {
console.log(hem, "im clicking");
}
return (
<Menu >
<Menu stackable>
<Menu.Item as='a'>Animal Crossing</Menu.Item>
<Menu.Item link><Link to="/fish">Fish</Link></Menu.Item>
<Menu.Item link><Link to="/bugs">Bugs</Link></Menu.Item>
Expand Down
Empty file removed src/components/bugList/bugList.jsx
Empty file.
11 changes: 7 additions & 4 deletions src/components/fish/fishtable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import './FishTable.css'


export default function FishTable({ fish }) {
function clickHandler() {
console.log(fish, "clicked on this fish")
}
return (
<Table.Row key={fish.id} id={fish.id}>
<Table.Cell><Icon name='check' /></Table.Cell>
<Table.Cell><Icon name='check' onClick={() => clickHandler()} /></Table.Cell>
<Table.Cell>
<img className="photo" src={`/imgs/${fish.img}`} alt={fish.fish_name} />
</Table.Cell>
<Table.Cell>{fish.fish_name}</Table.Cell>
<Table.Cell>{fish.price}</Table.Cell>
<Table.Cell>{fish.shadow_size}</Table.Cell>
<Table.Cell collapsing>{fish.time}</Table.Cell>
<Table.Cell className="mobile hidden">{fish.price}</Table.Cell>
<Table.Cell className="mobile hidden">{fish.shadow_size}</Table.Cell>
<Table.Cell className="mobile hidden">{fish.time}</Table.Cell>
</Table.Row>
)

Expand Down
12 changes: 12 additions & 0 deletions src/pages/App/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,15 @@
transform: rotate(360deg);
}
}

@media only screen and (max-width: 767px) {

[class*="mobile hidden"],
[class*="tablet only"]:not(.mobile),
[class*="computer only"]:not(.mobile),
[class*="large monitor only"]:not(.mobile),
[class*="widescreen monitor only"]:not(.mobile),
[class*="or lower hidden"] {
display: none !important;
}
}
4 changes: 2 additions & 2 deletions src/pages/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import "./App.css";
import SignupPage from "../SignupPage/SignupPage";
import LoginPage from "../LoginPage/LoginPage";
import userService from "../../utils/userService";
import bugData from '../../Data/bugData'
import fishData from '../../Data/fishData'
import Fish from '../Fish/Fish'
import Bugs from '../Bugs/Bugs'
import Loader from '../../components/Loader/Loader'
import { Container } from "semantic-ui-react";
import Nav from '../../components/Nav/Nav'
Expand Down Expand Up @@ -34,6 +33,7 @@ function App() {
<Routes>
<Route path="/" element={<h1>This is Home Page!</h1>} />
<Route path="/fish" element={<Fish currentHemisphere={currentHemisphere} />} />
<Route path="/bugs" element={<Bugs currentHemisphere={currentHemisphere} />} />
<Route
path="/login"
element={<LoginPage handleSignUpOrLogin={handleSignUpOrLogin} />}
Expand Down
65 changes: 65 additions & 0 deletions src/pages/Bugs/Bugs.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { useState, useEffect } from "react";

import { Table, Container } from "semantic-ui-react";
import BugTable from '../../components/BugTable/BugTable'
import Loading from '../../components/Loader/Loader'
import BugData from '../../Data/bugData'

export default function Bug({ currentHemisphere }) {
console.log(BugData, "data")
const [currentBug, setCurrentBug] = useState();
const [loading, setLoading] = useState(true);
async function getData() {
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
const today = new Date();
const currentHour = `h_${today.getHours()}`;
console.log(currentHour)
const currentMonth = months[today.getMonth()];
console.log(currentMonth, "month")
let filterBug = await BugData.filter(function (i) {
return i.time_available[currentHour] === true &&
i.hemisphere[currentHemisphere][currentMonth] === true;
});
console.log(filterBug, "filteredbug")
setCurrentBug(filterBug);
setLoading(() => false);
}
console.log(currentBug, "bug page")
// const allBug = currentBug.map((m, i) => <BugTable key={m.id} {...m} />)

useEffect(() => {
getData();
}, [currentHemisphere]);

if (loading) {
return (
<>
<Loading />
</>
);
}
return (
<Container style={{ maxWidth: 800 }}>
<Table basic striped unstackable>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Caught</Table.HeaderCell>
<Table.HeaderCell></Table.HeaderCell>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell className="mobile hidden">Price</Table.HeaderCell>
<Table.HeaderCell>Location</Table.HeaderCell>
<Table.HeaderCell className="mobile hidden">Avaliable</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{currentBug.map((bug) => {
return (
<BugTable bug={bug} />
);
})}
</Table.Body>
</Table>
</Container>
)

}
16 changes: 9 additions & 7 deletions src/pages/Fish/Fish.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Fish({ currentHemisphere }) {
const currentHour = `h_${today.getHours()}`;
const currentMonth = months[today.getMonth()];
console.log(currentMonth, "month")
let filterFish = await fishData.fishData.filter(function (i) {
let filterFish = await fishData.filter(function (i) {
return i.time_available[currentHour] === true &&
i.hemisphere[currentHemisphere][currentMonth] === true;
});
Expand All @@ -24,7 +24,9 @@ export default function Fish({ currentHemisphere }) {
}
console.log(currentFish, "fish page")
// const allFish = currentFish.map((m, i) => <FishTable key={m.id} {...m} />)
function addCaught() {

}
useEffect(() => {
getData();
}, [currentHemisphere]);
Expand All @@ -38,21 +40,21 @@ export default function Fish({ currentHemisphere }) {
}
return (
<Container style={{ maxWidth: 800 }}>
<Table basic striped>
<Table basic striped unstackable>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Caught</Table.HeaderCell>
<Table.HeaderCell>img</Table.HeaderCell>
<Table.HeaderCell></Table.HeaderCell>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>Price</Table.HeaderCell>
<Table.HeaderCell>Shadow Size</Table.HeaderCell>
<Table.HeaderCell>Avaliable</Table.HeaderCell>
<Table.HeaderCell className="mobile hidden">Price</Table.HeaderCell>
<Table.HeaderCell className="mobile hidden">Shadow Size</Table.HeaderCell>
<Table.HeaderCell className="mobile hidden">Avaliable</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{currentFish.map((fish) => {
return (
<FishTable fish={fish} />
<FishTable fish={fish} addCaught={addCaught} />
);
})}
</Table.Body>
Expand Down

0 comments on commit 3c9a272

Please sign in to comment.