-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update theme to 0.2.x #402
Changes from 12 commits
29023ff
02a2b95
76abb41
e45512d
4e6ea20
0185fa5
8165989
0876fca
3443509
5c1cafd
fc1c56c
9b19868
15b4690
070a24a
969509b
65c379a
4b8565b
13f1b7c
e7e87ad
cc549aa
2adfbb8
75d7047
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
/* eslint-env node */ | ||
require('./src/styles/global.css') | ||
import React from 'react' | ||
|
||
import ModesProvider from './src/components/organisms/SwitchableMode/Provider' | ||
|
||
export const wrapRootElement = ({ element }) => ( | ||
<ModesProvider>{element}</ModesProvider> | ||
) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
|
||
import ModesProvider from './src/components/organisms/SwitchableMode/Provider' | ||
|
||
export const wrapRootElement = ({ element }) => ( | ||
<ModesProvider>{element}</ModesProvider> | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import Promise from 'promise-polyfill' | ||
import { loadResource } from '@dvcorg/gatsby-theme-iterative/src/utils/front/resources' | ||
|
||
import * as styles from '@dvcorg/gatsby-theme-iterative/src/components/Documentation/Layout/SearchForm/styles.module.css' | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
interface Window { | ||
docsearch?: (opts: object) => void | ||
} | ||
} | ||
|
||
const apiKey = '3e17d424c7a90fede27b848fb01c0dc2' | ||
const appId = '1O03WAGL0D' | ||
const indexName = 'cml' | ||
|
||
const SearchForm: React.FC = props => { | ||
const [searchAvailable, setSearchAvailable] = useState<boolean>(false) | ||
useEffect(() => { | ||
console.log({ window, docSearch: window?.docsearch }) | ||
if (window) { | ||
if (!window.docsearch) { | ||
Promise.all([ | ||
loadResource( | ||
'https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/docsearch.min.css' | ||
), | ||
loadResource( | ||
'https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/docsearch.min.js' | ||
) | ||
]).then(() => { | ||
if (window.docsearch) { | ||
window.docsearch({ | ||
appId, | ||
apiKey, | ||
indexName, | ||
inputSelector: '#doc-search', | ||
debug: false // Set to `true` if you want to inspect the dropdown | ||
}) | ||
setSearchAvailable(true) | ||
} | ||
}) | ||
} else { | ||
window.docsearch({ | ||
appId, | ||
apiKey, | ||
indexName, | ||
inputSelector: '#doc-search', | ||
debug: false // Set to `true` if you want to inspect the dropdown | ||
}) | ||
setSearchAvailable(true) | ||
} | ||
} | ||
}, []) | ||
|
||
return ( | ||
<div className={styles.searchArea}> | ||
<div className={styles.container}> | ||
<input | ||
className={styles.input} | ||
type="text" | ||
id="doc-search" | ||
placeholder="Search docs" | ||
disabled={!searchAvailable} | ||
{...props} | ||
/> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default SearchForm | ||
Comment on lines
+1
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll have to follow up on making this more reusable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we have had this pending for a while |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React from 'react' | ||
import SmartLink from '../../../atoms/SmartLink' | ||
import SmartLink from '../../../../../components/atoms/SmartLink' | ||
import * as styles from './styles.module.css' | ||
|
||
const Alert: React.FC = () => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be able to drop the |
||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be better to just wrap our components in the normal React area in this rather than use the
wrapRootElement
escape hatch.