Skip to content

Commit

Permalink
Merge pull request #130 from appbaseio/feat/image-search
Browse files Browse the repository at this point in the history
Feat/image search
  • Loading branch information
mohdashraf010897 authored Oct 18, 2023
2 parents bf5a008 + e9534ed commit 0642403
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"homepage": "https://github.com/appbaseio/reactive-playground#readme",
"dependencies": {
"@appbaseio/reactivemaps": "4.0.0",
"@appbaseio/reactivesearch": "4.1.0",
"@appbaseio/reactivesearch": "4.2.0-alpha.6",
"docs": "appbaseio/Docs#dev",
"moment": "^2.29.1",
"react": "^18.2.0",
Expand Down
19 changes: 17 additions & 2 deletions stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import DateRangeDark from "./reactivesearch/DateRangeDark.stories";
import ErrorBoundaryDefault from "./reactivesearch/ErrorBoundary.stories";
import SearchBoxWithCustomAIRender, { GlobalStyles } from "./reactivesearch/SearchBoxWithCustomAIRender.stories";
import { Remarkable } from 'remarkable';
import { renderBookItemWithDate, renderBookItemWithLink } from "./utils/renderItem";
const md = new Remarkable();

md.set({
Expand Down Expand Up @@ -2562,6 +2563,20 @@ storiesOf("Search components/SearchBox", module)
)
)
.add('with compoundClause', () => <SearchBoxRSDefault compoundClause={compoundClauseSelector()} />)
.add("with image search", () => (
<SearchBoxRSDefault
showImageSearch={boolean("showImageSearch", true)}
vectorDataField={text("vectorDataField", "image")}
enableAI={boolean("enableAI", false)}
autosuggest={boolean("autosuggest", true)}
imageSearchConfig={{
tooltip: text("tooltip", "Search by image"),
icon: text("icon", ""),
iconURL: text("iconURL", ""),
}}
themePreset={select("themePreset", ["light", "dark"])}
/>
))
.add(
"With document suggestions",
() => (
Expand Down Expand Up @@ -2603,7 +2618,7 @@ storiesOf("Search components/SearchBox", module)
"overview"
]}
showClear
renderItem={(suggestion)=>(<div>{suggestion._source.original_title} <span style={{color: "crimson", backgroundColor: "lightgray", padding: 5, borderRadius: 3}}>{new Date(Number(suggestion._source._timestamp) * 1000).toDateString() || ""}</span></div>)}
renderItem={renderBookItemWithDate}
/>
)
)
Expand All @@ -2626,7 +2641,7 @@ storiesOf("Search components/SearchBox", module)
"overview"
]}
showClear
renderItem={(suggestion)=>(<a style={{width:'100%', height: '100%', display: 'block', textDecoration: "none", color: "inherit"}} href={`https://www.google.com/search?q=${suggestion._source.original_title}`} target="_blank" rel="noreferrer">{suggestion._source.original_title}</a>)}
renderItem={renderBookItemWithLink}
/>
)
)
Expand Down
2 changes: 2 additions & 0 deletions stories/reactivesearch/SearchBox.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export default class SearchBoxDefault extends Component {
recordAnalytics: true,
"userId": "test",
}}
key={this.props.themePreset || "light"}
themePreset={this.props.themePreset || "light"}
>
<div className="row">
<div className="col">
Expand Down
23 changes: 23 additions & 0 deletions stories/utils/renderItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const renderBookItemWithDate = (suggestion)=>(
<div>{suggestion._source.original_title}
<span style={{color: "crimson", backgroundColor: "lightgray", padding: 5, borderRadius: 3}}>
{new Date(Number(suggestion._source._timestamp) * 1000).toDateString() || ""}
</span>
</div>
)
export const renderBookItemWithLink = (suggestion)=>(
<a
style={{
width:'100%',
height: '100%',
display: 'block',
textDecoration: "none",
color: "inherit"
}}
href={`https://www.google.com/search?q=${suggestion._source.original_title}`}
target="_blank"
rel="noreferrer"
>
{suggestion._source.original_title}
</a>
)

1 comment on commit 0642403

@vercel
Copy link

@vercel vercel bot commented on 0642403 Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.