diff --git a/src/App.tsx b/src/App.tsx index 9a294a9..15975af 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,6 +6,7 @@ import { BrowserRouter, Route, Redirect, Switch } from "react-router-dom"; import { AddWord } from "./components/add-word/AddWord"; import { AddShelf } from "./components/add-shelf/AddShelf"; import { CategoryDetails } from "./components/category-details/CategoryDetails"; +import { ShelfDetails } from "./components/shelf-details/ShelfDetails"; function App() { return ( @@ -16,6 +17,7 @@ function App() { + diff --git a/src/components/category-details/CategoryDetails.module.scss b/src/components/category-details/CategoryDetails.module.scss index 467c2f5..a8793e5 100644 --- a/src/components/category-details/CategoryDetails.module.scss +++ b/src/components/category-details/CategoryDetails.module.scss @@ -80,20 +80,20 @@ border-radius: 3rem; padding: 1.5rem; - &:nth-child(5n - 4) { + &:nth-child(5n - 1) { background-color: var(--orange); } - &:nth-child(5n - 3) { + &:nth-child(5n - 2) { background-color: var(--blue); - } + } - &:nth-child(5n - 2) { - background-color: var(--red); + &:nth-child(5n - 3) { + background-color: var(--teal); } - &:nth-child(5n - 1) { - background-color: var(--teal); + &:nth-child(5n - 4) { + background-color: var(--red); } } diff --git a/src/components/category-details/CategoryDetails.tsx b/src/components/category-details/CategoryDetails.tsx index 7b548a8..aa8af4e 100644 --- a/src/components/category-details/CategoryDetails.tsx +++ b/src/components/category-details/CategoryDetails.tsx @@ -11,12 +11,14 @@ import { userProfileData } from "../home/Home"; import { CircularProgressbar } from "react-circular-progressbar"; import { NavLink } from "react-router-dom"; import { IShelf } from "../../structure/shelf"; +import { useHistory } from "react-router-dom"; export const CategoryDetails: React.FC = () => { const location = useLocation(); const category_id: any = queryString.parse(location.pathname)['/category-details/category_id']; const shelfCount: number = userProfileData.categories[category_id].shelves.length; const [shelfResult, setShelfResult] = useState>(userProfileData.categories[category_id].shelves); + const history = useHistory(); const searchShelf = (text: string) => { if (text.length > 0) { @@ -70,8 +72,10 @@ export const CategoryDetails: React.FC = () => {
    - { shelfResult.map(shelf => { - return
  • + { shelfResult.map((shelf, index) => { + return
  • { + history.push('/shelf-details/category_id=' + category_id + '&&shelf_id=' + index); + }}>
    0 ? (shelf.revisedWords.length * 100/ shelf.words.length) : 0} strokeWidth={7} styles={{ diff --git a/src/components/home/Home.tsx b/src/components/home/Home.tsx index bc0dce3..d5ec020 100644 --- a/src/components/home/Home.tsx +++ b/src/components/home/Home.tsx @@ -19,7 +19,7 @@ import { CircularProgressbar } from 'react-circular-progressbar'; import { IProfile } from "../../structure/profile"; import { NavLink } from "react-router-dom"; import { AddCategory } from "../add-category/AddCategory"; - +import { useHistory } from "react-router-dom"; export var userProfileData : IProfile = { name: 'Neymar Jr', @@ -63,6 +63,7 @@ export var userProfileData : IProfile = { export const Home: React.FC = () => { const [isAddCategoryPopupOpen, setAddCategoryPopupState] = useState(false); + const history = useHistory(); return
    @@ -152,17 +153,16 @@ export const Home: React.FC = () => { Active Shelves -
      - { userProfileData.categories.map(category => { - return category.shelves.map(shelf => { - return
    • + { userProfileData.categories.map((category, categoryIndex) => { + return category.shelves.map((shelf, shelfIndex) => { + return
    • { + history.push('/shelf-details/category_id=' + categoryIndex + '&&shelf_id=' + shelfIndex); + } }>
      0 ? (shelf.revisedWords.length * 100/ shelf.words.length) : 0} strokeWidth={7} styles={{ @@ -202,14 +202,16 @@ export const Home: React.FC = () => {
        { userProfileData.categories.map((category, index) => { - return
      • + return
      • { + history.push('/category-details/category_id=' + index); + }}>
        { category.icon }
        - +
        { category.shelves.length } Shelves - +
      • })}
      diff --git a/src/components/shelf-details/ShelfDetails.module.scss b/src/components/shelf-details/ShelfDetails.module.scss new file mode 100644 index 0000000..ea58cf1 --- /dev/null +++ b/src/components/shelf-details/ShelfDetails.module.scss @@ -0,0 +1,40 @@ +.navHeader { + background-color: transparent; + text-align: center; + position: relative; + display: flex; + justify-content: space-between; + align-items: center; + padding: 1rem 1.5rem; + + button { + width: 4rem; + text-align: center; + background-color: transparent; + border: 0; + display: flex; + align-items: center; + justify-content: flex-start; + + svg { + width: 1rem; + color: var(--black); + } + } + + h5 { + font-size: 1.5rem; + } + + figure { + display: block; + + img { + display: block; + width: 4rem; + height: 4rem; + border-radius: 50%; + border: 1px solid var(--creamy-white); + } + } +} \ No newline at end of file diff --git a/src/components/shelf-details/ShelfDetails.tsx b/src/components/shelf-details/ShelfDetails.tsx new file mode 100644 index 0000000..906d4a2 --- /dev/null +++ b/src/components/shelf-details/ShelfDetails.tsx @@ -0,0 +1,27 @@ +import React from "react"; +import styles from './ShelfDetails.module.scss'; +import { ReactComponent as ChevronLeft } from '../../assets/icons/chevron-left.svg'; +import { userProfileData } from "../home/Home"; +import { useLocation } from "react-router-dom"; +import queryString from 'query-string'; + +export const ShelfDetails: React.FC = () => { + const location = useLocation(); + const category_id: any = queryString.parse(location.pathname)['/category-details/category_id']; + const shelf_id: any = queryString.parse(location.pathname)['shelf_id']; + + return
      +
      + + +
      Shelves
      + +
      + {/* eslint-disable-next-line */} + profile-image +
      +
      +
      +} \ No newline at end of file