Bläddra i källkod

moved data to app.tsx for better usage and centralization

master
kj1352 4 år sedan
förälder
incheckning
2d2cb56866
14 ändrade filer med 122 tillägg och 83 borttagningar
  1. +50
    -0
      src/App.tsx
  2. +1
    -1
      src/components/add-category/AddCategory.tsx
  3. +4
    -4
      src/components/add-shelf/AddShelf.module.scss
  4. +1
    -1
      src/components/add-shelf/AddShelf.tsx
  5. +4
    -4
      src/components/add-word/AddWord.module.scss
  6. +1
    -1
      src/components/add-word/AddWord.tsx
  7. +4
    -4
      src/components/categories/Categories.module.scss
  8. +2
    -3
      src/components/categories/Categories.tsx
  9. +4
    -4
      src/components/category-details/CategoryDetails.module.scss
  10. +1
    -1
      src/components/category-details/CategoryDetails.tsx
  11. +12
    -12
      src/components/home/Home.module.scss
  12. +1
    -45
      src/components/home/Home.tsx
  13. +13
    -3
      src/components/shelf-details/ShelfDetails.tsx
  14. +24
    -0
      src/data/all-words.ts

+ 50
- 0
src/App.tsx Visa fil

@@ -8,6 +8,56 @@ import { AddShelf } from "./components/add-shelf/AddShelf";
import { CategoryDetails } from "./components/category-details/CategoryDetails";
import { ShelfDetails } from "./components/shelf-details/ShelfDetails";

import { ReactComponent as BookMarkIcon } from './assets/icons/bookmark.svg';
import { ReactComponent as PersonSpeakerIcon } from './assets/icons/user-speaker.svg';
import { ReactComponent as BrainIcon } from './assets/icons/bx-brain.svg';
import { ReactComponent as InternBadge } from './assets/icons/intern-badge.svg';
import { ReactComponent as TimeIcon } from './assets/icons/time.svg';

import { IProfile } from "./structure/profile";
import { ALL_WORDS } from "./data/all-words";


export var userProfileData : IProfile = {
name: 'Neymar Jr',
image: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSERA5Pm3aRBV7AaI8tvpZfzpD24ZgrU1_8NA&usqp=CAU',
medal: {
name: 'Intern badge',
minValue: 0,
maxValue: 100,
icon: <InternBadge />
},
categories: [{
name: 'Vocabulary',
icon: <TimeIcon />,
shelves: [{
name: 'All Words',
words: [ALL_WORDS[0], ALL_WORDS[1], ALL_WORDS[2], ALL_WORDS[3]],
revisedWords: [ALL_WORDS[1]],
description: 'All Words that I use on a daily basis',
viewPermission: 'PUBLIC'
}]
}, {
name: 'Books',
icon: <BookMarkIcon />,
shelves: [{
name: 'Sapiens',
words: [ALL_WORDS[3]],
revisedWords: [ALL_WORDS[3]],
description: 'Sapiens book complex words',
viewPermission: 'PUBLIC'
}]
}, {
name: 'GRE',
icon: <BrainIcon />,
shelves: []
}, {
name: 'ELTS',
icon: <PersonSpeakerIcon />,
shelves: []
}]
};

function App() {
return (
<BrowserRouter>


+ 1
- 1
src/components/add-category/AddCategory.tsx Visa fil

@@ -6,7 +6,7 @@ import { ReactComponent as TimeIcon } from '../../assets/icons/time.svg';
import { ReactComponent as TimerIcon } from '../../assets/icons/timer.svg';
import { ReactComponent as TextIcon } from '../../assets/icons/text.svg';
import { ICategory } from "../../structure/category";
import { userProfileData } from "../home/Home";
import { userProfileData } from "../../App";

type ownProps = {
hidePopup: () => void


+ 4
- 4
src/components/add-shelf/AddShelf.module.scss Visa fil

@@ -149,19 +149,19 @@
}
}

&:nth-child(5n - 4) .icon {
&:nth-child(4n - 4) .icon {
background-color: var(--orange);
}

&:nth-child(5n - 3) .icon {
&:nth-child(4n - 3) .icon {
background-color: var(--blue);
}

&:nth-child(5n - 2) .icon {
&:nth-child(4n - 2) .icon {
background-color: var(--red);
}

&:nth-child(5n - 1) .icon {
&:nth-child(4n - 1) .icon {
background-color: var(--teal);
}
}


+ 1
- 1
src/components/add-shelf/AddShelf.tsx Visa fil

@@ -3,8 +3,8 @@ import styles from './AddShelf.module.scss';
import { ReactComponent as CloseIcon } from '../../assets/icons/close.svg';
import { ReactComponent as PlusIcon } from '../../assets/icons/plus.svg';
import { ReactComponent as CheckCircle } from '../../assets/icons/check.svg';
import { userProfileData } from "../home/Home";
import { IShelf } from "../../structure/shelf";
import { userProfileData } from "../../App";

export const AddShelf: React.FC = () => {
const [selectedCategoryIndex, setCategoryIndex] = useState<number>();


+ 4
- 4
src/components/add-word/AddWord.module.scss Visa fil

@@ -233,19 +233,19 @@
align-items: center;
margin: 0 0 2rem;

&:nth-child(5n - 4) .icon {
&:nth-child(4n - 4) .icon {
background-color: var(--red);
}

&:nth-child(5n - 3) .icon {
&:nth-child(4n - 3) .icon {
background-color: var(--orange);
}

&:nth-child(5n - 2) .icon {
&:nth-child(4n - 2) .icon {
background-color: var(--blue);
}

&:nth-child(5n - 1) .icon {
&:nth-child(4n - 1) .icon {
background-color: var(--teal);
}
}


+ 1
- 1
src/components/add-word/AddWord.tsx Visa fil

@@ -7,8 +7,8 @@ import { ReactComponent as AddIcon } from '../../assets/icons/plus.svg';

import { IWord } from "../../structure/word";
import { ALL_WORDS } from "../../data/all-words";
import { userProfileData } from "../home/Home";
import { NavLink } from "react-router-dom";
import { userProfileData } from "../../App";

export const AddWord: React.FC = () => {
const [searchWordResult, setSearchResult] = useState<Array<IWord>>([]);


+ 4
- 4
src/components/categories/Categories.module.scss Visa fil

@@ -145,19 +145,19 @@ $block-padding: 2.5rem 2rem;
justify-content: space-between;
align-items: center;

&:nth-child(5n - 4) .icon {
&:nth-child(4n - 4) .icon {
background-color: var(--orange);
}

&:nth-child(5n - 3) .icon {
&:nth-child(4n - 3) .icon {
background-color: var(--blue);
}

&:nth-child(5n - 2) .icon {
&:nth-child(4n - 2) .icon {
background-color: var(--red);
}

&:nth-child(5n - 1) .icon {
&:nth-child(4n - 1) .icon {
background-color: var(--teal);
}
}


+ 2
- 3
src/components/categories/Categories.tsx Visa fil

@@ -3,11 +3,10 @@ import styles from './Categories.module.scss';
import { ReactComponent as LogoIcon } from '../../assets/icons/anamnesis.svg';
import { ReactComponent as SearchIcon } from '../../assets/icons/bx-search-alt.svg';
import { ReactComponent as PlusCircledIcon } from '../../assets/icons/plus-circle.svg';

import { userProfileData } from "../home/Home";
import { NavLink } from "react-router-dom";
import { ICategory } from "../../structure/category";
import { AddCategory } from "../add-category/AddCategory";
import { userProfileData } from "../../App";

export const Categories: React.FC = () => {
const [categoryResult, setCategories] = useState<Array<ICategory>>(userProfileData.categories);
@@ -36,7 +35,7 @@ export const Categories: React.FC = () => {
<header className={styles.tabHeading}>
<h4> Categories </h4>
<p> 4 Types </p>
<p> { userProfileData.categories.length } Types </p>
</header>
<section className={styles.searchHolder}>


+ 4
- 4
src/components/category-details/CategoryDetails.module.scss Visa fil

@@ -80,19 +80,19 @@
border-radius: 3rem;
padding: 1.5rem;

&:nth-child(5n - 1) {
&:nth-child(4n - 1) {
background-color: var(--orange);
}

&:nth-child(5n - 2) {
&:nth-child(4n - 2) {
background-color: var(--blue);
}

&:nth-child(5n - 3) {
&:nth-child(4n - 3) {
background-color: var(--teal);
}

&:nth-child(5n - 4) {
&:nth-child(4n - 4) {
background-color: var(--red);
}
}


+ 1
- 1
src/components/category-details/CategoryDetails.tsx Visa fil

@@ -7,11 +7,11 @@ import { ReactComponent as SearchIcon } from '../../assets/icons/bx-search-alt.s
import { ReactComponent as MoreIcon } from '../../assets/icons/more-alt.svg';
import { ReactComponent as PlusCircledIcon } from '../../assets/icons/plus-circle.svg';

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";
import { userProfileData } from "../../App";

export const CategoryDetails: React.FC = () => {
const location = useLocation();


+ 12
- 12
src/components/home/Home.module.scss Visa fil

@@ -161,19 +161,19 @@ $block-padding: 0 2rem;
align-items: center;
margin: 2rem 0;

&:nth-child(5n - 4) .icon {
&:nth-child(4n - 4) .icon {
background-color: var(--red);
}

&:nth-child(5n - 3) .icon {
&:nth-child(4n - 3) .icon {
background-color: var(--orange);
}

&:nth-child(5n - 2) .icon {
&:nth-child(4n - 2) .icon {
background-color: var(--blue);
}

&:nth-child(5n - 1) .icon {
&:nth-child(4n - 1) .icon {
background-color: var(--teal);
}
}
@@ -255,19 +255,19 @@ $block-padding: 0 2rem;
border-radius: 3rem;
padding: 1.5rem;

&:nth-child(5n - 4) {
&:nth-child(4n - 4) {
background-color: var(--orange);
}

&:nth-child(5n - 3) {
&:nth-child(4n - 3) {
background-color: var(--blue);
}

&:nth-child(5n - 2) {
&:nth-child(4n - 2) {
background-color: var(--red);
}

&:nth-child(5n - 1) {
&:nth-child(4n - 1) {
background-color: var(--teal);
}
}
@@ -305,19 +305,19 @@ $block-padding: 0 2rem;
align-items: center;
margin: 2rem 0;

&:nth-child(5n - 4) .icon {
&:nth-child(4n - 4) .icon {
background-color: var(--orange);
}

&:nth-child(5n - 3) .icon {
&:nth-child(4n - 3) .icon {
background-color: var(--blue);
}

&:nth-child(5n - 2) .icon {
&:nth-child(4n - 2) .icon {
background-color: var(--red);
}

&:nth-child(5n - 1) .icon {
&:nth-child(4n - 1) .icon {
background-color: var(--teal);
}
}


+ 1
- 45
src/components/home/Home.tsx Visa fil

@@ -3,7 +3,6 @@ import styles from './Home.module.scss';
import { ReactComponent as LogoIcon } from '../../assets/icons/anamnesis.svg';
import { ReactComponent as SearchIcon } from '../../assets/icons/bx-search-alt.svg';
import { ReactComponent as BookIcon } from '../../assets/icons/readme.svg';
import { ReactComponent as BookMarkIcon } from '../../assets/icons/bookmark.svg';
import { ReactComponent as BookShelfIcon } from '../../assets/icons/bookshelf.svg';
import { ReactComponent as CalendarIcon } from '../../assets/icons/bx-calendar.svg';
import { ReactComponent as TimeIcon } from '../../assets/icons/time.svg';
@@ -12,54 +11,11 @@ import { ReactComponent as CheckCircleIcon } from '../../assets/icons/check-circ
import { ReactComponent as ExpandIcon } from '../../assets/icons/expand.svg';
import { ReactComponent as PlusIcon } from '../../assets/icons/plus.svg';
import { ReactComponent as GridIcon } from '../../assets/icons/circled.svg';
import { ReactComponent as PersonSpeakerIcon } from '../../assets/icons/user-speaker.svg';
import { ReactComponent as BrainIcon } from '../../assets/icons/bx-brain.svg';
import { ReactComponent as InternBadge } from '../../assets/icons/intern-badge.svg';
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',
image: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSERA5Pm3aRBV7AaI8tvpZfzpD24ZgrU1_8NA&usqp=CAU',
medal: {
name: 'Intern badge',
minValue: 0,
maxValue: 100,
icon: <InternBadge />
},
categories: [{
name: 'Vocabulary',
icon: <TimeIcon />,
shelves: [{
name: 'All Words',
words: [],
revisedWords: [],
description: 'All Words that I use on a daily basis',
viewPermission: 'PUBLIC'
}]
}, {
name: 'Books',
icon: <BookMarkIcon />,
shelves: [{
name: 'Sapiens',
words: [],
revisedWords: [],
description: 'Sapiens book complex words',
viewPermission: 'PUBLIC'
}]
}, {
name: 'GRE',
icon: <BrainIcon />,
shelves: []
}, {
name: 'ELTS',
icon: <PersonSpeakerIcon />,
shelves: []
}]
};
import { userProfileData } from "../../App";

export const Home: React.FC = () => {
const [isAddCategoryPopupOpen, setAddCategoryPopupState] = useState<Boolean>(false);


+ 13
- 3
src/components/shelf-details/ShelfDetails.tsx Visa fil

@@ -1,14 +1,18 @@
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';
import { ICategory } from "../../structure/category";
import { IShelf } from "../../structure/shelf";
import { userProfileData } from "../../App";

export const ShelfDetails: React.FC = () => {
const location = useLocation();
const category_id: any = queryString.parse(location.pathname)['/category-details/category_id'];
const category_id: any = queryString.parse(location.pathname)['/shelf-details/category_id'];
const shelf_id: any = queryString.parse(location.pathname)['shelf_id'];
const category: ICategory = userProfileData.categories[category_id];
const shelf: IShelf = category.shelves[shelf_id];
return <section className="modalPage">
<header className={styles.navHeader}>
@@ -16,12 +20,18 @@ export const ShelfDetails: React.FC = () => {
<ChevronLeft />
</button>
<h5> Shelves </h5>
<h5> { category.name } </h5>

<figure>
{/* eslint-disable-next-line */}
<img src={ userProfileData.image } alt="profile-image" />
</figure>
</header>
<header className={styles.tabHeading}>
<h4> { shelf.name } </h4>
<p> { shelf.words.length } </p>
</header>

</section>
}

+ 24
- 0
src/data/all-words.ts Visa fil

@@ -24,4 +24,28 @@ export const ALL_WORDS: Array<IWord> = [{
description: 'used in polite requests or questions.'
}],
similarWords: ['Nice', 'Agreeable', 'Pleasant', 'Satisfying', 'Gratifying'],
}, {
name: 'Prudent',
pronounciation: '/ˈpruːd(ə)nt/',
audioPronounciationURL: '',
grammaticalDetails: [{
typeName: 'ADJECTIVE',
description: 'acting with or showing care and thought for the future.'
}],
similarWords: ['Wise', 'Well judged', 'Judicious', 'Sage', 'Shrewd'],
}, {
name: 'Ping',
pronounciation: '/pɪŋ/',
audioPronounciationURL: '',
grammaticalDetails: [{
typeName: 'NOUN',
description: 'a short, high-pitched ringing sound.'
}, {
typeName: 'VERB',
description: 'query (another computer on a network) to determine whether there is a connection to it.'
}, {
typeName: 'VERB',
description: 'make or cause to make a short, high-pitched ringing sound.'
}],
similarWords: [''],
}]

Laddar…
Avbryt
Spara