Skip to content

Commit

Permalink
feat(sendsay-docs): add support link component (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lullabyq authored Sep 16, 2024
1 parent fbbc5e0 commit 3d4bfa9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/SupportLink/SupportLink.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.supportLink {
color: var(--ifm-link-color);
font-size: inherit;
line-height: inherit;
cursor: pointer;
padding: 0;
background-color: white;
border: none;
}

.supportLink:hover {
opacity: 0.7;
}
29 changes: 29 additions & 0 deletions src/components/SupportLink/SupportLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, { PropsWithChildren } from 'react';
import styles from './SupportLink.module.css';

declare global {
interface Window {
carrotquest?: {
open: () => void;
};
}
}

const SupportLink = ({ children }: PropsWithChildren) => {
const handleChatLinkClick = () => {
if (window.carrotquest !== undefined) {
window.carrotquest.open();
} else {
// eslint-disable-next-line no-console
console.error('Unable to open carrot quest chat. Does the widget exist?');
}
};

return (
<button onClick={handleChatLinkClick} className={styles.supportLink} tabIndex={0} type="button">
{children}
</button>
);
};

export default SupportLink;
1 change: 1 addition & 0 deletions src/components/SupportLink/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './SupportLink';

0 comments on commit 3d4bfa9

Please sign in to comment.