Skip to content

Commit

Permalink
style(design): added country flags
Browse files Browse the repository at this point in the history
  • Loading branch information
thisissamridh committed Jul 4, 2023
1 parent a058bb4 commit 16dfdeb
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 19 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"next-superjson-plugin": "^0.4.9",
"react": "18.2.0",
"react-apexcharts": "^1.4.0",
"react-country-flag": "^3.1.0",
"react-dom": "18.2.0",
"react-icons": "^4.6.0",
"react-swipeable": "^7.0.0",
Expand Down
14 changes: 13 additions & 1 deletion pnpm-lock.yaml

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

49 changes: 35 additions & 14 deletions src/components/Dashboard/Row/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@chakra-ui/react';
import { Inter } from '@next/font/google';
import * as React from 'react';
import ReactCountryFlag from "react-country-flag";
import { FiChevronDown } from 'react-icons/fi';
import { xpType } from '../../../interfaces/xp';
import { projectDataType } from '../../../pages/projects';
Expand All @@ -18,7 +19,7 @@ import CustomTag from '../../HOC/Tag.HOC';
import MedalSVG, { hideMedalOrder } from '../../Logo/MedalSVG';
import { ExpandedProjectRow, ExpandedRow } from './ExpandedRow';
import RowCategories from './RowCategories';

import code from './code.json';
type propTypes = {
row: xpType;
index: number;
Expand All @@ -37,7 +38,12 @@ const TableRow = ({ row, index, sortOrder, searchResult }: propTypes) => {
'superteamGreyLT.50',
'superteamGreyDT.900'
);

const getCountryCode = (countryName: string) => {
const foundCountry = code.find(
(country) => country.countryName === countryName
);
return foundCountry ? foundCountry.countryCode : '';
};
return (
<>
<Tr
Expand Down Expand Up @@ -73,18 +79,31 @@ const TableRow = ({ row, index, sortOrder, searchResult }: propTypes) => {
</Td>
<Td padding="18px">
<Flex flexDir={'column'} w="13rem">
<Text
color={useColorModeValue(
'superteamBlack.100',
'superteamWhite.100'
<Flex flexDir={'row'} w="13rem">
{row?.region && (
<ReactCountryFlag
countryCode={getCountryCode(row.region)}
svg
style={{
width: '1.5em',
height: '1.3em',
marginRight: '0.5em'
}}
/>
)}
fontSize={'14px'}
textTransform="lowercase"
fontWeight="500"
className={inter.className}
>
{row?.name.split('#')[0]}
</Text>
<Text
color={useColorModeValue(
'superteamBlack.100',
'superteamWhite.100'
)}
fontSize={'14px'}
textTransform="lowercase"
fontWeight="500"
className={inter.className}
>
{row?.name.split('#')[0]}
</Text>
</Flex>
<Text
color={useColorModeValue(
'superteamGreyLT.800',
Expand All @@ -96,6 +115,7 @@ const TableRow = ({ row, index, sortOrder, searchResult }: propTypes) => {
{row?.name}
</Text>
</Flex>

</Td>
<Td>
<Flex h={10} w="7rem" flexDir="row" gap="0.4rem">
Expand Down Expand Up @@ -154,7 +174,7 @@ const TableRow = ({ row, index, sortOrder, searchResult }: propTypes) => {
/>
</Center>
</Td>
</Tr>
</Tr >
<ExpandedRow expandRow={expandRow} row={row} />
</>
);
Expand Down Expand Up @@ -241,6 +261,7 @@ export const ProjectsTableRow = ({
</Td>
<Td w={'50rem'} padding="18px">
<Flex flexDir={'column'} w="13rem">

<Text
color={useColorModeValue(
'superteamBlack.100',
Expand Down
29 changes: 25 additions & 4 deletions src/components/Dashboard/Row/TableRowMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
useColorModeValue,
} from '@chakra-ui/react';
import * as React from 'react';
import ReactCountryFlag from "react-country-flag";
import { FiChevronDown } from 'react-icons/fi';
import { xpType } from '../../../interfaces/xp';
import { projectDataType } from '../../../pages/projects';
Expand All @@ -17,7 +18,7 @@ import MedalSVG, { hideMedalOrder } from '../../Logo/MedalSVG';
import { ExpandedProjectRowMobile, ExpandedRowMobile } from './ExpandedRow';
import GraphColumn from './GraphColumn';
import RowCategories from './RowCategories';

import code from './code.json';
type propTypes = {
row: xpType;
index: number;
Expand All @@ -27,6 +28,13 @@ type propTypes = {

const TableRowMobile = ({ row, index, sortOrder, searchResult }: propTypes) => {
const [expandRow, setExpandRow] = React.useState(false);

const getCountryCode = (countryName: string) => {
const foundCountry = code.find(
(country) => country.countryName === countryName
);
return foundCountry ? foundCountry.countryCode : '';
};
return (
<Tr
bg={expandRow ? '#1B1F27' : ''}
Expand All @@ -46,9 +54,22 @@ const TableRowMobile = ({ row, index, sortOrder, searchResult }: propTypes) => {
showIndex={searchResult || hideMedalOrder.includes(sortOrder)}
/>
<Flex gap="0.3rem" direction="column">
<Text color="white" fontSize={'14px'} textTransform="capitalize">
{row?.name.split('#')[0]}
</Text>
<Flex gap="0.3rem" direction="row">

{row?.region && (
<ReactCountryFlag
countryCode={getCountryCode(row.region)}
svg
style={{
width: '1.5em',
height: '1.3em',
}}
/>
)}
<Text color="white" fontSize={'14px'} textTransform="capitalize">
{row?.name.split('#')[0]}
</Text>
</Flex>{' '}
<Text color="rgba(121, 155, 190, 0.47)" fontSize={'12px'}>
{row?.name}
</Text>
Expand Down
26 changes: 26 additions & 0 deletions src/components/Dashboard/Row/code.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"countryName": "Germany",
"countryCode": "DE"
},
{
"countryName": "India",
"countryCode": "IN"
},
{
"countryName": "Mexico",
"countryCode": "MX"
},
{
"countryName": "Turkey",
"countryCode": "TR"
},
{
"countryName": "Vietnam",
"countryCode": "VN"
},
{
"countryName": "United Kingdom",
"countryCode": "GB"
}
]

0 comments on commit 16dfdeb

Please sign in to comment.