-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secondary Dropdown #808
Merged
Merged
Secondary Dropdown #808
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
59200e1
Merge pull request #2 from Ignitus/develop
meghanacosmos 6e26233
Merge pull request #3 from Ignitus/develop
meghanacosmos a6c3771
search bar without filtering functionality
meghanacosmos 5e852ea
added filter functionality
meghanacosmos 606ed0d
minor fixes
meghanacosmos 3a18afd
Merge branch 'develop' into DropDownSec
meghanacosmos f740ff5
removed unused import
meghanacosmos 88d1f5d
Update secondaryDropDown.jsx
meghanacosmos 4d7494a
Update secondaryDropDown.jsx
meghanacosmos 228b6f4
Update secondaryDropDown.jsx
meghanacosmos c1a272f
fixes
meghanacosmos f9f173d
Merge branch 'develop' into DropDownSec
divyanshu-rawat 6d8eb47
Refactoring 🔨
divyanshu-rawat f58b094
Refactoring 🎯
divyanshu-rawat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-secondaryDropDown/Components/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import * as S from '../styles'; | ||
import * as H from '../../typography'; | ||
import { DataType } from '../types'; | ||
|
||
export const SecondaryDropDown = ({ data }) => { | ||
const [showOptions, setShowOptions] = React.useState(false); | ||
const [searchTerm, setSearchTerm] = React.useState(''); | ||
const [searchResults, setSearchResults] = React.useState([] as any); | ||
const handleChange = event => { | ||
setSearchTerm(event.target.value); | ||
setShowOptions(true); | ||
}; | ||
React.useEffect(() => { | ||
const results: [] | DataType = data.filter(person => | ||
person.name | ||
.replace(/\s+/g, '') | ||
.toLowerCase() | ||
.includes(searchTerm.replace(/\s+/g, '').toLowerCase()), | ||
); | ||
setSearchResults(results); | ||
if (searchTerm) { | ||
setShowOptions(true); | ||
} else { | ||
setShowOptions(false); | ||
} | ||
}, [searchTerm]); | ||
|
||
return ( | ||
<S.ParentContainer className="ParentContainer"> | ||
<S.SearchBarWrapper> | ||
<S.SearchBar | ||
type="text" | ||
placeholder="Search..." | ||
onChange={handleChange} | ||
value={searchTerm} | ||
/> | ||
</S.SearchBarWrapper> | ||
{showOptions && ( | ||
<S.OptionsContainer> | ||
{searchResults.map(({ name, avatar }) => ( | ||
<S.CardWrapper key={`${name}`}> | ||
<S.Avatar src={avatar} /> | ||
<S.NameWrapper> | ||
<H.Heading5>{name}</H.Heading5> | ||
</S.NameWrapper> | ||
</S.CardWrapper> | ||
))} | ||
</S.OptionsContainer> | ||
)} | ||
</S.ParentContainer> | ||
); | ||
}; |
60 changes: 60 additions & 0 deletions
60
src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-secondaryDropDown/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import styled from '@emotion/styled'; | ||
import * as C from '../colors'; | ||
import * as F from '../fonts'; | ||
|
||
export const ParentContainer = styled.div` | ||
display: inline-flex; | ||
flex-direction: column; | ||
`; | ||
|
||
export const SearchBarWrapper = styled.div` | ||
width: 20rem; | ||
height: 2rem; | ||
`; | ||
|
||
export const SearchBar = styled.input` | ||
outline: none; | ||
border: 0.1rem solid ${C.IgnitusBlue}; | ||
border-radius: 0.5rem; | ||
width: 20rem; | ||
height: 2rem; | ||
padding-left: 0.25rem; | ||
color: ${C.IgnitusBlue}; | ||
font-weight: ${F.SemiBold}; | ||
&::placeholder { | ||
color: ${C.IgnitusBlue}; | ||
font-weight: ${F.SemiBold}; | ||
} | ||
`; | ||
|
||
export const OptionsContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
margin: 1rem 0.25rem; | ||
background-color: ${C.White}; | ||
overflow: auto; | ||
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1); | ||
border-radius: 0.5rem; | ||
`; | ||
|
||
export const CardWrapper = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-items: baseline; | ||
padding: 0.5rem; | ||
height: 3rem; | ||
:hover { | ||
background-color: ${C.GreyLight}; | ||
} | ||
flex: 1; | ||
`; | ||
|
||
export const Avatar = styled.img` | ||
border-radius: 50%; | ||
width: 2.5rem; | ||
margin: 0 1rem 0 1rem; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
`; | ||
|
||
export const NameWrapper = styled.div` | ||
margin: 0.5rem; | ||
`; |
4 changes: 4 additions & 0 deletions
4
src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-secondaryDropDown/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type DataType = { | ||
avatar: string; | ||
name: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...gnitus-UserInterfaceBook/Components/Atoms/interfaceSecondaryDropdown/Components/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { Interface } from '../../../../styles'; | ||
import { data } from '../constants'; | ||
import { Heading2, SecondaryDropDown } from '../../../../../ignitus-Shared'; | ||
|
||
export const interfaceSecondaryDropDown: React.FC = () => ( | ||
<React.Fragment> | ||
<Interface> | ||
<Heading2>Secondary DropDown</Heading2> | ||
<hr /> | ||
|
||
<SecondaryDropDown data={data} /> | ||
</Interface> | ||
</React.Fragment> | ||
); |
34 changes: 34 additions & 0 deletions
34
src/ignitus-UserInterfaceBook/Components/Atoms/interfaceSecondaryDropdown/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { DataType } from './types'; | ||
|
||
export const data: DataType[] = [ | ||
{ | ||
avatar: | ||
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png', | ||
name: 'Harpar Hopman', | ||
}, | ||
{ | ||
avatar: | ||
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png', | ||
name: 'Hara Hopman', | ||
}, | ||
{ | ||
avatar: | ||
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png', | ||
name: 'Harbour Center', | ||
}, | ||
{ | ||
avatar: | ||
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png', | ||
name: 'Harvard University', | ||
}, | ||
{ | ||
avatar: | ||
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png', | ||
name: 'Henry Harbour', | ||
}, | ||
{ | ||
avatar: | ||
'https://storage.googleapis.com/ignitus_assets/ig-avatars/eugene.png', | ||
name: 'Hara Jackson', | ||
}, | ||
]; |
4 changes: 4 additions & 0 deletions
4
src/ignitus-UserInterfaceBook/Components/Atoms/interfaceSecondaryDropdown/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type DataType = { | ||
avatar: string; | ||
name: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot see your dropdown on this route, so can you please add it. Also, try to add the information on how can we view your new PR, like mentioning the route in this case.