Skip to content
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

docs(): add markprompt help chat #7837

Merged
merged 4 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs-website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
noIndex: isSaas,
customFields: {
isSaas: isSaas,
markpromptProjectKey: process.env.DOCUSAURUS_MARKPROMPT_PROJECT_KEY
jeffmerrick marked this conversation as resolved.
Show resolved Hide resolved
},
themeConfig: {
...(!isSaas && {
Expand Down
3 changes: 3 additions & 0 deletions docs-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
"docusaurus-graphql-plugin": "0.5.0",
"docusaurus-plugin-sass": "^0.2.1",
"dotenv": "^16.0.1",
"markprompt": "^0.1.7",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-modal": "^3.16.1",
"react-modal-hook": "^3.0.2",
"sass": "^1.43.2"
},
"browserslist": {
Expand Down
53 changes: 53 additions & 0 deletions docs-website/src/components/MarkpromptHelp/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from "react";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import { Markprompt } from "markprompt";
import clsx from "clsx";
import styles from "./markprompthelp.module.scss";
import { ModalProvider, useModal } from "react-modal-hook";
import Modal from "react-modal";

const BotIcon = ({ ...props }) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 79.164" {...props}>
<path d="M64.582 8.332h-18.75v-6.25C45.832.93 44.902 0 43.75 0s-2.082.93-2.082 2.082v6.25h-18.75c-5.754.004-10.414 4.664-10.418 10.418v37.5c.004 5.75 4.664 10.41 10.418 10.414H34.3l7.715 11.574a2.089 2.089 0 0 0 3.468 0L53.2 66.664h11.383C70.336 66.66 74.996 62 75 56.25v-37.5c-.004-5.754-4.664-10.414-10.418-10.418Zm6.25 47.918a6.256 6.256 0 0 1-6.25 6.25h-12.5c-.695 0-1.344.348-1.73.926l-6.602 9.902-6.602-9.898v-.004a2.082 2.082 0 0 0-1.73-.926h-12.5a6.256 6.256 0 0 1-6.25-6.25V50h54.168l-.004 6.25Zm0-10.418H16.668V18.75a6.253 6.253 0 0 1 6.25-6.25h41.664a6.253 6.253 0 0 1 6.25 6.25v27.082ZM35.418 31.25a4.165 4.165 0 0 1-2.574 3.848 4.166 4.166 0 1 1-1.594-8.016c1.105 0 2.164.438 2.945 1.219s1.223 1.844 1.223 2.95v-.001Zm25 0a4.165 4.165 0 0 1-2.574 3.848 4.166 4.166 0 1 1-1.594-8.016c1.105 0 2.164.438 2.945 1.219s1.223 1.844 1.223 2.95v-.001Zm-56.25-8.336v16.668a2.082 2.082 0 0 1-2.086 2.082A2.081 2.081 0 0 1 0 39.582V22.914a2.084 2.084 0 0 1 4.168 0Zm83.332 0v16.668a2.081 2.081 0 0 1-2.082 2.082 2.082 2.082 0 0 1-2.086-2.082V22.914a2.085 2.085 0 0 1 4.168 0Z" />
</svg>
);

const MarkpromptModal = () => {
const context = useDocusaurusContext();
const { siteConfig = {} } = context;

const [showModal, hideModal] = useModal(() => (
<Modal isOpen onRequestClose={hideModal} className={clsx(styles.markpromptModal, "shadow--tl")}>
<>
<div className={clsx(styles.markprompt)}>
<BotIcon />
<Markprompt placeholder="Ask me anything about DataHub!" projectKey={siteConfig.customFields.markpromptProjectKey} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part looks a bit cramped
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some changes to include the source list be included in scrollable area along with some mobile and dark mode tweaks I missed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

</div>
<hr />
<p>
This is an experimental AI-powered chat bot. We can't be sure what it will say but hope it can be helpful. If it's not, there are always{" "}
<a href="https://slack.datahubproject.io/" target="_blank">
humans available in our Slack channel
</a>
.
</p>
</>
</Modal>
));

return (
<div>
<button className={clsx(styles.markpromptButton, "button button--primary shadow--tl")} onClick={showModal}>
<BotIcon />
</button>
</div>
);
};

const MarkpromptHelp = () => (
<ModalProvider>
<MarkpromptModal />
</ModalProvider>
);

export default MarkpromptHelp;
126 changes: 126 additions & 0 deletions docs-website/src/components/MarkpromptHelp/markprompthelp.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
.markpromptButton {
position: fixed;
bottom: 1rem;
right: 1rem;
z-index: 1001;
width: 60px;
height: 60px;
padding: 0.75rem;
svg {
width: 100%;
height: auto;
fill: currentColor;
}
}

.markpromptModal {
max-width: 560px;
border-radius: 6px;
position: fixed;
left: 50%;
top: 0;
transform: translate(-50%, 0%);
background: var(--docsearch-modal-background);
z-index: 1003;
margin: 60px auto auto;
padding: 0;
max-height: 100%;
> p {
font-size: smaller;
padding: 1rem 1rem 0;
}

hr {
margin: 0.5rem 0;
}
}

.markprompt {
padding: 1rem 1rem;
display: flex;
justify-content: center;
flex-direction: column;
svg {
width: 4rem;
margin: 1rem auto;
height: auto;
fill: var(--ifm-color-primary);
}
input {
height: var(--docsearch-searchbox-height);
margin: 0;
padding: 0 var(--docsearch-spacing);
position: relative;
width: 100%;
border: none;
background: var(--docsearch-searchbox-focus-background);
border-radius: 4px;
box-shadow: var(--docsearch-searchbox-shadow);
color: var(--docsearch-text-color);
font-size: 1.2em;
outline: none;
}
}

:global {
.ReactModal__Overlay {
background: rgba(0, 0, 0, 0.5) !important;
z-index: 1002;
}
.caret {
& :local {
animation: caret 0.75s infinite;
}
display: inline-block;
width: 8px;
height: 16px;
background: var(--ifm-color-primary);
margin-top: 1rem;
}
.prompt-answer {
overflow-y: auto;
max-height: 50vh;

&:not(:empty) {
padding: 0.5rem 0;
}
.caret {
margin-top: 0;
}
&.prompt-answer-done {
.caret {
display: none;
}
}
&.prompt-answer-loading {
padding: 0.5rem 0;
.caret:not(:last-child),
code .caret {
display: none;
}
:last-child.caret {
display: inline-block;
}
}
+ div {
font-size: 12px;
> div > div > div {
display: inline-block;
padding: 0.25em 0.5em;
margin: 0 0.5em 0.5em 0;
border: 1px solid var(--ifm-hr-background-color);
border-radius: 4px;
}
}
}
}

@keyframes caret {
0% {
opacity: 1;
}

to {
opacity: 0;
}
}
3 changes: 2 additions & 1 deletion docs-website/src/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ html[data-theme="dark"] {
--ifm-heading-color: #ffffff;
--ifm-hr-border-color: #313131;
--ifm-background-surface-color: #0b0b0b;
--ifm-hr-background-color: #313131;

.button--primary {
color: #fff;
Expand Down Expand Up @@ -227,7 +228,7 @@ div[class^="announcementBar"] {
.quickstart__codeblock {
text-align: left;
padding: 0 20vh;
}
}

.theme-doc-sidebar-menu ul li.saasOnly a.menu__link {
&:after {
Expand Down
12 changes: 12 additions & 0 deletions docs-website/src/theme/Footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";
import Footer from "@theme-original/Footer";
import MarkpromptHelp from "../../components/MarkpromptHelp";

export default function FooterWrapper(props) {
return (
<>
<MarkpromptHelp />
<Footer {...props} />
</>
);
}
Loading