-
Notifications
You must be signed in to change notification settings - Fork 24
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
PORTALS-3385: [CCKP Homepage_V1] Add icons to CCKP cards for data types #1620
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
36a5395
icon click wip
kianamcc e17301a
add clickable icons for icons in iconlist
kianamcc 8971c9d
cleanup
kianamcc fce9cf5
more cleanup
kianamcc d0d83bd
remove unused fct
kianamcc 943de4f
usecallback to be safe for handleiconclick fct
kianamcc 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { useMemo } from 'react' | ||
import IconSvg, { IconSvgProps } from './IconSvg/IconSvg' | ||
import { merge } from 'lodash-es' | ||
import { useQueryContext } from './QueryContext' | ||
import { UniqueFacetIdentifier } from '../utils' | ||
|
||
type IconConfigs = { | ||
[index: string]: IconSvgProps // if the icon option has the "label" set, it will show tooltip in IconSvg | ||
|
@@ -29,6 +31,15 @@ function IconList(props: IconListProps) { | |
let noMatch: boolean = false | ||
const css = useTheme ? 'icon-list themed' : 'icon-list' | ||
const componentCss = useBackground ? `${css} bg-circle` : css | ||
const queryContext = useQueryContext() | ||
const { addValueToSelectedFacet } = queryContext | ||
|
||
const handleIconClick = (dataType: 'string') => { | ||
const facet: UniqueFacetIdentifier = { | ||
columnName: 'dataType', | ||
} | ||
addValueToSelectedFacet(facet, dataType) | ||
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. I verified that addValueToSelectedFacet in TableQueryReducerActions handles the case when the caller attempts to add the same facet value more than once (duplicate value is not pushed). So this should be fine! |
||
} | ||
|
||
const mergedIconConfigs: IconConfigs = useMemo(() => { | ||
const mergedIconConfigs: IconConfigs = {} | ||
|
@@ -47,7 +58,13 @@ function IconList(props: IconListProps) { | |
noMatch = true | ||
return | ||
} else { | ||
return <IconSvg key={el} {...iconConfig} /> | ||
return ( | ||
<IconSvg | ||
key={el} | ||
{...iconConfig} | ||
onClick={() => handleIconClick(el)} | ||
/> | ||
) | ||
} | ||
}) | ||
} | ||
|
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
Oops, something went wrong.
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.
Function is recreated on rerender (I think). Is this a good place for a useCallback? (It's unclear to me if IconSvg is going to be re-rendered when this is recreated)