Allow custom metadata to be passed to views
For example,
(A) A Facet view might operate in different modes, e.g., compressed, or show/hide icons. Today, to accomplish that it is necessary to name each component in accordance with it's variation, e.g.:
const SearchMultiIconFacetsView = (props: FacetViewProps & Props) => {
...
}
export const SearchMultiIconFacetsViewLogos = (props: any) => (
<SearchMultiIconFacetsView {...props} logos />
);
export const SearchMultiIconFacetsViewCompressed = (props: any) => (
<SearchMultiIconFacetsView {...props} compressed />
);
export const SearchMultiIconFacetsViewCompressedLogos = (props: any) => (
<SearchMultiIconFacetsView {...props} compressed logos />
);
As another example,
(B) It seems that the field used to create the facet is not passed as a prop to a custom Facet view. This is useful for customizing the view based on the field. e.g., the "Product" facet view might have icons that need to be loaded.
It would be helpful if we could pass this sort of data as props to the end view component, or some metadata object as a prop. e.g.,
<Facet
field="priority"
filterType="all"
label={priority}
view={SearchMultiIconFacetsView}
meta={{field: 'priority', compressed: true, logos: true}}
/>
Hey @PhaedrusTheGreek. I think that all properties you pass to the Facet component will ultimately get passed down to the view, can you try it out to confirm?
Meaning, if you pass meta as you do above, it should be passed through to your view for you to use.
Another approach you could take is something like this:
<Facet
field="priority"
filterType="all"
label={priority}
view={props => {
return <SearchMultiIconFacetsView {...props} meta={{field: 'priority', compressed: true, logos: true}} />
}}
/>
Do you think either of those solutions would work for you?
Thanks. Option 1 doesn't seem to work due to TS issues, but the 2nd approach works well, thank you!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Is this issue still important to you? If so, please leave a comment and let us know. As always, thank you for your contributions.