Skip to content

Commit e78e5c6

Browse files
committed
docs: add docsearch
1 parent 243508e commit e78e5c6

File tree

6 files changed

+304
-1
lines changed

6 files changed

+304
-1
lines changed

packages/docs/.vuepress/theme-coreui/src/client/components/Header.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<CHeaderToggler class="ms-md-3" @click="$emit('toggle-sidebar')">
44
<CIcon icon="cil-menu" size="lg" />
55
</CHeaderToggler>
6+
<div class="docs-search" id="docsearch"></div>
67
<CHeaderNav class="ms-auto">
78
<CNavItem href="https://github.com/coreui">
89
<CIcon icon="cib-github" size="xl" />

packages/docs/.vuepress/theme-coreui/src/client/layouts/Layout.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</template>
4646

4747
<script lang="ts">
48-
import { computed, defineComponent, ref, Transition } from 'vue'
48+
import { computed, defineComponent, onMounted, ref, Transition } from 'vue'
4949
import { usePageData, usePageFrontmatter } from '@vuepress/client'
5050
import type { DefaultThemePageFrontmatter } from '../../shared'
5151
import Footer from '../components/Footer.vue'
@@ -54,6 +54,7 @@ import Home from '../components/Home.vue'
5454
import Page from '../components/Page.vue'
5555
import Sidebar from '../components/Sidebar.vue'
5656
import { useScrollPromise, useSidebarItems, useThemeLocaleData } from '../composables'
57+
import docsearch from '@docsearch/js'
5758
5859
export default defineComponent({
5960
name: 'Layout',
@@ -100,6 +101,18 @@ export default defineComponent({
100101
const onBeforeEnter = scrollPromise.resolve
101102
const onBeforeLeave = scrollPromise.pending
102103
104+
onMounted(() => {
105+
const searchElement = document.getElementById('docsearch') as HTMLElement
106+
docsearch({
107+
appId: 'RG8RW9GEH3',
108+
apiKey: '4926b633296d71c6d727f7766170f82b',
109+
indexName: 'coreuivue',
110+
container: searchElement,
111+
// @ts-ignore
112+
debug: false,
113+
})
114+
})
115+
103116
return {
104117
isSidebarOpen,
105118
frontmatter,
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// stylelint-disable selector-class-pattern
2+
3+
.DocSearch-Container {
4+
--docsearch-muted-color: #{$text-muted};
5+
--docsearch-hit-shadow: none;
6+
7+
z-index: 2000; // Make sure to be over all components showcased in the documentation
8+
cursor: auto; // Needed because of [role="button"] in Algolia search modal. Remove once https://github.com/algolia/docsearch/issues/1370 is tackled.
9+
10+
@include media-breakpoint-up(lg) {
11+
padding-top: 4rem;
12+
}
13+
}
14+
15+
.DocSearch-Button {
16+
min-width: 200px;
17+
min-height: 38px;
18+
font-family: $input-font-family;
19+
font-weight: $input-font-weight;
20+
line-height: $input-line-height;
21+
@include font-size($input-font-size);
22+
color: $input-color;
23+
background-color: $input-bg;
24+
background-clip: padding-box;
25+
border: $input-border-width solid $input-border-color;
26+
27+
// Note: This has no effect on <select>s in some browsers, due to the limited stylability of `<select>`s in CSS.
28+
@include border-radius($btn-border-radius);
29+
30+
@include box-shadow($input-box-shadow);
31+
@include transition($input-transition);
32+
33+
&:focus {
34+
color: $input-focus-color;
35+
background-color: $input-focus-bg;
36+
border-color: $input-focus-border-color;
37+
outline: 0;
38+
@if $enable-shadows {
39+
@include box-shadow($input-box-shadow, $input-focus-box-shadow);
40+
} @else {
41+
// Avoid using mixin so we can pass custom focus shadow properly
42+
box-shadow: $input-focus-box-shadow;
43+
}
44+
}
45+
46+
&:hover:not(:disabled):not([readonly])::file-selector-button {
47+
background-color: $form-file-button-hover-bg;
48+
}
49+
50+
.DocSearch-Search-Icon {
51+
opacity: .65;
52+
}
53+
}
54+
55+
56+
.DocSearch-Button-Keys {
57+
min-width: 0;
58+
padding: 0 .25rem;
59+
background: rgba($black, .125);
60+
@include border-radius(.25rem);
61+
}
62+
63+
.DocSearch-Button-Key {
64+
top: 0;
65+
width: auto;
66+
height: 1.5rem;
67+
padding: 0 .125rem;
68+
margin-right: 0;
69+
font-size: .875rem;
70+
background: none;
71+
box-shadow: none;
72+
}
73+
74+
.DocSearch-Commands-Key {
75+
padding-left: 1px;
76+
font-size: .875rem;
77+
background-color: rgba($black, .1);
78+
background-image: none;
79+
box-shadow: none;
80+
}
81+
82+
.DocSearch-Form {
83+
@include border-radius(var(--cui-border-radius));
84+
}
85+
86+
.DocSearch-Hits {
87+
mark {
88+
padding: 0;
89+
}
90+
}
91+
92+
.DocSearch-Hit {
93+
padding-bottom: 0;
94+
@include border-radius(0);
95+
96+
a {
97+
@include border-radius(0);
98+
border: solid var(--cui-border-color);
99+
border-width: 0 1px 1px;
100+
}
101+
102+
&:first-child a {
103+
@include border-top-radius(var(--cui-border-radius));
104+
border-top-width: 1px;
105+
}
106+
&:last-child a {
107+
@include border-bottom-radius(var(--cui-border-radius));
108+
}
109+
}
110+
111+
.DocSearch-Hit-icon {
112+
display: flex;
113+
align-items: center;
114+
}

packages/docs/.vuepress/theme-coreui/src/client/styles/index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
@import '@coreui/coreui/scss/coreui.scss';
2+
@import '@docsearch/css/dist/style.css';
23

34
@import 'ads';
45
@import 'anchor';
56
@import 'demo';
67
@import 'footer';
78
@import 'layout';
9+
@import 'search';
810
@import 'sidebar';
911
@import 'table-api';
1012
@import 'toc';

packages/docs/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"@coreui/icons": "^3.0.0",
1414
"@coreui/icons-vue": "^2.0.0",
1515
"@coreui/vue-chartjs": "^2.0.1",
16+
"@docsearch/css": "^3.3.3",
17+
"@docsearch/js": "^3.3.3",
1618
"@vuepress/plugin-toc": "2.0.0-beta.38",
1719
"markdown-it-include": "^2.0.0",
1820
"vue-docgen-cli": "^4.57.1",

yarn.lock

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,129 @@
22
# yarn lockfile v1
33

44

5+
"@algolia/autocomplete-core@1.7.4":
6+
version "1.7.4"
7+
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.7.4.tgz#85ff36b2673654a393c8c505345eaedd6eaa4f70"
8+
integrity sha512-daoLpQ3ps/VTMRZDEBfU8ixXd+amZcNJ4QSP3IERGyzqnL5Ch8uSRFt/4G8pUvW9c3o6GA4vtVv4I4lmnkdXyg==
9+
dependencies:
10+
"@algolia/autocomplete-shared" "1.7.4"
11+
12+
"@algolia/autocomplete-preset-algolia@1.7.4":
13+
version "1.7.4"
14+
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.7.4.tgz#610ee1d887962f230b987cba2fd6556478000bc3"
15+
integrity sha512-s37hrvLEIfcmKY8VU9LsAXgm2yfmkdHT3DnA3SgHaY93yjZ2qL57wzb5QweVkYuEBZkT2PIREvRoLXC2sxTbpQ==
16+
dependencies:
17+
"@algolia/autocomplete-shared" "1.7.4"
18+
19+
"@algolia/autocomplete-shared@1.7.4":
20+
version "1.7.4"
21+
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.7.4.tgz#78aea1140a50c4d193e1f06a13b7f12c5e2cbeea"
22+
integrity sha512-2VGCk7I9tA9Ge73Km99+Qg87w0wzW4tgUruvWAn/gfey1ZXgmxZtyIRBebk35R1O8TbK77wujVtCnpsGpRy1kg==
23+
24+
"@algolia/cache-browser-local-storage@4.14.3":
25+
version "4.14.3"
26+
resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.14.3.tgz#b9e0da012b2f124f785134a4d468ee0841b2399d"
27+
integrity sha512-hWH1yCxgG3+R/xZIscmUrWAIBnmBFHH5j30fY/+aPkEZWt90wYILfAHIOZ1/Wxhho5SkPfwFmT7ooX2d9JeQBw==
28+
dependencies:
29+
"@algolia/cache-common" "4.14.3"
30+
31+
"@algolia/cache-common@4.14.3":
32+
version "4.14.3"
33+
resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.14.3.tgz#a78e9faee3dfec018eab7b0996e918e06b476ac7"
34+
integrity sha512-oZJofOoD9FQOwiGTzyRnmzvh3ZP8WVTNPBLH5xU5JNF7drDbRT0ocVT0h/xB2rPHYzOeXRrLaQQBwRT/CKom0Q==
35+
36+
"@algolia/cache-in-memory@4.14.3":
37+
version "4.14.3"
38+
resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.14.3.tgz#96cefb942aeb80e51e6a7e29f25f4f7f3439b736"
39+
integrity sha512-ES0hHQnzWjeioLQf5Nq+x1AWdZJ50znNPSH3puB/Y4Xsg4Av1bvLmTJe7SY2uqONaeMTvL0OaVcoVtQgJVw0vg==
40+
dependencies:
41+
"@algolia/cache-common" "4.14.3"
42+
43+
"@algolia/client-account@4.14.3":
44+
version "4.14.3"
45+
resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.14.3.tgz#6d7d032a65c600339ce066505c77013d9a9e4966"
46+
integrity sha512-PBcPb0+f5Xbh5UfLZNx2Ow589OdP8WYjB4CnvupfYBrl9JyC1sdH4jcq/ri8osO/mCZYjZrQsKAPIqW/gQmizQ==
47+
dependencies:
48+
"@algolia/client-common" "4.14.3"
49+
"@algolia/client-search" "4.14.3"
50+
"@algolia/transporter" "4.14.3"
51+
52+
"@algolia/client-analytics@4.14.3":
53+
version "4.14.3"
54+
resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.14.3.tgz#ca409d00a8fff98fdcc215dc96731039900055dc"
55+
integrity sha512-eAwQq0Hb/aauv9NhCH5Dp3Nm29oFx28sayFN2fdOWemwSeJHIl7TmcsxVlRsO50fsD8CtPcDhtGeD3AIFLNvqw==
56+
dependencies:
57+
"@algolia/client-common" "4.14.3"
58+
"@algolia/client-search" "4.14.3"
59+
"@algolia/requester-common" "4.14.3"
60+
"@algolia/transporter" "4.14.3"
61+
62+
"@algolia/client-common@4.14.3":
63+
version "4.14.3"
64+
resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.14.3.tgz#c44e48652b2121a20d7a40cfd68d095ebb4191a8"
65+
integrity sha512-jkPPDZdi63IK64Yg4WccdCsAP4pHxSkr4usplkUZM5C1l1oEpZXsy2c579LQ0rvwCs5JFmwfNG4ahOszidfWPw==
66+
dependencies:
67+
"@algolia/requester-common" "4.14.3"
68+
"@algolia/transporter" "4.14.3"
69+
70+
"@algolia/client-personalization@4.14.3":
71+
version "4.14.3"
72+
resolved "https://registry.yarnpkg.com/@algolia/client-personalization/-/client-personalization-4.14.3.tgz#8f71325035aa2a5fa7d1d567575235cf1d6c654f"
73+
integrity sha512-UCX1MtkVNgaOL9f0e22x6tC9e2H3unZQlSUdnVaSKpZ+hdSChXGaRjp2UIT7pxmPqNCyv51F597KEX5WT60jNg==
74+
dependencies:
75+
"@algolia/client-common" "4.14.3"
76+
"@algolia/requester-common" "4.14.3"
77+
"@algolia/transporter" "4.14.3"
78+
79+
"@algolia/client-search@4.14.3":
80+
version "4.14.3"
81+
resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.14.3.tgz#cf1e77549f5c3e73408ffe6441ede985fde69da0"
82+
integrity sha512-I2U7xBx5OPFdPLA8AXKUPPxGY3HDxZ4r7+mlZ8ZpLbI8/ri6fnu6B4z3wcL7sgHhDYMwnAE8Xr0AB0h3Hnkp4A==
83+
dependencies:
84+
"@algolia/client-common" "4.14.3"
85+
"@algolia/requester-common" "4.14.3"
86+
"@algolia/transporter" "4.14.3"
87+
88+
"@algolia/logger-common@4.14.3":
89+
version "4.14.3"
90+
resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.14.3.tgz#87d4725e7f56ea5a39b605771b7149fff62032a7"
91+
integrity sha512-kUEAZaBt/J3RjYi8MEBT2QEexJR2kAE2mtLmezsmqMQZTV502TkHCxYzTwY2dE7OKcUTxi4OFlMuS4GId9CWPw==
92+
93+
"@algolia/logger-console@4.14.3":
94+
version "4.14.3"
95+
resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.14.3.tgz#1f19f8f0a5ef11f01d1f9545290eb6a89b71fb8a"
96+
integrity sha512-ZWqAlUITktiMN2EiFpQIFCJS10N96A++yrexqC2Z+3hgF/JcKrOxOdT4nSCQoEPvU4Ki9QKbpzbebRDemZt/hw==
97+
dependencies:
98+
"@algolia/logger-common" "4.14.3"
99+
100+
"@algolia/requester-browser-xhr@4.14.3":
101+
version "4.14.3"
102+
resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.14.3.tgz#bcf55cba20f58fd9bc95ee55793b5219f3ce8888"
103+
integrity sha512-AZeg2T08WLUPvDncl2XLX2O67W5wIO8MNaT7z5ii5LgBTuk/rU4CikTjCe2xsUleIZeFl++QrPAi4Bdxws6r/Q==
104+
dependencies:
105+
"@algolia/requester-common" "4.14.3"
106+
107+
"@algolia/requester-common@4.14.3":
108+
version "4.14.3"
109+
resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.14.3.tgz#2d02fbe01afb7ae5651ae8dfe62d6c089f103714"
110+
integrity sha512-RrRzqNyKFDP7IkTuV3XvYGF9cDPn9h6qEDl595lXva3YUk9YSS8+MGZnnkOMHvjkrSCKfoLeLbm/T4tmoIeclw==
111+
112+
"@algolia/requester-node-http@4.14.3":
113+
version "4.14.3"
114+
resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.14.3.tgz#72389e1c2e5d964702451e75e368eefe85a09d8f"
115+
integrity sha512-O5wnPxtDRPuW2U0EaOz9rMMWdlhwP0J0eSL1Z7TtXF8xnUeeUyNJrdhV5uy2CAp6RbhM1VuC3sOJcIR6Av+vbA==
116+
dependencies:
117+
"@algolia/requester-common" "4.14.3"
118+
119+
"@algolia/transporter@4.14.3":
120+
version "4.14.3"
121+
resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.14.3.tgz#5593036bd9cf2adfd077fdc3e81d2e6118660a7a"
122+
integrity sha512-2qlKlKsnGJ008exFRb5RTeTOqhLZj0bkMCMVskxoqWejs2Q2QtWmsiH98hDfpw0fmnyhzHEt0Z7lqxBYp8bW2w==
123+
dependencies:
124+
"@algolia/cache-common" "4.14.3"
125+
"@algolia/logger-common" "4.14.3"
126+
"@algolia/requester-common" "4.14.3"
127+
5128
"@ampproject/remapping@^2.1.0":
6129
version "2.2.0"
7130
resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.0.tgz#56c133824780de3174aed5ab6834f3026790154d"
@@ -332,6 +455,29 @@
332455
resolved "https://registry.yarnpkg.com/@coreui/icons/-/icons-3.0.0.tgz#e36ef6e10fdc61aaff22e4ab1f6e71775b26f365"
333456
integrity sha512-t4hJilv5IFBvaHIIQeUoXctV5nJkW21PTIhgeGO80xS25Ii4kkXa2gzryj6v6OEPSDPnY2YWhYm39TBjbXt1Xw==
334457

458+
"@docsearch/css@3.3.3", "@docsearch/css@^3.3.3":
459+
version "3.3.3"
460+
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.3.3.tgz#f9346c9e24602218341f51b8ba91eb9109add434"
461+
integrity sha512-6SCwI7P8ao+se1TUsdZ7B4XzL+gqeQZnBc+2EONZlcVa0dVrk0NjETxozFKgMv0eEGH8QzP1fkN+A1rH61l4eg==
462+
463+
"@docsearch/js@^3.3.3":
464+
version "3.3.3"
465+
resolved "https://registry.yarnpkg.com/@docsearch/js/-/js-3.3.3.tgz#70725a7a8fe92d221fcf0593263b936389d3728f"
466+
integrity sha512-2xAv2GFuHzzmG0SSZgf8wHX0qZX8n9Y1ZirKUk5Wrdc+vH9CL837x2hZIUdwcPZI9caBA+/CzxsS68O4waYjUQ==
467+
dependencies:
468+
"@docsearch/react" "3.3.3"
469+
preact "^10.0.0"
470+
471+
"@docsearch/react@3.3.3":
472+
version "3.3.3"
473+
resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.3.3.tgz#907b6936a565f880b4c0892624b4f7a9f132d298"
474+
integrity sha512-pLa0cxnl+G0FuIDuYlW+EBK6Rw2jwLw9B1RHIeS4N4s2VhsfJ/wzeCi3CWcs5yVfxLd5ZK50t//TMA5e79YT7Q==
475+
dependencies:
476+
"@algolia/autocomplete-core" "1.7.4"
477+
"@algolia/autocomplete-preset-algolia" "1.7.4"
478+
"@docsearch/css" "3.3.3"
479+
algoliasearch "^4.0.0"
480+
335481
"@esbuild/linux-loong64@0.14.54":
336482
version "0.14.54"
337483
resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.14.54.tgz#de2a4be678bd4d0d1ffbb86e6de779cde5999028"
@@ -2537,6 +2683,26 @@ ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4:
25372683
json-schema-traverse "^0.4.1"
25382684
uri-js "^4.2.2"
25392685

2686+
algoliasearch@^4.0.0:
2687+
version "4.14.3"
2688+
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.14.3.tgz#f02a77a4db17de2f676018938847494b692035e7"
2689+
integrity sha512-GZTEuxzfWbP/vr7ZJfGzIl8fOsoxN916Z6FY2Egc9q2TmZ6hvq5KfAxY89pPW01oW/2HDEKA8d30f9iAH9eXYg==
2690+
dependencies:
2691+
"@algolia/cache-browser-local-storage" "4.14.3"
2692+
"@algolia/cache-common" "4.14.3"
2693+
"@algolia/cache-in-memory" "4.14.3"
2694+
"@algolia/client-account" "4.14.3"
2695+
"@algolia/client-analytics" "4.14.3"
2696+
"@algolia/client-common" "4.14.3"
2697+
"@algolia/client-personalization" "4.14.3"
2698+
"@algolia/client-search" "4.14.3"
2699+
"@algolia/logger-common" "4.14.3"
2700+
"@algolia/logger-console" "4.14.3"
2701+
"@algolia/requester-browser-xhr" "4.14.3"
2702+
"@algolia/requester-common" "4.14.3"
2703+
"@algolia/requester-node-http" "4.14.3"
2704+
"@algolia/transporter" "4.14.3"
2705+
25402706
ansi-escapes@^4.2.1:
25412707
version "4.3.2"
25422708
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e"
@@ -6863,6 +7029,11 @@ postcss@^8.1.10, postcss@^8.4.12, postcss@^8.4.13:
68637029
picocolors "^1.0.0"
68647030
source-map-js "^1.0.2"
68657031

7032+
preact@^10.0.0:
7033+
version "10.12.1"
7034+
resolved "https://registry.yarnpkg.com/preact/-/preact-10.12.1.tgz#8f9cb5442f560e532729b7d23d42fd1161354a21"
7035+
integrity sha512-l8386ixSsBdbreOAkqtrwqHwdvR35ID8c3rKPa8lCWuO86dBi32QWHV4vfsZK1utLLFMvw+Z5Ad4XLkZzchscg==
7036+
68667037
prelude-ls@^1.2.1:
68677038
version "1.2.1"
68687039
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"

0 commit comments

Comments
 (0)