This repository has been archived by the owner on Jun 11, 2021. It is now read-only.
forked from algolia/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docsearch): introduce DocSearch.js v3 (#56)
- Loading branch information
1 parent
fe56ef3
commit 0ff2462
Showing
18 changed files
with
169 additions
and
773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "@docsearch/css", | ||
"version": "1.0.0-alpha.21", | ||
"license": "MIT", | ||
"homepage": "https://github.com/algolia/autocomplete.js", | ||
"repository": "algolia/autocomplete.js", | ||
"author": { | ||
"name": "Algolia, Inc.", | ||
"url": "https://www.algolia.com" | ||
}, | ||
"sideEffects": false, | ||
"files": [ | ||
"dist/" | ||
], | ||
"main": "dist/style.css", | ||
"unpkg": "dist/style.css", | ||
"jsdelivr": "dist/style.css", | ||
"scripts": { | ||
"build": "yarn build:clean && yarn build:css", | ||
"build:css": "mkdir dist && cp src/_variables.css dist/ && cp src/modal.css dist/ && cp src/search-button.css dist/ && cat src/*.css > dist/style.css", | ||
"build:css:watch": "chokidar src/*.css --command \"yarn build:css\"", | ||
"build:clean": "rm -rf ./dist", | ||
"watch": "concurrently \"yarn build:css:watch\"" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions
2
...search-react/src/styles/search-button.css → packages/docsearch-css/src/search-button.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-disable import/no-commonjs */ | ||
|
||
module.exports = (api) => { | ||
const isTest = api.env('test'); | ||
const modules = isTest ? 'commonjs' : false; | ||
const targets = {}; | ||
|
||
if (isTest) { | ||
targets.node = true; | ||
} else { | ||
targets.browsers = ['last 2 versions', 'ie >= 11']; | ||
} | ||
|
||
return { | ||
presets: [ | ||
'@babel/preset-typescript', | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
modules, | ||
targets, | ||
}, | ||
], | ||
], | ||
plugins: [['@babel/plugin-transform-react-jsx']], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@docsearch/js", | ||
"version": "1.0.0-alpha.21", | ||
"license": "MIT", | ||
"homepage": "https://github.com/algolia/autocomplete.js", | ||
"repository": "algolia/autocomplete.js", | ||
"author": { | ||
"name": "Algolia, Inc.", | ||
"url": "https://www.algolia.com" | ||
}, | ||
"sideEffects": false, | ||
"files": [ | ||
"dist/" | ||
], | ||
"source": "src/index.ts", | ||
"types": "dist/esm/index.d.ts", | ||
"module": "dist/esm/index.js", | ||
"main": "dist/umd/index.js", | ||
"umd:main": "dist/umd/index.js", | ||
"unpkg": "dist/umd/index.js", | ||
"jsdelivr": "dist/umd/index.js", | ||
"scripts": { | ||
"build": "yarn build:clean && yarn build:umd && yarn build:esm", | ||
"build:esm": "babel src --root-mode upward --extensions '.ts,.tsx' --out-dir dist/esm", | ||
"build:esm:watch": "yarn build:esm --watch", | ||
"build:umd": "rollup --config", | ||
"build:types": "tsc -p ./tsconfig.declaration.json --outDir ./dist/esm", | ||
"build:types:watch": "chokidar \"**/*.ts\" \"**/*.tsx\" --command \"yarn build:types\" --ignore \"dist\"", | ||
"build:clean": "rm -rf ./dist", | ||
"watch": "concurrently \"yarn build:esm:watch\" \"yarn build:types:watch\"" | ||
}, | ||
"dependencies": { | ||
"@docsearch/react": "^1.0.0-alpha.21", | ||
"preact": "^10.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import json from '@rollup/plugin-json'; | ||
import alias from '@rollup/plugin-alias'; | ||
|
||
import { sharedPlugins } from '../autocomplete-core/rollup.config'; | ||
|
||
export default { | ||
input: 'src/index.ts', | ||
output: { | ||
file: 'dist/umd/index.js', | ||
format: 'umd', | ||
sourcemap: true, | ||
name: 'docsearch', | ||
}, | ||
plugins: [ | ||
json(), | ||
alias({ | ||
entries: [ | ||
{ find: 'react', replacement: 'preact/compat' }, | ||
{ find: 'react-dom', replacement: 'preact/compat' }, | ||
], | ||
}), | ||
...sharedPlugins, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { render } from 'preact/compat'; | ||
|
||
import { DocSearch } from '@docsearch/react'; | ||
|
||
function getHTMLElement( | ||
value: string | HTMLElement, | ||
environment: typeof window = window | ||
): HTMLElement { | ||
if (typeof value === 'string') { | ||
return environment.document.querySelector<HTMLElement>(value)!; | ||
} | ||
|
||
return value; | ||
} | ||
|
||
export function docsearch(props) { | ||
render( | ||
<DocSearch {...props} />, | ||
getHTMLElement(props.container, props.environment) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { docsearch as default } from './docsearch'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig", | ||
"compilerOptions": { | ||
"noEmit": false, | ||
"declaration": true, | ||
"emitDeclarationOnly": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.