reactivesearch icon indicating copy to clipboard operation
reactivesearch copied to clipboard

How To Create My Own Component in Reactivesearch??

Open ashwini987 opened this issue 9 years ago • 9 comments

Hello Everyone, I want to create my own component in Reactivesearch which is same as a "MultiList". I just want to change the name of component and functionality of it same as a "MultiList" because of I want to apply external CSS on it but it's apply on all. Can you provide me some help regarding it?? Thanks Regards.

ashwini987 avatar Oct 24 '17 11:10 ashwini987

@ashwini987 not sure I understand the use-case. Why can't you use the style prop or className prop of MultiList?

siddharthlatest avatar Oct 24 '17 11:10 siddharthlatest

Can you please give me example of it, to provide style prop or className prop on component?? Because I can understand what you say, but I don't konw how to apply it.

ashwini987 avatar Oct 24 '17 12:10 ashwini987

@ashwini987 Here is an example where I am using the style prop with MultiList https://codepen.io/sids-aquarius/pen/OxePea?editors=0010.

You can also see a code section about the props in the docs. className is a similar prop that can be used if you want to inject a CSS class's styles into the component.

siddharthlatest avatar Oct 24 '17 12:10 siddharthlatest

i want to create own custom component ColorList like MultList and in that i want to apply my own html , css whtever i want to lookwise.
*****How can i create own custom component ColorList ??? ***** i want create component like this below image 2

right now i use MultiList show it look like this image 3

ashwini987 avatar Oct 25 '17 09:10 ashwini987

@ashwini987 Okay, you can do that with DataController https://opensource.appbase.io/reactive-manual/v1/components/DataController.html.

The dataLabel prop allows you to define the HTML markup. style, className props can used to define the styles, and you can use the customQuery prop to construct the query.

Does this help?

siddharthlatest avatar Oct 25 '17 09:10 siddharthlatest

No it doesn't help.

  1. how can i create my own custom ColorList component ???

2 ) i want to show color image on checkbox. how can i do that ?? this the image of colour filter in that there is jpg imge for all colours behind the checkboxs.

image 5

  1. i want price filter like that right now only rangesilder is there but i want to below like that can we have something like this or create like this ??

image 6

ashwini987 avatar Oct 25 '17 11:10 ashwini987

For 1.) and 2.) you can add your own render() markup in the dataLabel prop. The checkbox and jpeg images are how you want the component to look, you can define it there.

For 3.), the RangeSlider component supports the slider (like you mention), but doesn't support an input box filter to select the values right now.

siddharthlatest avatar Oct 25 '17 15:10 siddharthlatest

can you provide example of how to i add my own render() markup in the dataLabel prop ??? OR can i apply jpeg imge or color code on multilist colour data. or there is any prop that i pass jpeg img or colur code that is comes from my api ??

ashwini987 avatar Oct 26 '17 07:10 ashwini987

You can pass a valid JSX in the dataLabel which may look something like this:

<div>
    <a onClick={() => this.setColor("red")}>Red color image or whatever you wish to render</a>
    <a onClick={() => this.setColor("yellow")}>Yellow color image or whatever you wish to render</a>
    .... more colors
</div>

The setColor() should update the selectedColor value in the parent component's state, which is passed as a defaultSelected prop to the DataController with a customQuery prop to compute the query based on the given color as a parameter.

<DataController 
    componentId="ColorPicker"
    defaultSelected={this.state.selectedColor}
    customQuery={this.yourCustomQuery}
    dataLabel={<div>...</div>}
/>

So essentially, you need to update the defaultSelected prop on every color selection here.

Refer docs for more details

metagrover avatar Oct 26 '17 07:10 metagrover