Skip to content

Commit 0ec6083

Browse files
authored
Merge pull request #241 from data-driven-forms/added-documentation-search-input
Added doc search input to documentation.
2 parents 3bc386d + b713947 commit 0ec6083

File tree

5 files changed

+74
-2576
lines changed

5 files changed

+74
-2576
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,5 @@
7070
}
7171
]
7272
},
73-
"dependencies": {
74-
"n": "^6.0.1"
75-
}
73+
"dependencies": {}
7674
}

packages/react-renderer-demo/src/app/pages/_document.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ class MyDocument extends Document {
2626
integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
2727
crossOrigin="anonymous"
2828
/>
29+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
2930
</Head>
3031
<body>
3132
<Main />
3233
<NextScript />
34+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
3335
</body>
3436
</html>
3537
);
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React, { useEffect } from 'react';
2+
import TextField from '@material-ui/core/TextField'
3+
import InputAdornment from '@material-ui/core/InputAdornment'
4+
import makeStyles from '@material-ui/core/styles/makeStyles';
5+
import Search from '@material-ui/icons/Search';
6+
7+
const useStyles = makeStyles(() => ({
8+
docSearchWrapper: {
9+
marginRight: 16,
10+
'& .algolia-docsearch-suggestion.algolia-docsearch-suggestion__main.algolia-docsearch-suggestion__secondary': {
11+
textDecoration: 'none'
12+
},
13+
'& .algolia-autocomplete .algolia-docsearch-suggestion--title': {
14+
marginBottom: 0
15+
},
16+
'& .ds-dropdown-menu': {
17+
'& [class^=ds-dataset-]': {
18+
borderRadius: 0,
19+
},
20+
'&:before': {
21+
display: 'none'
22+
}
23+
},
24+
},
25+
docSearchInput: {
26+
'& input': {
27+
color: 'white'
28+
},
29+
'& .MuiInput-underline:hover:not(.Mui-disabled):before': {
30+
borderBottomColor: 'white',
31+
},
32+
'& .MuiInput-underline:after': {
33+
borderBottomColor: 'white',
34+
},
35+
'& .MuiInput-underline:before': {
36+
borderBottomColor: 'transparent',
37+
},
38+
},
39+
docSearchIcon: {
40+
fill: 'white'
41+
}
42+
}));
43+
44+
const DocSearch = () => {
45+
const classes = useStyles()
46+
useEffect(() => {
47+
window.docsearch({
48+
apiKey: '5e9dbd314423e38339595e183d1ae7b6',
49+
indexName: 'data-driven-forms',
50+
inputSelector: '#data-driven-forms-search',
51+
debug: false
52+
});
53+
}, []);
54+
return (
55+
<form className={ classes.docSearchWrapper }>
56+
<TextField
57+
id="data-driven-forms-search"
58+
type="search"
59+
placeholder="Search..."
60+
className={ classes.docSearchInput }
61+
InputProps={{
62+
startAdornment: <InputAdornment position="start"><Search className={ classes.docSearchIcon } /></InputAdornment>,
63+
}}
64+
/>
65+
</form>
66+
);
67+
};
68+
69+
export default DocSearch;

packages/react-renderer-demo/src/app/src/components/layout.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import MenuContext from './navigation/menu-context';
2020
import findConnectedLinks from './navigation/find-connected-links';
2121
import ConnectedLinks from './common/connected-links';
2222
import Footer from './footer';
23+
import DocSearch from './docsearch';
2324

2425
export const drawerWidth = 240;
2526

@@ -190,6 +191,7 @@ const Layout = ({ children }) => {
190191
<div className={ clsx(classes.drawerHeader, classes.appBar, classes.rightAppBar, {
191192
[classes.appBarShift]: open,
192193
}) }>
194+
<DocSearch />
193195
<a href="https://github.com/data-driven-forms/react-forms" rel="noopener noreferrer" target="_blank">
194196
<IconButton
195197
color="inherit"

0 commit comments

Comments
 (0)