Skip to content

Commit

Permalink
Merge branch 'main' into feature/1364
Browse files Browse the repository at this point in the history
  • Loading branch information
VadymBezpalko authored Nov 28, 2024
2 parents d51b568 + 90ba344 commit 41a83cb
Show file tree
Hide file tree
Showing 33 changed files with 443 additions and 95 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["packages/*"],
"version": "2.6.2",
"version": "2.8.0",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/example-react/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "example-react",
"private": true,
"version": "2.6.2",
"version": "2.8.0",
"scripts": {
"start": "vite --open",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@livechat/design-system-icons": "^2.5.3",
"@livechat/design-system-react-components": "^2.6.2",
"@livechat/design-system-icons": "^2.8.0",
"@livechat/design-system-react-components": "^2.8.0",
"react": "^18.3.0",
"react-dom": "^18.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/icons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@livechat/design-system-icons",
"version": "2.5.3",
"version": "2.8.0",
"description": "",
"publishConfig": {
"access": "public"
Expand Down
7 changes: 7 additions & 0 deletions packages/icons/svg/arrows_diagonal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions packages/icons/svg/arrows_diagonal_minimize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/icons/svg/caret_down-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/icons/svg/caret_down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/icons/svg/caret_up-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/icons/svg/caret_up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/icons/svg/multi_choice-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/icons/svg/multi_choice.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/react-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@livechat/design-system-react-components",
"version": "2.6.2",
"version": "2.8.0",
"description": "",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -76,7 +76,7 @@
"dependencies": {
"@floating-ui/react": "^0.26.25",
"@livechat/data-utils": "^0.2.16",
"@livechat/design-system-icons": "^2.5.3",
"@livechat/design-system-icons": "^2.8.0",
"clsx": "^1.1.1",
"date-fns": "^2.28.0",
"lodash.debounce": "^4.0.8",
Expand Down
34 changes: 32 additions & 2 deletions packages/react-components/src/components/Accordion/Accordion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,54 @@ import * as AccordionStories from './Accordion.stories';

<Title>Accordion</Title>

[Intro](#Intro) | [Component API](#ComponentAPI)
[Intro](#Intro) | [Default Accordion](#Default) | [Promo Accordion](#Promo) | [Component API](#ComponentAPI)

## Intro <a id="Intro" />

Accordion is a simple component for building expandable tiles that display provided content when opened.

### Default Accordion <a id="Default" />

<Canvas of={AccordionStories.Examples} sourceState="none" />

#### Example implementation

```jsx
import { Accordion } from '@livechat/design-system-react-components';

<Accordion label="Default">
<Accordion
label={{
closed: (<div>Label for closed accordion</div>),
open: (<div>Label for open accordion</div>),
}}
multilineElement={<div>Multiline element</div>}
footer={<div>Footer element</div>}
>
Default accordion content
</Accordion>
```

### Promo Accordion <a id="Promo" />

<Canvas of={AccordionStories.AccordionPromoExamples} sourceState="none" />

#### Example implementation

```jsx
import { AccordionPromo } from '@livechat/design-system-react-components';

<AccordionPromo
label={{
closed: (<div>Label for closed accordion</div>),
open: (<div>Label for open accordion</div>),
}}
multilineElement={<div>Multiline element</div>}
footer={<div>Footer element</div>}
>
Default accordion content
</AccordionPromo>
```

## Component API <a id="ComponentAPI" />

<ArgTypes of={AccordionStories.Default} sort="requiredFirst" />
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ $base-class: 'accordion';
}
}

&--promo {
border: 1px solid var(--border-basic-secondary);
background-color: var(--surface-primary-default);
}

&--open {
border: 1px solid var(--action-primary-default);
box-shadow: var(--shadow-float);
Expand All @@ -59,6 +64,10 @@ $base-class: 'accordion';
&--open {
transform: rotate(180deg);
}

&--promo {
top: 26px;
}
}

&__label {
Expand All @@ -69,6 +78,11 @@ $base-class: 'accordion';
&:hover {
cursor: pointer;
}

&--promo {
padding: var(--spacing-6) var(--spacing-12) var(--spacing-6)
var(--spacing-6);
}
}

&__content {
Expand All @@ -84,6 +98,19 @@ $base-class: 'accordion';
&--open {
opacity: 1;
}

&--promo {
padding: 0 var(--spacing-12) var(--spacing-6) var(--spacing-6);
}
}
}

&__footer {
border-top: 1px solid var(--border-basic-secondary);
padding: var(--spacing-5);

&--promo {
padding: var(--spacing-6);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ describe('<Accordion> component', () => {
it('should call onClose and onOpen handlers on label click', async () => {
const onClose = vi.fn();
const onOpen = vi.fn();
const { getByRole } = renderComponent({
const { getByText } = renderComponent({
...DEFAULT_PROPS,
onClose,
onOpen,
});

expect(getByRole('button')).toHaveAttribute('aria-expanded', 'false');
userEvent.click(getByRole('button'));
expect(getByText('Label')).toHaveAttribute('aria-expanded', 'false');
userEvent.click(getByText('Label'));
expect(onOpen).toHaveBeenCalledTimes(1);

await waitFor(() => {
expect(getByRole('button')).toHaveAttribute('aria-expanded', 'false');
expect(getByText('Label')).toHaveAttribute('aria-expanded', 'false');
});

userEvent.click(getByRole('button'));
userEvent.click(getByText('Label'));
expect(onClose).toHaveBeenCalledTimes(1);
});

it('should show different label content when open and closed', async () => {
const { getByText, getByRole } = renderComponent({
const { getByText } = renderComponent({
...DEFAULT_PROPS,
label: {
open: <div>Open label</div>,
Expand All @@ -72,7 +72,7 @@ describe('<Accordion> component', () => {
});

expect(getByText('Closed label')).toBeInTheDocument();
userEvent.click(getByRole('button'));
userEvent.click(getByText('Closed label'));
await waitFor(() => expect(getByText('Open label')).toBeInTheDocument());
});

Expand All @@ -84,4 +84,15 @@ describe('<Accordion> component', () => {

expect(getByText('Multi')).toBeInTheDocument();
});

it('should show footer element if open', async () => {
const { queryByText, getByText } = renderComponent({
...DEFAULT_PROPS,
footer: <div>Footer</div>,
});

expect(queryByText('Footer')).not.toBeInTheDocument();
userEvent.click(getByText('Label'));
await waitFor(() => expect(queryByText('Footer')).toBeInTheDocument());
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@
}
}
}

.accordion-promo-closed-heading {
margin-bottom: 4px;
}

.accordion-promo-closed-description {
color: var(--content-basic-secondary);
}
Loading

0 comments on commit 41a83cb

Please sign in to comment.