Skip to content

Commit c769117

Browse files
committed
fix css issues for lightspeed on RHDH
1 parent 45ecea7 commit c769117

File tree

6 files changed

+40
-23
lines changed

6 files changed

+40
-23
lines changed

workspaces/lightspeed/packages/app/src/components/Root/ApplicationDrawer.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,11 @@ export const ApplicationDrawer = ({
8888
stateExposers = [],
8989
}: ApplicationDrawerProps) => {
9090
const drawerStatesRef = useRef<Map<string, DrawerPartialState>>(new Map());
91-
const [, forceUpdate] = useState({});
9291
const [activeDrawerId, setActiveDrawerId] = useState<string | null>(null);
9392

9493
const handleStateChange = useCallback(
9594
(state: DrawerPartialState) => {
9695
const prev = drawerStatesRef.current.get(state.id);
97-
const hasChanged =
98-
!prev ||
99-
prev.isDrawerOpen !== state.isDrawerOpen ||
100-
prev.drawerWidth !== state.drawerWidth ||
101-
prev.setDrawerWidth !== state.setDrawerWidth;
10296

10397
// If drawer just opened then make it the active drawer
10498
if (!prev?.isDrawerOpen && state.isDrawerOpen) {
@@ -114,10 +108,6 @@ export const ApplicationDrawer = ({
114108
}
115109

116110
drawerStatesRef.current.set(state.id, state);
117-
118-
if (hasChanged) {
119-
forceUpdate({});
120-
}
121111
},
122112
[activeDrawerId],
123113
);

workspaces/lightspeed/plugins/lightspeed/src/components/LightSpeedChat.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,21 @@ export const LightspeedChat = ({
507507
(c: ConversationSummary) => c.conversation_id === conversationId,
508508
);
509509

510+
const getMaxPrompts = () => {
511+
if (displayMode === ChatbotDisplayMode.embedded) {
512+
return samplePrompts?.length; // In the Fullscreen mode, show all prompts
513+
}
514+
if (displayMode === ChatbotDisplayMode.docked) {
515+
return 2; // In the docked mode, show 2 prompts
516+
}
517+
return 1; // In the overlay mode, show 1 prompt
518+
};
519+
const maxPrompts = getMaxPrompts();
520+
510521
const welcomePrompts =
511522
(newChatCreated && conversationMessages.length === 0) ||
512523
(!conversationFound && conversationMessages.length === 0)
513-
? samplePrompts?.map(prompt => {
524+
? samplePrompts?.slice(0, maxPrompts).map(prompt => {
514525
const p = prompt as { title: string; message: string };
515526
return {
516527
title: p.title,

workspaces/lightspeed/plugins/lightspeed/src/components/LightspeedChatBox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export const LightspeedChatBox = forwardRef(
200200
})}
201201
description={t('chatbox.welcome.description')}
202202
prompts={welcomePrompts}
203+
style={{ paddingBottom: '0' }}
203204
/>
204205
) : (
205206
<br />

workspaces/lightspeed/plugins/lightspeed/src/components/LightspeedDrawerProvider.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ import { ChatbotDisplayMode, ChatbotModal } from '@patternfly/chatbot';
2929
import { LightspeedChatContainer } from './LightspeedChatContainer';
3030
import { LightspeedDrawerContext } from './LightspeedDrawerContext';
3131

32-
const useStyles = makeStyles(() => ({
32+
const useStyles = makeStyles(theme => ({
3333
chatbotModal: {
34+
boxShadow:
35+
'0 14px 20px -7px rgba(0, 0, 0, 0.22), 0 32px 50px 6px rgba(0, 0, 0, 0.16), 0 12px 60px 12px rgba(0, 0, 0, 0.14) !important',
36+
bottom: `calc(${theme?.spacing?.(2) ?? '16px'} + 5em)`,
37+
right: `calc(${theme?.spacing?.(2) ?? '16px'} + 1.5em)`,
3438
// When docked drawer is open, adjust modal position
3539
'body.docked-drawer-open &': {
3640
transition: 'margin-right 0.3s ease',
@@ -128,6 +132,10 @@ export const LightspeedDrawerProvider = ({ children }: PropsWithChildren) => {
128132
// Set display mode with route handling for embedded/fullscreen
129133
const setDisplayMode = useCallback(
130134
(mode: ChatbotDisplayMode, conversationId?: string) => {
135+
if (mode === displayModeState) {
136+
return;
137+
}
138+
131139
setDisplayModeState(mode);
132140

133141
// Navigate to fullscreen route with conversation ID if available
@@ -145,7 +153,7 @@ export const LightspeedDrawerProvider = ({ children }: PropsWithChildren) => {
145153
setIsOpen(true);
146154
}
147155
},
148-
[navigate, isLightspeedRoute, currentConversationIdState],
156+
[navigate, isLightspeedRoute, currentConversationIdState, displayModeState],
149157
);
150158

151159
// Only render ChatbotModal for overlay mode

workspaces/lightspeed/plugins/lightspeed/src/components/LightspeedFAB.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ import { useLightspeedDrawerContext } from '../hooks/useLightspeedDrawerContext'
2424
import { LightspeedFABIcon } from './LightspeedIcon';
2525

2626
const useStyles = makeStyles(theme => ({
27+
fab: {
28+
opacity: '1 !important',
29+
backgroundColor: `${theme?.palette?.primary?.main ?? '#1976d2'} !important`,
30+
color: `${theme?.palette?.primary?.contrastText ?? '#fff'} !important`,
31+
boxShadow: `${
32+
theme?.shadows?.[6] ??
33+
'0px 3px 5px -1px rgba(0,0,0,0.2), 0px 6px 10px 0px rgba(0,0,0,0.14), 0px 1px 18px 0px rgba(0,0,0,0.12)'
34+
} !important`,
35+
'&:hover': {
36+
backgroundColor: `${theme?.palette?.primary?.dark ?? '#1565c0'} !important`,
37+
boxShadow: `${
38+
theme?.shadows?.[8] ??
39+
'0px 5px 5px -3px rgba(0,0,0,0.2), 0px 8px 10px 1px rgba(0,0,0,0.14), 0px 3px 14px 2px rgba(0,0,0,0.12)'
40+
} !important`,
41+
},
42+
},
2743
'fab-button': {
2844
bottom: `calc(${theme?.spacing?.(2) ?? '16px'} + 1.5em)`,
2945
right: `calc(${theme?.spacing?.(2) ?? '16px'} + 1.5em)`,
@@ -70,6 +86,7 @@ export const LightspeedFAB = () => {
7086
size="small"
7187
onClick={toggleChatbot}
7288
aria-label={isChatbotActive ? 'lightspeed-open' : 'lightspeed-close'}
89+
className={fabButton.fab}
7390
sx={{ borderRadius: '100% !important' }}
7491
>
7592
{isChatbotActive ? <Close fontSize="small" /> : <LightspeedFABIcon />}

workspaces/quickstart/packages/app/src/components/Root/ApplicationDrawer.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,11 @@ export const ApplicationDrawer = ({
8888
stateExposers = [],
8989
}: ApplicationDrawerProps) => {
9090
const drawerStatesRef = useRef<Map<string, DrawerPartialState>>(new Map());
91-
const [, forceUpdate] = useState({});
9291
const [activeDrawerId, setActiveDrawerId] = useState<string | null>(null);
9392

9493
const handleStateChange = useCallback(
9594
(state: DrawerPartialState) => {
9695
const prev = drawerStatesRef.current.get(state.id);
97-
const hasChanged =
98-
!prev ||
99-
prev.isDrawerOpen !== state.isDrawerOpen ||
100-
prev.drawerWidth !== state.drawerWidth ||
101-
prev.setDrawerWidth !== state.setDrawerWidth;
10296

10397
// If drawer just opened then make it the active drawer
10498
if (!prev?.isDrawerOpen && state.isDrawerOpen) {
@@ -114,10 +108,6 @@ export const ApplicationDrawer = ({
114108
}
115109

116110
drawerStatesRef.current.set(state.id, state);
117-
118-
if (hasChanged) {
119-
forceUpdate({});
120-
}
121111
},
122112
[activeDrawerId],
123113
);

0 commit comments

Comments
 (0)