Skip to content

Commit f58b094

Browse files
Refactoring 🎯
1 parent 6d8eb47 commit f58b094

File tree

6 files changed

+33
-36
lines changed

6 files changed

+33
-36
lines changed

src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-secondaryDropDown/Components/index.tsx

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import * as S from '../styles';
33
import * as H from '../../typography';
4-
import { Details } from '../constants';
4+
import { DataType } from '../types';
55

6-
export const SecondaryDropDown: React.FC = () => {
6+
export const SecondaryDropDown = ({ data }) => {
77
const [showOptions, setShowOptions] = React.useState(false);
88
const [searchTerm, setSearchTerm] = React.useState('');
99
const [searchResults, setSearchResults] = React.useState([] as any);
@@ -12,14 +12,12 @@ export const SecondaryDropDown: React.FC = () => {
1212
setShowOptions(true);
1313
};
1414
React.useEffect(() => {
15-
const results =
16-
[] ||
17-
Details.filter(person =>
18-
person.name
19-
.replace(/\s+/g, '')
20-
.toLowerCase()
21-
.includes(searchTerm.replace(/\s+/g, '').toLowerCase()),
22-
);
15+
const results: [] | DataType = data.filter(person =>
16+
person.name
17+
.replace(/\s+/g, '')
18+
.toLowerCase()
19+
.includes(searchTerm.replace(/\s+/g, '').toLowerCase()),
20+
);
2321
setSearchResults(results);
2422
if (searchTerm) {
2523
setShowOptions(true);
@@ -40,11 +38,11 @@ export const SecondaryDropDown: React.FC = () => {
4038
</S.SearchBarWrapper>
4139
{showOptions && (
4240
<S.OptionsContainer>
43-
{searchResults.map(person => (
44-
<S.CardWrapper key={`${person.name}`}>
45-
<S.Avatar src={person.avatarLink} />
41+
{searchResults.map(({ name, avatar }) => (
42+
<S.CardWrapper key={`${name}`}>
43+
<S.Avatar src={avatar} />
4644
<S.NameWrapper>
47-
<H.Heading5>{person.name}</H.Heading5>
45+
<H.Heading5>{name}</H.Heading5>
4846
</S.NameWrapper>
4947
</S.CardWrapper>
5048
))}

src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-secondaryDropDown/styles.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,21 @@ import * as C from '../colors';
33
import * as F from '../fonts';
44

55
export const ParentContainer = styled.div`
6-
display: flex;
6+
display: inline-flex;
77
flex-direction: column;
8-
width: 20rem;
9-
margin: 2rem;
10-
max-height: 20rem;
118
`;
129

1310
export const SearchBarWrapper = styled.div`
1411
width: 20rem;
15-
height: 3rem;
12+
height: 2rem;
1613
`;
1714

1815
export const SearchBar = styled.input`
1916
outline: none;
2017
border: 0.1rem solid ${C.IgnitusBlue};
2118
border-radius: 0.5rem;
2219
width: 20rem;
23-
height: 2.5rem;
20+
height: 2rem;
2421
padding-left: 0.25rem;
2522
color: ${C.IgnitusBlue};
2623
font-weight: ${F.SemiBold};
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
export type SecondaryDropDownProps = {
2-
label: string;
3-
options: string[];
4-
display: string;
1+
export type DataType = {
2+
avatar: string;
3+
name: string;
54
};
6-
7-
// export type DropDownProps = {
8-
// display: string;
9-
// };
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { Interface } from '../../../../styles';
3+
import { data } from '../constants';
34
import { Heading2, SecondaryDropDown } from '../../../../../ignitus-Shared';
45

56
export const interfaceSecondaryDropDown: React.FC = () => (
@@ -8,7 +9,7 @@ export const interfaceSecondaryDropDown: React.FC = () => (
89
<Heading2>Secondary DropDown</Heading2>
910
<hr />
1011

11-
<SecondaryDropDown />
12+
<SecondaryDropDown data={data} />
1213
</Interface>
1314
</React.Fragment>
1415
);

src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-secondaryDropDown/constants.ts src/ignitus-UserInterfaceBook/Components/Atoms/interfaceSecondaryDropdown/constants.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
export const Details = [
1+
import { DataType } from './types';
2+
3+
export const data: DataType[] = [
24
{
3-
avatarLink:
5+
avatar:
46
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png',
57
name: 'Harpar Hopman',
68
},
79
{
8-
avatarLink:
10+
avatar:
911
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png',
1012
name: 'Hara Hopman',
1113
},
1214
{
13-
avatarLink:
15+
avatar:
1416
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png',
1517
name: 'Harbour Center',
1618
},
1719
{
18-
avatarLink:
20+
avatar:
1921
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png',
2022
name: 'Harvard University',
2123
},
2224
{
23-
avatarLink:
25+
avatar:
2426
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png',
2527
name: 'Henry Harbour',
2628
},
2729
{
28-
avatarLink:
30+
avatar:
2931
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png',
3032
name: 'Hara Jackson',
3133
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type DataType = {
2+
avatar: string;
3+
name: string;
4+
};

0 commit comments

Comments
 (0)