From e5d3f7aa6559507289dd43d8a11d155046190ce0 Mon Sep 17 00:00:00 2001
From: juliajforesti
Date: Wed, 10 Jan 2024 16:00:33 -0300
Subject: [PATCH 01/18] feat(fuselage): `Bubble` (wip)
---
.../src/components/Bubble/Bubble.spec.tsx | 31 ++++++++++++
.../src/components/Bubble/Bubble.stories.tsx | 23 +++++++++
.../src/components/Bubble/Bubble.styles.scss | 33 +++++++++++++
.../fuselage/src/components/Bubble/Bubble.tsx | 48 +++++++++++++++++++
.../fuselage/src/components/Bubble/index.ts | 1 +
packages/fuselage/src/components/index.scss | 1 +
packages/fuselage/src/components/index.ts | 1 +
7 files changed, 138 insertions(+)
create mode 100644 packages/fuselage/src/components/Bubble/Bubble.spec.tsx
create mode 100644 packages/fuselage/src/components/Bubble/Bubble.stories.tsx
create mode 100644 packages/fuselage/src/components/Bubble/Bubble.styles.scss
create mode 100644 packages/fuselage/src/components/Bubble/Bubble.tsx
create mode 100644 packages/fuselage/src/components/Bubble/index.ts
diff --git a/packages/fuselage/src/components/Bubble/Bubble.spec.tsx b/packages/fuselage/src/components/Bubble/Bubble.spec.tsx
new file mode 100644
index 0000000000..088d7d0538
--- /dev/null
+++ b/packages/fuselage/src/components/Bubble/Bubble.spec.tsx
@@ -0,0 +1,31 @@
+import { composeStories } from '@storybook/testing-react';
+import { render } from '@testing-library/react';
+import { axe } from 'jest-axe';
+import React from 'react';
+
+import * as stories from './Bubble.stories';
+
+const testCases = Object.values(composeStories(stories)).map((Story) => [
+ Story.storyName || 'Story',
+ Story,
+]);
+
+describe('[Bubble Rendering]', () => {
+ test.each(testCases)(
+ `renders %s without crashing`,
+ async (_storyname, Story) => {
+ const tree = render();
+ expect(tree.baseElement).toMatchSnapshot();
+ }
+ );
+
+ test.each(testCases)(
+ '%s should have no a11y violations',
+ async (_storyname, Story) => {
+ const { container } = render();
+
+ const results = await axe(container);
+ expect(results).toHaveNoViolations();
+ }
+ );
+});
diff --git a/packages/fuselage/src/components/Bubble/Bubble.stories.tsx b/packages/fuselage/src/components/Bubble/Bubble.stories.tsx
new file mode 100644
index 0000000000..3057bf7735
--- /dev/null
+++ b/packages/fuselage/src/components/Bubble/Bubble.stories.tsx
@@ -0,0 +1,23 @@
+import type { ComponentMeta, ComponentStory } from '@storybook/react';
+import React from 'react';
+
+import Bubble from '.';
+
+export default {
+ title: 'Components/Bubble',
+ component: Bubble,
+} as ComponentMeta;
+
+const Template: ComponentStory = (args) => ;
+
+export const Default = Template.bind({});
+Default.args = {
+ children: 'New messages',
+ icon: 'arrow-down',
+};
+export const WithDismiss = Template.bind({});
+WithDismiss.args = {
+ children: 'New messages',
+ icon: 'arrow-down',
+ onDismiss: () => console.log('dismiss'),
+};
diff --git a/packages/fuselage/src/components/Bubble/Bubble.styles.scss b/packages/fuselage/src/components/Bubble/Bubble.styles.scss
new file mode 100644
index 0000000000..a3deae7e44
--- /dev/null
+++ b/packages/fuselage/src/components/Bubble/Bubble.styles.scss
@@ -0,0 +1,33 @@
+@use '../../styles/colors.scss';
+@use '../../styles/lengths.scss';
+@use '../../styles/typography.scss';
+
+.rcx-button.rcx-bubble {
+ @include typography.use-font-scale(c2);
+
+ display: flex;
+ align-items: center;
+
+ height: lengths.size(28);
+
+ padding: lengths.padding(none);
+
+ cursor: pointer;
+ text-align: center;
+
+ border-radius: 20px;
+}
+
+.rcx-bubble {
+ &--content,
+ &--dismiss {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+ padding-inline-start: lengths.padding(12);
+ padding-inline-end: lengths.padding(16);
+
+ transform: none !important;
+ }
+}
diff --git a/packages/fuselage/src/components/Bubble/Bubble.tsx b/packages/fuselage/src/components/Bubble/Bubble.tsx
new file mode 100644
index 0000000000..b96978d4a3
--- /dev/null
+++ b/packages/fuselage/src/components/Bubble/Bubble.tsx
@@ -0,0 +1,48 @@
+import type { Keys as IconName } from '@rocket.chat/icons';
+import type { ButtonHTMLAttributes, ReactNode } from 'react';
+import React from 'react';
+
+import { Icon } from '../Icon';
+
+type BubbleProps = {
+ children: ReactNode;
+ onClick: () => void;
+ icon: IconName;
+ onDismiss?: () => void;
+} & ButtonHTMLAttributes;
+
+const Bubble = ({
+ children,
+ onClick,
+ icon,
+ onDismiss,
+ ...props
+}: BubbleProps) => {
+ console.log('');
+ return (
+
+ );
+};
+
+export default Bubble;
diff --git a/packages/fuselage/src/components/Bubble/index.ts b/packages/fuselage/src/components/Bubble/index.ts
new file mode 100644
index 0000000000..1c2c1c422a
--- /dev/null
+++ b/packages/fuselage/src/components/Bubble/index.ts
@@ -0,0 +1 @@
+export { default } from './Bubble';
diff --git a/packages/fuselage/src/components/index.scss b/packages/fuselage/src/components/index.scss
index 5b762d00d3..748bb20a34 100644
--- a/packages/fuselage/src/components/index.scss
+++ b/packages/fuselage/src/components/index.scss
@@ -5,6 +5,7 @@
@import './Badge/Badge.styles.scss';
@import './Box/Box.styles.scss';
@import './Button/Button.styles.scss';
+@import './Bubble/Bubble.styles.scss';
@import './ButtonGroup/ButtonGroup.styles.scss';
@import './Callout/Callout.styles.scss';
@import './Card/Card.styles.scss';
diff --git a/packages/fuselage/src/components/index.ts b/packages/fuselage/src/components/index.ts
index 6b4f9e3f0c..d64021f6b1 100644
--- a/packages/fuselage/src/components/index.ts
+++ b/packages/fuselage/src/components/index.ts
@@ -8,6 +8,7 @@ export { default as Banner } from './Banner';
export { default as Box } from './Box';
export { useArrayLikeClassNameProp } from '../hooks/useArrayLikeClassNameProp';
export { default as Button, ActionButton, IconButton } from './Button';
+export * from './Bubble';
export * from './ButtonGroup';
export * from './Callout';
export * from './Card';
From f2e9d9732626e0a341e7558c46ae305bbf12b2d3 Mon Sep 17 00:00:00 2001
From: juliajforesti
Date: Fri, 12 Jan 2024 11:43:59 -0300
Subject: [PATCH 02/18] feat: bubble-group to handle button states separately
---
.../src/components/Bubble/Bubble.styles.scss | 38 +++++++++-----
.../fuselage/src/components/Bubble/Bubble.tsx | 49 +++++++++----------
.../src/styles/mixins/interactivity.scss | 9 ++++
3 files changed, 57 insertions(+), 39 deletions(-)
diff --git a/packages/fuselage/src/components/Bubble/Bubble.styles.scss b/packages/fuselage/src/components/Bubble/Bubble.styles.scss
index a3deae7e44..cc104d9ad0 100644
--- a/packages/fuselage/src/components/Bubble/Bubble.styles.scss
+++ b/packages/fuselage/src/components/Bubble/Bubble.styles.scss
@@ -2,32 +2,44 @@
@use '../../styles/lengths.scss';
@use '../../styles/typography.scss';
-.rcx-button.rcx-bubble {
- @include typography.use-font-scale(c2);
+@use '../../styles/variables/buttons.scss' as buttonColors;
+@use '../../styles/primitives/button.scss';
+@use '../../styles/mixins/interactivity.scss';
+.rcx-bubble {
display: flex;
align-items: center;
- height: lengths.size(28);
-
- padding: lengths.padding(none);
-
- cursor: pointer;
- text-align: center;
-
- border-radius: 20px;
-}
-
-.rcx-bubble {
&--content,
&--dismiss {
+ @include typography.use-font-scale(c2);
+ @include button.kind-variant(buttonColors.$primary);
+ @include clickable;
+ @include click-animation();
+
display: flex;
justify-content: center;
align-items: center;
+ height: lengths.size(28);
+
padding-inline-start: lengths.padding(12);
padding-inline-end: lengths.padding(16);
transform: none !important;
+
+ border-radius: 20px;
+ }
+
+ &--group {
+ :first-child {
+ border-top-right-radius: 0;
+ border-bottom-right-radius: 0;
+ }
+
+ :last-child {
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+ }
}
}
diff --git a/packages/fuselage/src/components/Bubble/Bubble.tsx b/packages/fuselage/src/components/Bubble/Bubble.tsx
index b96978d4a3..e8b9f099d6 100644
--- a/packages/fuselage/src/components/Bubble/Bubble.tsx
+++ b/packages/fuselage/src/components/Bubble/Bubble.tsx
@@ -17,32 +17,29 @@ const Bubble = ({
icon,
onDismiss,
...props
-}: BubbleProps) => {
- console.log('');
- return (
-
{onDismiss && (
-
+
Date: Fri, 12 Jan 2024 13:00:32 -0300
Subject: [PATCH 06/18] chore: update snapshot
---
.../Bubble/__snapshots__/Bubble.spec.tsx.snap | 60 +++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
diff --git a/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap b/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
new file mode 100644
index 0000000000..c4f9eaaff7
--- /dev/null
+++ b/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
@@ -0,0 +1,60 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`[Bubble Rendering] renders Default without crashing 1`] = `
+
+
+
+
+
+
+
+
+ New messages
+
+
+
+
+
+`;
+
+exports[`[Bubble Rendering] renders WithDismiss without crashing 1`] = `
+
+
+
+
+
+
+
+
+ New messages
+
+
+
+
+
+
+
+
+
+
+`;
From 9a9a8348e109a62478a743aab88ae72c2c3e132a Mon Sep 17 00:00:00 2001
From: juliajforesti
Date: Fri, 12 Jan 2024 14:59:51 -0300
Subject: [PATCH 07/18] fix: click-animation
---
packages/fuselage/src/styles/mixins/interactivity.scss | 3 +--
packages/fuselage/src/styles/primitives/button.scss | 4 ++++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/packages/fuselage/src/styles/mixins/interactivity.scss b/packages/fuselage/src/styles/mixins/interactivity.scss
index dbe8e7d5af..a22159c0f4 100644
--- a/packages/fuselage/src/styles/mixins/interactivity.scss
+++ b/packages/fuselage/src/styles/mixins/interactivity.scss
@@ -11,8 +11,7 @@
@mixin click-animation($excludeRole: false) {
@include on-active {
- > *:not([role='#{$excludeRole}']),
- > *:not[aria-disabled='true'] {
+ > *:not([role='#{$excludeRole}']) {
transform: translateY(1px);
}
}
diff --git a/packages/fuselage/src/styles/primitives/button.scss b/packages/fuselage/src/styles/primitives/button.scss
index 4cbbafef70..a495ea177b 100644
--- a/packages/fuselage/src/styles/primitives/button.scss
+++ b/packages/fuselage/src/styles/primitives/button.scss
@@ -42,5 +42,9 @@
color: map.get($colors, disabled-color);
border-color: map.get($colors, disabled-border-color);
background-color: map.get($colors, disabled-background-color);
+
+ .rcx-button--content {
+ transform: none !important;
+ }
}
}
From 4517e36bff1bf58870564478520032b7cf690d7c Mon Sep 17 00:00:00 2001
From: juliajforesti
Date: Fri, 12 Jan 2024 15:51:01 -0300
Subject: [PATCH 08/18] chore: improve stories
---
.../src/components/Bubble/Bubble.stories.tsx | 18 ++++++++++++++----
.../fuselage/src/components/Bubble/Bubble.tsx | 2 +-
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/packages/fuselage/src/components/Bubble/Bubble.stories.tsx b/packages/fuselage/src/components/Bubble/Bubble.stories.tsx
index 3057bf7735..c78c97b8db 100644
--- a/packages/fuselage/src/components/Bubble/Bubble.stories.tsx
+++ b/packages/fuselage/src/components/Bubble/Bubble.stories.tsx
@@ -1,3 +1,4 @@
+import { action } from '@storybook/addon-actions';
import type { ComponentMeta, ComponentStory } from '@storybook/react';
import React from 'react';
@@ -10,14 +11,23 @@ export default {
const Template: ComponentStory = (args) => ;
-export const Default = Template.bind({});
-Default.args = {
+export const IconAndLabel = Template.bind({});
+IconAndLabel.args = {
children: 'New messages',
+ onClick: action('click'),
icon: 'arrow-down',
};
-export const WithDismiss = Template.bind({});
-WithDismiss.args = {
+
+export const Dismissable = Template.bind({});
+Dismissable.args = {
children: 'New messages',
icon: 'arrow-down',
+ onClick: action('click'),
onDismiss: () => console.log('dismiss'),
};
+
+export const LabelOnly = Template.bind({});
+LabelOnly.args = {
+ children: 'See new messages',
+ onClick: action('click'),
+};
diff --git a/packages/fuselage/src/components/Bubble/Bubble.tsx b/packages/fuselage/src/components/Bubble/Bubble.tsx
index ae505ccf7f..d8b0646776 100644
--- a/packages/fuselage/src/components/Bubble/Bubble.tsx
+++ b/packages/fuselage/src/components/Bubble/Bubble.tsx
@@ -7,7 +7,7 @@ import { Icon } from '../Icon';
type BubbleProps = {
children: ReactNode;
onClick: () => void;
- icon: IconName;
+ icon?: IconName;
onDismiss?: () => void;
} & ButtonHTMLAttributes;
From 86d97419ab094e73bbbe4861705850c46bc55878 Mon Sep 17 00:00:00 2001
From: juliajforesti
Date: Fri, 12 Jan 2024 15:54:21 -0300
Subject: [PATCH 09/18] chore: HTML attributes props
---
packages/fuselage/src/components/Bubble/Bubble.tsx | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/packages/fuselage/src/components/Bubble/Bubble.tsx b/packages/fuselage/src/components/Bubble/Bubble.tsx
index d8b0646776..20326b413c 100644
--- a/packages/fuselage/src/components/Bubble/Bubble.tsx
+++ b/packages/fuselage/src/components/Bubble/Bubble.tsx
@@ -1,5 +1,5 @@
import type { Keys as IconName } from '@rocket.chat/icons';
-import type { ButtonHTMLAttributes, ReactNode } from 'react';
+import type { AllHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
import React from 'react';
import { Icon } from '../Icon';
@@ -9,21 +9,26 @@ type BubbleProps = {
onClick: () => void;
icon?: IconName;
onDismiss?: () => void;
-} & ButtonHTMLAttributes;
+ contentProps?: ButtonHTMLAttributes;
+ dismissProps?: ButtonHTMLAttributes;
+} & AllHTMLAttributes;
const Bubble = ({
children,
onClick,
icon,
onDismiss,
+ contentProps,
+ dismissProps,
...props
}: BubbleProps) => (
-
+
{icon && }
{children}
@@ -32,7 +37,7 @@ const Bubble = ({
aria-label={`Dismiss ${children}`}
className='rcx-bubble--dismiss'
onClick={onClick}
- {...props}
+ {...dismissProps}
>
Date: Fri, 12 Jan 2024 15:58:07 -0300
Subject: [PATCH 10/18] chore: dismiss action
---
.../fuselage/src/components/Bubble/Bubble.stories.tsx | 2 +-
packages/fuselage/src/components/Bubble/Bubble.tsx | 11 ++---------
2 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/packages/fuselage/src/components/Bubble/Bubble.stories.tsx b/packages/fuselage/src/components/Bubble/Bubble.stories.tsx
index c78c97b8db..d883ae68e6 100644
--- a/packages/fuselage/src/components/Bubble/Bubble.stories.tsx
+++ b/packages/fuselage/src/components/Bubble/Bubble.stories.tsx
@@ -23,7 +23,7 @@ Dismissable.args = {
children: 'New messages',
icon: 'arrow-down',
onClick: action('click'),
- onDismiss: () => console.log('dismiss'),
+ onDismiss: action('dismiss'),
};
export const LabelOnly = Template.bind({});
diff --git a/packages/fuselage/src/components/Bubble/Bubble.tsx b/packages/fuselage/src/components/Bubble/Bubble.tsx
index 20326b413c..74a32d1680 100644
--- a/packages/fuselage/src/components/Bubble/Bubble.tsx
+++ b/packages/fuselage/src/components/Bubble/Bubble.tsx
@@ -36,17 +36,10 @@ const Bubble = ({
- {
- e.stopPropagation();
- onDismiss();
- }}
- />
+
)}
From 89a9058b186457a5e941d6950b1736e75b55dd8d Mon Sep 17 00:00:00 2001
From: juliajforesti
Date: Fri, 12 Jan 2024 17:38:11 -0300
Subject: [PATCH 11/18] chore: update snapshot
---
.../Bubble/__snapshots__/Bubble.spec.tsx.snap | 64 +++++++++++++++----
1 file changed, 52 insertions(+), 12 deletions(-)
diff --git a/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap b/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
index c4f9eaaff7..e2518826bb 100644
--- a/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
+++ b/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
@@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`[Bubble Rendering] renders Default without crashing 1`] = `
+exports[`[Bubble Rendering] renders Dismissable without crashing 1`] = `
`;
-exports[`[Bubble Rendering] renders WithDismiss without crashing 1`] = `
+exports[`[Bubble Rendering] renders IconAndLabel without crashing 1`] = `
+
+`;
+
+exports[`[Bubble Rendering] renders LabelOnly without crashing 1`] = `
+
+
+
-
-
-
+
+ See new messages
+
`;
+
+exports[`[Bubble Rendering] renders RichContentTest without crashing 1`] = `
+
+
+
+`;
From 8d5b208aa25ee33db9be05bdf2bbcdb245bc2314 Mon Sep 17 00:00:00 2001
From: juliajforesti
Date: Mon, 15 Jan 2024 12:03:48 -0300
Subject: [PATCH 12/18] style
---
packages/fuselage/src/components/Bubble/Bubble.styles.scss | 2 --
1 file changed, 2 deletions(-)
diff --git a/packages/fuselage/src/components/Bubble/Bubble.styles.scss b/packages/fuselage/src/components/Bubble/Bubble.styles.scss
index cc104d9ad0..d1b73a0545 100644
--- a/packages/fuselage/src/components/Bubble/Bubble.styles.scss
+++ b/packages/fuselage/src/components/Bubble/Bubble.styles.scss
@@ -26,8 +26,6 @@
padding-inline-start: lengths.padding(12);
padding-inline-end: lengths.padding(16);
- transform: none !important;
-
border-radius: 20px;
}
From 866e27b3a1b05f87891613c351c4c34850799165 Mon Sep 17 00:00:00 2001
From: juliajforesti
Date: Mon, 15 Jan 2024 12:29:13 -0300
Subject: [PATCH 13/18] update snapshot
---
.../Bubble/__snapshots__/Bubble.spec.tsx.snap | 22 -------------------
1 file changed, 22 deletions(-)
diff --git a/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap b/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
index e2518826bb..ef2a291c0a 100644
--- a/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
+++ b/packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
@@ -76,25 +76,3 @@ exports[`[Bubble Rendering] renders LabelOnly without crashing 1`] = `
-
-