Skip to content

Commit

Permalink
Merge pull request #18 from easyops-cn/steve/search-page
Browse files Browse the repository at this point in the history
feat: search page to view all results
  • Loading branch information
weareoutman committed Nov 1, 2020
2 parents 506b5c3 + d6799c9 commit a80bc4d
Show file tree
Hide file tree
Showing 31 changed files with 816 additions and 166 deletions.
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module.exports = {
collectCoverageFrom: ["src/**/*.{ts,tsx,js,jsx}"],
// setupFilesAfterEnv: ["<rootDir>/__jest__/setup.js"],
// snapshotSerializers: ["enzyme-to-json/serializer"],
moduleNameMapper: {
"\\.module\\.css$": "identity-obj-proxy",
},
// Ref https://github.com/facebook/jest/issues/2070#issuecomment-431706685
// Todo(steve): remove next line when issue fixed.
modulePathIgnorePatterns: ["<rootDir>/.*/__mocks__"],
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "npm run build:client && npm run build:server",
"build:client": "tsc --project tsconfig.client.json",
"build:server": "tsc --project tsconfig.server.json",
"postbuild": "copyfiles -f src/client/theme/SearchBar/SearchBar.css dist/client/client/theme/SearchBar",
"postbuild": "copyfiles -u 3 \"src/client/theme/**/*.css\" dist/client/client/theme",
"release": "standard-version",
"coveralls": "coveralls < .coverage/lcov.info"
},
Expand All @@ -27,6 +27,7 @@
},
"license": "MIT",
"dependencies": {
"@docusaurus/utils": "^2.0.0-alpha.66",
"@hapi/joi": "^17.1.1",
"autocomplete.js": "^0.38.0",
"cheerio": "^1.0.0-rc.3",
Expand All @@ -42,6 +43,8 @@
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.1",
"@babel/preset-typescript": "^7.12.1",
"@docusaurus/module-type-aliases": "^2.0.0-alpha.66",
"@tsconfig/docusaurus": "^1.0.2",
"@types/debug": "^4.1.5",
"@types/enzyme": "^3.10.7",
"@types/enzyme-adapter-react-16": "^1.0.6",
Expand All @@ -50,8 +53,10 @@
"@types/jest": "^26.0.14",
"@types/klaw-sync": "^6.0.0",
"@types/lunr": "^2.3.3",
"@types/react": "^16.9.53",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.8",
"@types/react-helmet": "^6.1.0",
"@types/react-router-dom": "^5.1.6",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"babel-jest": "^26.5.2",
Expand All @@ -66,6 +71,7 @@
"eslint-plugin-react": "^7.21.4",
"eslint-plugin-react-hooks": "^4.1.2",
"husky": "^4.3.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.5.3",
"lint-staged": "^10.4.1",
"nodejieba": "^2.4.1",
Expand Down
47 changes: 47 additions & 0 deletions src/client/theme/LoadingRing/LoadingRing.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* https://loading.io/css/ */
.loadingRing {
display: inline-block;
position: relative;
width: 20px;
height: 20px;
opacity: var(--search-local-loading-icon-opacity, 0.5);
}

.loadingRing div {
box-sizing: border-box;
display: block;
position: absolute;
width: 16px;
height: 16px;
margin: 2px;
border: 2px solid
var(--search-load-loading-icon-color, var(--ifm-navbar-search-input-color));
border-radius: 50%;
animation: loading-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: var(
--search-load-loading-icon-color,
var(--ifm-navbar-search-input-color)
)
transparent transparent transparent;
}

.loadingRing div:nth-child(1) {
animation-delay: -0.45s;
}

.loadingRing div:nth-child(2) {
animation-delay: -0.3s;
}

.loadingRing div:nth-child(3) {
animation-delay: -0.15s;
}

@keyframes loading-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
19 changes: 19 additions & 0 deletions src/client/theme/LoadingRing/LoadingRing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// istanbul ignore file
import React from "react";
import clsx from "clsx";
import styles from "./LoadingRing.module.css";

export default function LoadingRing({
className,
}: {
className?: string;
}): React.ReactElement {
return (
<div className={clsx(styles.loadingRing, className)}>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
);
}
File renamed without changes.
9 changes: 9 additions & 0 deletions src/client/theme/SearchBar/EmptyTemplate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { iconNoResults } from "./icons";
import styles from "./SearchBar.module.css";

export function EmptyTemplate(): string {
if (process.env.NODE_ENV === "production") {
return `<span class="${styles.noResults}"><span class="${styles.noResultsIcon}">${iconNoResults}</span><span>No results.</span></span>`;
}
return `<span class="${styles.noResults}">⚠️ The search index is only available when you run docusaurus build!</span>`;
}

0 comments on commit a80bc4d

Please sign in to comment.