Skip to content

Commit a106a49

Browse files
Merge pull request #851 from rebeccaalpert/icon
fix(ChatbotToggle): Adjust icon
2 parents dba0d76 + 2ecc4fe commit a106a49

9 files changed

Lines changed: 263 additions & 87 deletions

File tree

package-lock.json

Lines changed: 176 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@octokit/rest": "^18.0.0",
4242
"@patternfly/documentation-framework": "6.28.9",
4343
"@patternfly/patternfly": "^6.1.0",
44-
"@patternfly/react-icons": "^6.1.0",
44+
"@patternfly/react-icons": "^6.5.1",
4545
"@patternfly/react-table": "^6.1.0",
4646
"@swc/core": "1.3.96",
4747
"@testing-library/dom": "^9.3.4",

packages/module/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"dependencies": {
3636
"@patternfly/react-code-editor": "^6.1.0",
3737
"@patternfly/react-core": "^6.1.0",
38-
"@patternfly/react-icons": "^6.1.0",
38+
"@patternfly/react-icons": "^6.5.1",
3939
"@patternfly/react-styles": "^6.1.0",
4040
"@patternfly/react-table": "^6.1.0",
4141
"@segment/analytics-next": "^1.76.0",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { FunctionComponent, useState } from 'react';
2+
import ChatbotToggle from '@patternfly/chatbot/dist/dynamic/ChatbotToggle';
3+
4+
export const SecondaryChatbotToggle: FunctionComponent = () => {
5+
const [chatbotVisible, setChatbotVisible] = useState<boolean>(false);
6+
7+
return (
8+
<ChatbotToggle
9+
tooltipLabel="Virtual assistant"
10+
isChatbotVisible={chatbotVisible}
11+
onToggleChatbot={() => setChatbotVisible(!chatbotVisible)}
12+
colorVariant="secondary"
13+
/>
14+
);
15+
};

packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ To allow users to open and close the ChatBot window as needed, add a toggle.
165165

166166
```
167167

168+
### Secondary color toggle
169+
170+
Use `colorVariant="secondary"` for a light gray toggle with a default border. This is useful when the floating default style does not match the surrounding UI.
171+
172+
```js file="./SecondaryChatbotToggle.tsx" isFullscreen
173+
174+
```
175+
168176
### Custom toggle icon
169177

170178
A custom icon can be passed to the toggle. To ensure the icon is visible in both light and dark themes, use an SVG image and set `fill="currentColor"`.

packages/module/src/ChatbotToggle/ChatbotToggle.scss

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
position: fixed;
66
inset-block-end: var(--pf-t--global--spacer--md);
77
inset-inline-end: var(--pf-t--global--spacer--md);
8-
background-color: var(--pf-t--global--background--color--inverse--default);
9-
--pf-v6-c-button__icon--Color: var(--pf-t--global--icon--color--inverse);
8+
--pf-v6-c-button--m-plain--BackgroundColor: var(--pf-t--global--background--color--floating--default);
9+
--pf-v6-c-button--m-plain--hover--BackgroundColor: var(--pf-t--global--background--color--floating--hover);
10+
--pf-v6-c-button--m-plain--m-clicked--BackgroundColor: var(--pf-t--global--background--color--floating--clicked);
11+
--pf-v6-c-button--m-plain--BorderColor: var(--pf-t--global--border--color--default);
12+
--pf-v6-c-button--m-plain--hover--BorderColor: var(--pf-t--global--border--color--default);
13+
--pf-v6-c-button--m-plain--m-clicked--BorderColor: var(--pf-t--global--border--color--default);
14+
--pf-v6-c-button--m-plain--BorderWidth: 1px;
15+
--pf-v6-c-button--m-plain--hover--BorderWidth: 1px;
16+
--pf-v6-c-button--m-plain--m-clicked--BorderWidth: 1px;
1017
padding: var(--pf-t--global--spacer--md);
11-
12-
&:hover,
13-
&:focus {
14-
background-color: var(--pf-t--color--gray--70);
15-
}
18+
box-shadow: var(--pf-t--global--box-shadow--sm);
1619

1720
.pf-v6-c-button__icon {
1821
display: contents;
@@ -23,6 +26,20 @@
2326
width: var(--pf-t--global--spacer--lg);
2427
height: var(--pf-t--global--spacer--lg);
2528
}
29+
30+
&--active {
31+
--pf-v6-c-button--m-plain--BackgroundColor: var(--pf-t--global--background--color--floating--clicked);
32+
}
33+
34+
&--secondary {
35+
--pf-v6-c-button--m-plain--BackgroundColor: var(--pf-t--global--background--color--secondary--default);
36+
--pf-v6-c-button--m-plain--hover--BackgroundColor: var(--pf-t--global--background--color--secondary--hover);
37+
--pf-v6-c-button--m-plain--m-clicked--BackgroundColor: var(--pf-t--global--background--color--secondary--clicked);
38+
39+
&.pf-chatbot__button--active {
40+
--pf-v6-c-button--m-plain--BackgroundColor: var(--pf-t--global--background--color--secondary--clicked);
41+
}
42+
}
2643
}
2744

2845
.pf-chatbot__button--round {

packages/module/src/ChatbotToggle/ChatbotToggle.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ describe('ChatbotToggle', () => {
4343
expect(screen.getByRole('button')).toHaveClass('pf-chatbot__button');
4444
expect(screen.getByRole('button')).toHaveClass('test');
4545
});
46+
it('should handle colorVariant secondary correctly', () => {
47+
render(<ChatbotToggle tooltipLabel="Chatbot" colorVariant="secondary" />);
48+
expect(screen.getByRole('button')).toHaveClass('pf-chatbot__button--secondary');
49+
});
4650
});

packages/module/src/ChatbotToggle/ChatbotToggle.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Ref, FunctionComponent } from 'react';
55

66
import { forwardRef } from 'react';
77
import { Button, ButtonProps, Tooltip, TooltipProps, Icon } from '@patternfly/react-core';
8-
import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
8+
import RhMicronsCaretDownIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-caret-down-icon';
99

1010
export interface ChatbotToggleProps extends ButtonProps {
1111
/** Contents of the tooltip applied to the toggle button */
@@ -28,24 +28,23 @@ export interface ChatbotToggleProps extends ButtonProps {
2828
className?: string;
2929
/** Test id applied to default open icon */
3030
openIconTestId?: string;
31+
/** Color variant applied to the toggle button */
32+
colorVariant?: 'default' | 'secondary';
3133
}
3234

3335
const ChatIcon = () => (
34-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
35-
<path
36-
fill="var(--pf-t--global--icon--color--inverse)"
37-
stroke="var(--pf-t--global--icon--color--inverse)"
38-
strokeLinejoin="round"
39-
strokeWidth=".75"
40-
d="M3.577 14.382c0 .198.12.38.31.46l.19.04a.492.492 0 0 0 .349-.143l3.028-3.028h8.513a.489.489 0 0 0 .492-.492V2.491A.489.489 0 0 0 15.967 2H1.691a.489.489 0 0 0-.492.491v8.728c0 .135.056.262.143.349a.498.498 0 0 0 .349.143h1.878v2.663h.008v.008ZM2.19 10.72V2.983h13.278v7.729H7.24a.512.512 0 0 0-.35.143l-2.322 2.322v-1.974a.498.498 0 0 0-.142-.348.492.492 0 0 0-.35-.143H2.19v.008Z"
41-
/>
42-
<path
43-
fill="var(--pf-t--global--text--color--inverse)"
44-
stroke="var(--pf-t--global--text--color--inverse)"
45-
strokeLinejoin="round"
46-
strokeWidth=".75"
47-
d="M22.301 9.135h-3.963a.489.489 0 0 0-.492.491c0 .27.222.492.492.492h3.472v7.737h-1.88a.404.404 0 0 0-.348.134.492.492 0 0 0-.143.35v1.973l-2.322-2.323a.492.492 0 0 0-.349-.142H8.532v-4.265a.489.489 0 0 0-.492-.492.494.494 0 0 0-.491.492v4.756c0 .277.222.492.491.492h8.514l3.028 3.028a.492.492 0 0 0 .349.142l.19-.04a.502.502 0 0 0 .31-.459V18.83h1.878c.111-.008.262-.048.349-.135a.491.491 0 0 0 .142-.349v-8.72a.489.489 0 0 0-.491-.491h-.008Z"
48-
/>
36+
<svg xmlns="http://www.w3.org/2000/svg" width="33" height="31" viewBox="0 0 33 31" fill="none">
37+
<g clipPath="url(#clip0_11685_20917)">
38+
<path
39+
d="M29.7 11.0714H17.6V7.75H19.525C20.2834 7.75 20.9 7.12939 20.9 6.36607V1.38393C20.9 0.620609 20.2834 0 19.525 0H13.475C12.7166 0 12.1 0.620609 12.1 1.38393V6.36607C12.1 7.12939 12.7166 7.75 13.475 7.75H15.4V11.0714H3.3C1.48027 11.0714 0 12.5613 0 14.3929V27.6786C0 29.5101 1.48027 31 3.3 31H29.7C31.5197 31 33 29.5101 33 27.6786V14.3929C33 12.5613 31.5197 11.0714 29.7 11.0714ZM14.3 2.21429H18.7V5.53571H14.3V2.21429ZM30.8 27.6786C30.8 28.2894 30.3069 28.7857 29.7 28.7857H3.3C2.6936 28.7857 2.2 28.2894 2.2 27.6786V14.3929C2.2 13.7825 2.6936 13.2857 3.3 13.2857H29.7C30.3069 13.2857 30.8 13.7825 30.8 14.3929V27.6786ZM8.525 17.7143V19.9286C8.525 20.387 8.15547 20.7589 7.7 20.7589H5.5C5.04453 20.7589 4.675 20.387 4.675 19.9286V17.7143C4.675 17.2559 5.04453 16.8839 5.5 16.8839H7.7C8.15547 16.8839 8.525 17.2559 8.525 17.7143ZM28.325 17.7143V19.9286C28.325 20.387 27.9555 20.7589 27.5 20.7589H25.3C24.8445 20.7589 24.475 20.387 24.475 19.9286V17.7143C24.475 17.2559 24.8445 16.8839 25.3 16.8839H27.5C27.9555 16.8839 28.325 17.2559 28.325 17.7143ZM20.5691 22.6683C20.8893 23.0965 20.8033 23.703 20.3779 24.0241C19.2521 24.8761 17.9115 25.3259 16.5 25.3259C15.0885 25.3259 13.7473 24.8761 12.6215 24.0241C12.1961 23.703 12.1107 23.0965 12.4298 22.6683C12.7494 22.2391 13.3536 22.1526 13.7774 22.4759C15.3576 23.6695 17.6408 23.6695 19.2221 22.4759C19.6475 22.1515 20.2512 22.2402 20.5691 22.6683Z"
40+
fill="currentColor"
41+
/>
42+
</g>
43+
<defs>
44+
<clipPath id="clip0_11685_20917">
45+
<rect width="33" height="31" fill="currentColor" />
46+
</clipPath>
47+
</defs>
4948
</svg>
5049
);
5150

@@ -60,11 +59,12 @@ const ChatbotToggleBase: FunctionComponent<ChatbotToggleProps> = ({
6059
isRound = true,
6160
className,
6261
openIconTestId,
62+
colorVariant = 'default',
6363
...props
6464
}: ChatbotToggleProps) => {
6565
// Configure icon
6666
const closedIcon = ClosedToggleIcon ? <ClosedToggleIcon /> : <ChatIcon />;
67-
const icon = isChatbotVisible ? <AngleDownIcon data-testid={openIconTestId} /> : closedIcon;
67+
const icon = isChatbotVisible ? <RhMicronsCaretDownIcon data-testid={openIconTestId} /> : closedIcon;
6868

6969
return (
7070
<Tooltip
@@ -74,7 +74,7 @@ const ChatbotToggleBase: FunctionComponent<ChatbotToggleProps> = ({
7474
{...tooltipProps}
7575
>
7676
<Button
77-
className={`pf-chatbot__button ${isChatbotVisible ? 'pf-chatbot__button--active' : ''} ${isRound ? 'pf-chatbot__button--round' : ''} ${className ? className : ''}`}
77+
className={`pf-chatbot__button ${colorVariant === 'secondary' ? 'pf-chatbot__button--secondary' : ''} ${isChatbotVisible ? 'pf-chatbot__button--active' : ''} ${isRound ? 'pf-chatbot__button--round' : ''} ${className ? className : ''}`}
7878
variant="plain"
7979
aria-label={toggleButtonLabel || `${tooltipLabel} toggle`}
8080
onClick={onToggleChatbot}

packages/module/src/LoadingMessage/__snapshots__/LoadingMessage.test.tsx.snap

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,24 @@ exports[`LoadingMessage should render loading message 1`] = `
2020
fill="currentColor"
2121
height="1em"
2222
role="img"
23-
viewBox="0 0 640 512"
2423
width="1em"
2524
>
26-
<path
27-
d="M32,224H64V416H32A31.96166,31.96166,0,0,1,0,384V256A31.96166,31.96166,0,0,1,32,224Zm512-48V448a64.06328,64.06328,0,0,1-64,64H160a64.06328,64.06328,0,0,1-64-64V176a79.974,79.974,0,0,1,80-80H288V32a32,32,0,0,1,64,0V96H464A79.974,79.974,0,0,1,544,176ZM264,256a40,40,0,1,0-40,40A39.997,39.997,0,0,0,264,256Zm-8,128H192v32h64Zm96,0H288v32h64ZM456,256a40,40,0,1,0-40,40A39.997,39.997,0,0,0,456,256Zm-8,128H384v32h64ZM640,256V384a31.96166,31.96166,0,0,1-32,32H576V224h32A31.96166,31.96166,0,0,1,640,256Z"
28-
/>
25+
<svg
26+
class="pf-v6-icon-default"
27+
viewBox="0 0 640 512"
28+
>
29+
<path
30+
d="M32,224H64V416H32A31.96166,31.96166,0,0,1,0,384V256A31.96166,31.96166,0,0,1,32,224Zm512-48V448a64.06328,64.06328,0,0,1-64,64H160a64.06328,64.06328,0,0,1-64-64V176a79.974,79.974,0,0,1,80-80H288V32a32,32,0,0,1,64,0V96H464A79.974,79.974,0,0,1,544,176ZM264,256a40,40,0,1,0-40,40A39.997,39.997,0,0,0,264,256Zm-8,128H192v32h64Zm96,0H288v32h64ZM456,256a40,40,0,1,0-40,40A39.997,39.997,0,0,0,456,256Zm-8,128H384v32h64ZM640,256V384a31.96166,31.96166,0,0,1-32,32H576V224h32A31.96166,31.96166,0,0,1,640,256Z"
31+
/>
32+
</svg>
33+
<svg
34+
class="pf-v6-icon-rh-ui"
35+
viewBox="0 0 32 32"
36+
>
37+
<path
38+
d="M29 22.5V29a1 1 0 1 1-2 0v-6H5v6a1 1 0 1 1-2 0v-6.5c0-.827.673-1.5 1.5-1.5h23c.827 0 1.5.673 1.5 1.5ZM3 11a1 1 0 0 1 1-1h2V5.5C6 4.673 6.673 4 7.5 4H12V2a1 1 0 1 1 2 0v2h4V2a1 1 0 1 1 2 0v2h4.5c.827 0 1.5.673 1.5 1.5V10h2a1 1 0 1 1 0 2h-2v4.5c0 .827-.673 1.5-1.5 1.5h-17c-.827 0-1.5-.673-1.5-1.5V12H4a1 1 0 0 1-1-1Zm5 5h16V6H8v10Zm5-6.612a1.626 1.626 0 1 0 .001 3.251A1.626 1.626 0 0 0 13 9.388Zm6-.01a1.626 1.626 0 1 0 .001 3.251A1.626 1.626 0 0 0 19 9.378Z"
39+
/>
40+
</svg>
2941
</svg>
3042
</span>
3143
</span>

0 commit comments

Comments
 (0)