-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'RocketChat:main' into main
- Loading branch information
Showing
50 changed files
with
516 additions
and
107 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(<Story />); | ||
expect(tree.baseElement).toMatchSnapshot(); | ||
} | ||
); | ||
|
||
test.each(testCases)( | ||
'%s should have no a11y violations', | ||
async (_storyname, Story) => { | ||
const { container } = render(<Story />); | ||
|
||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
} | ||
); | ||
}); |
33 changes: 33 additions & 0 deletions
33
packages/fuselage/src/components/Bubble/Bubble.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { action } from '@storybook/addon-actions'; | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { Bubble } from '../..'; | ||
|
||
export default { | ||
title: 'Data Display/Bubble', | ||
component: Bubble, | ||
} as ComponentMeta<typeof Bubble>; | ||
|
||
const Template: ComponentStory<typeof Bubble> = (args) => <Bubble {...args} />; | ||
|
||
export const IconAndLabel = Template.bind({}); | ||
IconAndLabel.args = { | ||
children: 'New messages', | ||
onClick: action('click'), | ||
icon: 'arrow-down', | ||
}; | ||
|
||
export const Dismissable = Template.bind({}); | ||
Dismissable.args = { | ||
children: 'New messages', | ||
icon: 'arrow-down', | ||
onClick: action('click'), | ||
onDismiss: action('dismiss'), | ||
}; | ||
|
||
export const LabelOnly = Template.bind({}); | ||
LabelOnly.args = { | ||
children: 'See new messages', | ||
onClick: action('click'), | ||
}; |
43 changes: 43 additions & 0 deletions
43
packages/fuselage/src/components/Bubble/Bubble.styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@use '../../styles/colors.scss'; | ||
@use '../../styles/lengths.scss'; | ||
@use '../../styles/typography.scss'; | ||
|
||
@use '../../styles/variables/buttons.scss' as buttonColors; | ||
@use '../../styles/primitives/button.scss'; | ||
@use '../../styles/mixins/interactivity.scss'; | ||
|
||
.rcx-bubble { | ||
display: flex; | ||
align-items: center; | ||
|
||
&__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); | ||
|
||
border-radius: lengths.border-radius(extra-large); | ||
} | ||
|
||
&__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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { Keys as IconName } from '@rocket.chat/icons'; | ||
import type { AllHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react'; | ||
import React from 'react'; | ||
|
||
import { Icon } from '../Icon'; | ||
|
||
type BubbleProps = { | ||
children: ReactNode; | ||
onClick: () => void; | ||
icon?: IconName; | ||
onDismiss?: () => void; | ||
contentProps?: ButtonHTMLAttributes<HTMLButtonElement>; | ||
dismissProps?: ButtonHTMLAttributes<HTMLButtonElement>; | ||
} & AllHTMLAttributes<HTMLDivElement>; | ||
|
||
export const Bubble = ({ | ||
children, | ||
onClick, | ||
icon, | ||
onDismiss, | ||
contentProps, | ||
dismissProps, | ||
...props | ||
}: BubbleProps) => ( | ||
<div | ||
className={`rcx-bubble rcx-box rcx-box--full ${ | ||
onDismiss ? 'rcx-bubble__group' : '' | ||
}`} | ||
{...props} | ||
> | ||
<button className='rcx-bubble__content' onClick={onClick} {...contentProps}> | ||
{icon && <Icon name={icon} size='x16' mie={8} />} | ||
<span>{children}</span> | ||
</button> | ||
{onDismiss && ( | ||
<button | ||
aria-label={`Dismiss ${children}`} | ||
className='rcx-bubble__dismiss' | ||
onClick={onDismiss} | ||
{...dismissProps} | ||
> | ||
<Icon name='cross-small' size='x16' /> | ||
</button> | ||
)} | ||
</div> | ||
); |
78 changes: 78 additions & 0 deletions
78
packages/fuselage/src/components/Bubble/__snapshots__/Bubble.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`[Bubble Rendering] renders Dismissable without crashing 1`] = ` | ||
<body> | ||
<div> | ||
<div | ||
class="rcx-bubble rcx-box rcx-box--full rcx-bubble__group" | ||
> | ||
<button | ||
class="rcx-bubble__content" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="rcx-box rcx-box--full rcx-icon--name-arrow-down rcx-icon rcx-css-gcnmf8" | ||
> | ||
| ||
</i> | ||
<span> | ||
New messages | ||
</span> | ||
</button> | ||
<button | ||
aria-label="Dismiss New messages" | ||
class="rcx-bubble__dismiss" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="rcx-box rcx-box--full rcx-icon--name-cross-small rcx-icon rcx-css-1g87xs3" | ||
> | ||
| ||
</i> | ||
</button> | ||
</div> | ||
</div> | ||
</body> | ||
`; | ||
|
||
exports[`[Bubble Rendering] renders IconAndLabel without crashing 1`] = ` | ||
<body> | ||
<div> | ||
<div | ||
class="rcx-bubble rcx-box rcx-box--full " | ||
> | ||
<button | ||
class="rcx-bubble__content" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="rcx-box rcx-box--full rcx-icon--name-arrow-down rcx-icon rcx-css-gcnmf8" | ||
> | ||
| ||
</i> | ||
<span> | ||
New messages | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
</body> | ||
`; | ||
|
||
exports[`[Bubble Rendering] renders LabelOnly without crashing 1`] = ` | ||
<body> | ||
<div> | ||
<div | ||
class="rcx-bubble rcx-box rcx-box--full " | ||
> | ||
<button | ||
class="rcx-bubble__content" | ||
> | ||
<span> | ||
See new messages | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
</body> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Bubble'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
&--stretch { | ||
justify-content: stretch; | ||
align-items: stretch; | ||
|
||
flex-grow: 1; | ||
} | ||
|
||
&--vertical { | ||
|
Oops, something went wrong.