From 668424d9b586ec1d28da84642e68f5e21f4ab395 Mon Sep 17 00:00:00 2001 From: Amruth Pillai Date: Thu, 16 Apr 2020 19:18:48 +0530 Subject: [PATCH] modify language tab to have both level and rating, update templates --- src/assets/demo/data.json | 43 +++++++++----------- src/components/LeftSidebar/tabs/Languages.js | 38 ++++++++++++----- src/templates/castform/Castform.js | 36 +++++++++------- src/templates/celebi/Celebi.js | 17 +++++--- src/templates/gengar/Gengar.js | 20 +++++---- src/templates/glalie/Glalie.js | 15 ++++--- src/templates/onyx/Onyx.js | 16 +++++--- src/templates/pikachu/Pikachu.js | 15 ++++--- 8 files changed, 123 insertions(+), 77 deletions(-) diff --git a/src/assets/demo/data.json b/src/assets/demo/data.json index eae6abb8..cce87f42 100644 --- a/src/assets/demo/data.json +++ b/src/assets/demo/data.json @@ -66,7 +66,7 @@ "major": "MS in Computer Science", "start": "Sep 2001", "end": "Aug 2002", - "grade": "", + "grade": "7.2 CGPA", "description": "", "enabled": true, "enable": true @@ -77,7 +77,7 @@ "major": "BS in Computer Science", "start": "Sep 1997", "end": "Aug 2001", - "grade": "", + "grade": "8.4 CGPA", "description": "", "enabled": true, "enable": true @@ -131,8 +131,8 @@ }, { "id": "97a1a8d9-3c03-47fb-93ab-e84f864ffe17", - "title": "DCUCI Exam", - "subtitle": "", + "title": "DCUCI 642-999", + "subtitle": "Cisco Systems", "description": "", "enable": true } @@ -158,25 +158,32 @@ "id": "9d34cfcb-c9f0-4d25-ab27-cf81652dd1d0", "key": "English (US)", "value": 5, - "enable": true + "enable": true, + "level": "", + "rating": 5 }, { "id": "3511a86b-7ea9-44ac-8144-6acc7f3bd54f", "key": "Spanish", "value": 4, - "enable": true + "enable": true, + "rating": 4 }, { "id": "d1e17542-f7cc-473a-aa0e-978765907454", - "key": "French", + "key": "Japanese", "value": 4, - "enable": true + "enable": true, + "level": "N4", + "rating": 2 }, { "id": "b1e8442a-7059-4c6f-8a9c-415383133b0e", "key": "German", "value": 3, - "enable": true + "enable": true, + "level": "B1", + "rating": 0 } ] }, @@ -244,24 +251,12 @@ ] }, "data": { - "languages": { - "items": [ - null, - null, - null, - null, - { - "items": [] - } - ] - } + "languages": { "items": [null, null, null, null, { "items": [] }] } } }, "theme": { - "layout": "Gengar", - "font": { - "family": "Montserrat" - }, + "layout": "castform", + "font": { "family": "Montserrat" }, "colors": { "background": "#ffffff", "primary": "#212121", diff --git a/src/components/LeftSidebar/tabs/Languages.js b/src/components/LeftSidebar/tabs/Languages.js index a2a58b1f..30a79bc6 100644 --- a/src/components/LeftSidebar/tabs/Languages.js +++ b/src/components/LeftSidebar/tabs/Languages.js @@ -1,16 +1,16 @@ -import React, { useState, useEffect, useContext } from 'react'; +import set from 'lodash/set'; +import React, { useContext, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { v4 as uuidv4 } from 'uuid'; -import set from 'lodash/set'; -import TextField from '../../../shared/TextField'; import AppContext from '../../../context/AppContext'; +import AddItemButton from '../../../shared/AddItemButton'; import Checkbox from '../../../shared/Checkbox'; import Counter from '../../../shared/Counter'; -import { addItem } from '../../../utils'; import ItemActions from '../../../shared/ItemActions'; -import AddItemButton from '../../../shared/AddItemButton'; import ItemHeading from '../../../shared/ItemHeading'; +import TextField from '../../../shared/TextField'; +import { addItem } from '../../../utils'; const LanguagesTab = ({ data, onChange }) => { const context = useContext(AppContext); @@ -86,12 +86,28 @@ const Form = ({ item, onChange, identifier = '' }) => { onChange={v => onChange(`${identifier}key`, v)} /> + onChange(`${identifier}level`, v)} + /> + item.value > 1 && onChange(`${identifier}value`, item.value - 1)} - onIncrement={() => item.value < 5 && onChange(`${identifier}value`, item.value + 1)} + value={item.rating} + onDecrement={() => + item.rating > 1 + ? onChange(`${identifier}rating`, item.rating - 1) + : onChange(`${identifier}rating`, 0) + } + onIncrement={() => + item.rating < 5 + ? onChange(`${identifier}rating`, item.rating + 1) + : onChange(`${identifier}rating`, 0) + } /> ); @@ -103,7 +119,8 @@ const AddItem = ({ heading, dispatch }) => { id: uuidv4(), enable: true, key: '', - value: 1, + value: '', + rating: 1, }); const onChange = (key, value) => setItem(items => set({ ...items }, key, value)); @@ -117,7 +134,8 @@ const AddItem = ({ heading, dispatch }) => { id: uuidv4(), enable: true, key: '', - value: 1, + value: '', + rating: 1, }); setOpen(false); diff --git a/src/templates/castform/Castform.js b/src/templates/castform/Castform.js index 69195ec4..3ec7ef64 100644 --- a/src/templates/castform/Castform.js +++ b/src/templates/castform/Castform.js @@ -143,22 +143,28 @@ const Castform = () => { const LanguageItem = x => (
-
{x.key}
-
-
-
+
+
{x.key}
+ {x.level !== '' &&
{x.level}
}
+ + {x.rating !== 0 && ( +
+
+
+
+ )}
); diff --git a/src/templates/celebi/Celebi.js b/src/templates/celebi/Celebi.js index 2e548a52..cab5d833 100644 --- a/src/templates/celebi/Celebi.js +++ b/src/templates/celebi/Celebi.js @@ -34,7 +34,7 @@ const Celebi = () => { const Heading = ({ title, className }) => (
{title}
@@ -177,11 +177,16 @@ const Celebi = () => {
{x.key}
- {Array.from(Array(x.value)).map((_, i) => ( - - star - - ))} + {x.level &&
{x.level}
} + {x.rating !== 0 && ( +
+ {Array.from(Array(x.rating)).map((_, i) => ( + + star + + ))} +
+ )}
); diff --git a/src/templates/gengar/Gengar.js b/src/templates/gengar/Gengar.js index c271d26a..ab120b15 100644 --- a/src/templates/gengar/Gengar.js +++ b/src/templates/gengar/Gengar.js @@ -25,8 +25,9 @@ const Gengar = () => { const FullName = () => (
-

{data.profile.firstName}

-

{data.profile.lastName}

+

{data.profile.firstName}

+

{data.profile.lastName}

+
{data.profile.subtitle}
); @@ -196,11 +197,16 @@ const Gengar = () => {
{x.key}
- {Array.from(Array(x.value)).map((_, i) => ( - - star - - ))} + {x.level &&
{x.level}
} + {x.rating !== 0 && ( +
+ {Array.from(Array(x.rating)).map((_, i) => ( + + star + + ))} +
+ )}
); diff --git a/src/templates/glalie/Glalie.js b/src/templates/glalie/Glalie.js index 300a408f..88919614 100644 --- a/src/templates/glalie/Glalie.js +++ b/src/templates/glalie/Glalie.js @@ -195,11 +195,16 @@ const Glalie = () => {
{x.key}
- {Array.from(Array(x.value)).map((_, i) => ( - - star - - ))} + {x.level &&
{x.level}
} + {x.rating !== 0 && ( +
+ {Array.from(Array(x.rating)).map((_, i) => ( + + star + + ))} +
+ )}
); diff --git a/src/templates/onyx/Onyx.js b/src/templates/onyx/Onyx.js index 69134e09..f351381b 100644 --- a/src/templates/onyx/Onyx.js +++ b/src/templates/onyx/Onyx.js @@ -171,11 +171,16 @@ const Onyx = () => {
{x.key}
- {Array.from(Array(x.value)).map((_, i) => ( - - star - - ))} + {x.level &&
{x.level}
} + {x.rating !== 0 && ( +
+ {Array.from(Array(x.rating)).map((_, i) => ( + + star + + ))} +
+ )}
); @@ -255,6 +260,7 @@ const Onyx = () => { value={data.profile.email} link={`mailto:${data.profile.email}`} /> +
diff --git a/src/templates/pikachu/Pikachu.js b/src/templates/pikachu/Pikachu.js index cb498ae3..efb231a6 100644 --- a/src/templates/pikachu/Pikachu.js +++ b/src/templates/pikachu/Pikachu.js @@ -101,11 +101,16 @@ const Pikachu = () => {
{x.key}
- {Array.from(Array(x.value)).map((_, i) => ( - - star - - ))} + {x.level &&
{x.level}
} + {x.rating !== 0 && ( +
+ {Array.from(Array(x.rating)).map((_, i) => ( + + star + + ))} +
+ )}
);