Skip to content

Commit 20e14bc

Browse files
Guillermo Alejandro Gallardo DiezGuillermo Alejandro Gallardo Diez
authored andcommitted
fix: css and minor behaviour issues
1 parent 8eb563b commit 20e14bc

6 files changed

Lines changed: 98 additions & 49 deletions

File tree

website/src/components/FeedbackComponent.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export function FeedbackComponent() {
66
const [comment, setComment] = useState('');
77
const [showComment, setShowComment] = useState(false);
88

9-
const handleFeedback = (type) => {
9+
const handleFeedback = (event, type) => {
10+
event.preventDefault();
1011
setFeedback(type);
1112
setShowComment(true);
1213
};
@@ -34,38 +35,40 @@ export function FeedbackComponent() {
3435
};
3536

3637
if (isSubmitted) {
37-
return (
38+
return <>
39+
<hr style={{marginBottom: "1rem"}} />
3840
<div className="feedback-container">
3941
<div className="feedback-success">
4042
<span className="feedback-success-icon"></span>
4143
<span>Thanks for your feedback!</span>
4244
</div>
4345
</div>
44-
);
46+
</>
4547
}
4648

47-
return (
49+
return <>
50+
<hr style={{marginBottom: "1rem"}} />
4851
<div className="feedback-container">
4952
{!showComment ? (
5053
<div className="feedback-question">
5154
<span className="feedback-text">Was this page helpful?</span>
5255
<div className="feedback-buttons">
53-
<button
54-
className="feedback-btn feedback-btn-yes"
55-
onClick={() => handleFeedback('yes')}
56-
title="Yes, this was helpful"
56+
<a
57+
className="feedback-btn"
58+
href="#"
59+
onClick={(event) => handleFeedback(event, 'yes')}
60+
// title="Yes, this was helpful"
5761
>
58-
<span className="feedback-emoji">👍</span>
59-
<span>Yes</span>
60-
</button>
61-
<button
62-
className="feedback-btn feedback-btn-no"
63-
onClick={() => handleFeedback('no')}
64-
title="No, this wasn't helpful"
62+
👍 Yes
63+
</a>
64+
<a
65+
className="feedback-btn"
66+
href="#"
67+
onClick={(event) => handleFeedback(event, 'no')}
68+
// title="No, this wasn't helpful"
6569
>
66-
<span className="feedback-emoji">👎</span>
67-
<span>No</span>
68-
</button>
70+
👎 No
71+
</a>
6972
</div>
7073
</div>
7174
) : (
@@ -93,5 +96,5 @@ export function FeedbackComponent() {
9396
</div>
9497
)}
9598
</div>
96-
);
99+
</>;
97100
}

website/src/theme/SearchBar/components/AIChatInSearch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default function AIChatInSearch({
134134

135135
<div className={styles.aiChatRow}>
136136
<div className={styles.aiChatRowContent}>
137-
{turn.assistantText?.trim() ? (
137+
{turn.assistantText? (
138138
<div className={styles.aiChatAnswer}>
139139
<MarkdownRenderer part={turn.assistantText} isDarkTheme={colorMode === 'dark'} />
140140
</div>

website/src/theme/SearchBar/components/ChatbotTrigger.tsx

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
1-
import React, { useState, useRef } from 'react';
1+
import React, { useEffect, useState, useRef } from 'react';
22
import { ArrowUp } from 'lucide-react';
33
import { useLocation } from '@docusaurus/router';
4+
import { useWindowSize } from '@docusaurus/theme-common';
45
import styles from '../styles.module.css';
56

67
export default function ChatbotTrigger() {
78
const [value, setValue] = useState('');
9+
const [isStuck, setIsStuck] = useState(false);
10+
const containerRef = useRef<HTMLDivElement>(null);
811
const textareaRef = useRef<HTMLTextAreaElement>(null);
12+
const windowSize = useWindowSize();
913
const { pathname } = useLocation();
1014

15+
useEffect(() => {
16+
if (windowSize === 'mobile') {
17+
setIsStuck(false);
18+
return;
19+
}
20+
21+
const updateStuckState = () => {
22+
const element = containerRef.current;
23+
if (!element) return;
24+
25+
const rect = element.getBoundingClientRect();
26+
const stickyBottom = Number.parseFloat(getComputedStyle(element).bottom) || 0;
27+
const viewportBottom = window.innerHeight;
28+
const targetBottom = viewportBottom - stickyBottom;
29+
30+
setIsStuck(Math.abs(rect.bottom - targetBottom) < 1.5);
31+
};
32+
33+
updateStuckState();
34+
window.addEventListener('scroll', updateStuckState, { passive: true });
35+
window.addEventListener('resize', updateStuckState);
36+
37+
return () => {
38+
window.removeEventListener('scroll', updateStuckState);
39+
window.removeEventListener('resize', updateStuckState);
40+
};
41+
}, [windowSize]);
42+
1143
const getPageMdUrl = () => {
1244
const clean = pathname.replace(/\/$/, '');
1345
return `${clean}.md`;
@@ -30,17 +62,25 @@ export default function ChatbotTrigger() {
3062
}
3163
};
3264

33-
return (
34-
<div className={styles.chatbotTrigger}>
65+
if (windowSize === 'mobile') {
66+
return null;
67+
}
68+
69+
return <>
70+
<hr />
71+
<div
72+
ref={containerRef}
73+
className={`${styles.chatbotTrigger} ${isStuck ? styles.chatbotTriggerStuck : ''}`}
74+
>
3575
<textarea
3676
ref={textareaRef}
3777
className={styles.chatbotTriggerTextarea}
38-
placeholder="Ask a question..."
78+
placeholder="Talk with this document..."
3979
value={value}
4080
onChange={(e) => setValue(e.target.value)}
4181
onKeyDown={handleKeyDown}
4282
rows={2}
43-
aria-label="Ask the AI assistant"
83+
aria-label="Talk with this document"
4484
/>
4585
<div className={styles.chatbotTriggerActions}>
4686
<button
@@ -55,5 +95,5 @@ export default function ChatbotTrigger() {
5595
</button>
5696
</div>
5797
</div>
58-
);
98+
</>;
5999
}

website/src/theme/SearchBar/components/useStreamingChat.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface UseStreamingChatOptions {
2121
}
2222

2323
const API_URL = 'https://docs-mcp-f18b.onrender.com/api/chat';
24+
// const API_URL = 'http://localhost:3001/api/chat';
25+
// const API_URL = 'http://localhost:3001/api/chat/mock';
2426

2527
const metadataSchema = z.object({
2628
sources: z.array(z.object({ title: z.string(), path: z.string() })).optional(),
@@ -30,7 +32,7 @@ export function extractMessageText(message: ChatUIMessage): string {
3032
return message.parts
3133
.filter((p): p is { type: 'text'; text: string } => p.type === 'text')
3234
.map((p) => p.text)
33-
.join('');
35+
.join('\n\n');
3436
}
3537

3638
export function useStreamingChat({ savedConversation, onSaveConversation }: UseStreamingChatOptions) {

website/src/theme/SearchBar/styles.module.css

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,7 @@
790790
}
791791

792792
.chatbotTrigger {
793-
margin: 1rem 0 0.75rem 0;
794-
width: 82%;
793+
margin: 0 auto;
795794
}
796795
}
797796

@@ -920,38 +919,46 @@
920919

921920
.chatbotTrigger {
922921
position: sticky;
923-
bottom: 1rem;
924-
z-index: 10;
922+
bottom: 2rem;
925923
display: flex;
926-
align-items: flex-end;
927-
gap: 0.5rem;
928-
padding: 0.75rem;
929-
margin: 1rem 0 0.75rem 0;
930-
background: var(--ifm-background-surface-color);
931-
border-radius: 12px;
932-
backdrop-filter: blur(8px);
924+
padding: .5rem .8rem;
925+
margin: 0 auto;
926+
border-radius: 8px;
927+
background-color: var(--ifm-background-surface-color);
933928
border: 1px solid var(--ifm-color-emphasis-200);
929+
width: 100%;
930+
max-width: 100%;
931+
transition: max-width 0.2s ease;
932+
}
933+
934+
.chatbotTriggerStuck {
935+
max-width: 60%;
934936
}
935937

936938
.chatbotTriggerTextarea {
937939
flex: 1;
938940
border: none;
939941
outline: none;
940-
resize: none;
942+
backdrop-filter: blur(4px);
941943
background: transparent;
944+
resize: none;
942945
font-size: 0.9375rem;
943-
color: var(--ifm-font-color-base);
944946
font-family: inherit;
945947
line-height: 1.5;
946948
padding: 0;
947949
margin: 0;
948-
min-height: 1.5rem;
950+
max-height: 1.5rem;
949951
}
950952

951953
.chatbotTriggerTextarea::placeholder {
952954
color: var(--ifm-color-emphasis-500);
953955
}
954956

957+
[data-theme='light'] .chatbotTriggerTextarea::placeholder {
958+
color: var(--ifm-color-emphasis-700);
959+
opacity: 1;
960+
}
961+
955962
.chatbotTriggerActions {
956963
display: flex;
957964
align-items: center;
@@ -963,8 +970,8 @@
963970
display: flex;
964971
align-items: center;
965972
justify-content: center;
966-
width: 32px;
967-
height: 32px;
973+
width: 24px;
974+
height: 24px;
968975
border: none;
969976
border-radius: 50%;
970977
cursor: pointer;

website/static/css/custom.scss

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,7 @@ video+p>em,img+p>em,img+em, .monaco+em {
661661
// ============================================================================
662662

663663
.feedback-container {
664-
margin: 2rem 0.8em 2rem 1.75rem;
665-
padding: 1rem;
666-
border: 1px solid var(--ifm-color-emphasis-300);
667-
border-radius: 8px;
664+
padding: 0 1rem 1rem 1rem;
668665
font-size: 0.9rem;
669666
}
670667

@@ -681,14 +678,14 @@ video+p>em,img+p>em,img+em, .monaco+em {
681678
}
682679

683680
.feedback-btn {
684-
padding: 0.375rem 0.75rem;
681+
padding: 0.1rem 0.75rem;
685682
border: 1px solid var(--ifm-color-emphasis-300);
686683
border-radius: 6px;
687-
background-color: var(--ifm-background-surface-color);
688684
color: var(--ifm-color-content);
689685
font-size: 0.85rem;
690686
cursor: pointer;
691687
transition: all 0.2s ease;
688+
text-decoration: none;
692689
}
693690

694691
.feedback-btn:hover {

0 commit comments

Comments
 (0)