amis2/examples/components/DocSearch.jsx

48 lines
1.0 KiB
React
Raw Normal View History

2019-06-11 17:00:02 +08:00
import React from 'react';
2019-06-04 16:24:09 +08:00
import makeSchemaRenderer from './SchemaRender';
const FormComponent = makeSchemaRenderer({
2019-11-07 10:41:14 +08:00
type: 'form',
mode: 'inline',
wrapWithPanel: false,
2020-07-28 10:03:53 +08:00
className: ':Doc-search',
2019-11-07 10:41:14 +08:00
controls: [
{
type: 'input-group',
size: 'sm',
controls: [
{
type: 'icon',
2020-07-23 20:31:51 +08:00
addOnclassName: 'no-bg no-border p-r-none p-l',
2019-11-07 10:41:14 +08:00
className: 'text-sm',
icon: 'search',
vendor: 'iconfont'
},
{
type: 'text',
2020-07-23 20:31:51 +08:00
placeholder: '搜索...',
inputClassName: 'no-border',
2019-11-07 10:41:14 +08:00
name: 'docsearch'
}
]
}
]
});
2019-06-04 16:24:09 +08:00
export default class DocSearch extends React.Component {
2019-11-07 10:41:14 +08:00
componentDidMount() {
const inputSelector = 'input[name="docsearch"]';
docsearch({
appId: '3W0NHYOWPE',
apiKey: '469f5cf3d54f9b86127970f913dc0725',
indexName: 'gh_pages',
inputSelector,
debug: false
});
}
2019-06-04 16:24:09 +08:00
2019-11-07 10:41:14 +08:00
render() {
return <FormComponent showCode={false} theme={this.props.theme} />;
}
}