Skip to content

Commit

Permalink
feat(Disclosure): added qa attribute for details and summary nodes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vrozaev authored Jan 19, 2024
1 parent 1c551f7 commit b1bbcd1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/Disclosure/Disclosure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {isOfType} from '../utils/isOfType';
import {DisclosureProvider} from './DisclosureContext';
import {DisclosureDetails} from './DisclosureDetails/DisclosureDetails';
import {DefaultDisclosureSummary, DisclosureSummary} from './DisclosureSummary/DisclosureSummary';
import {b} from './cn';
import {b} from './constants';

import './Disclosure.scss';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {CSSTransition} from 'react-transition-group';

import {getCSSTransitionClassNames} from '../../utils/transition';
import {useDisclosureAttributes} from '../DisclosureContext';
import {b} from '../cn';
import {DisclosureQa, b} from '../constants';

export interface DisclosureDetailsProps {
children: React.ReactNode;
Expand All @@ -30,6 +30,7 @@ export function DisclosureDetails({children}: DisclosureDetailsProps) {
role="region"
aria-labelledby={ariaLabelledby}
className={b('content', {visible: expanded})}
data-qa={DisclosureQa.DETAILS}
>
{children}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import {ArrowToggle} from '../../ArrowToggle';
import type {DisclosureSize} from '../Disclosure';
import {useDisclosureAttributes, useToggleDisclosure} from '../DisclosureContext';
import {b} from '../cn';
import {DisclosureQa, b} from '../constants';

const ComponentSizeToIconSizeMap: Record<DisclosureSize, number> = {
m: 14,
Expand Down Expand Up @@ -47,6 +47,7 @@ export function DefaultDisclosureSummary({
id={id}
onClick={onClick}
disabled={disabled}
data-qa={DisclosureQa.SUMMARY}
>
<ArrowToggle
size={ComponentSizeToIconSizeMap[size]}
Expand Down
3 changes: 0 additions & 3 deletions src/components/Disclosure/cn.ts

This file was deleted.

8 changes: 8 additions & 0 deletions src/components/Disclosure/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {blockNew} from '../utils/cn';

export const b = blockNew('disclosure');

export const DisclosureQa = {
SUMMARY: 'disclosure-summary',
DETAILS: 'disclosure-details',
};
1 change: 1 addition & 0 deletions src/components/Disclosure/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export {Disclosure} from './Disclosure';
export type {DisclosureSize, DisclosureArrowPosition, DisclosureProps} from './Disclosure';
export {DisclosureQa} from './constants';

0 comments on commit b1bbcd1

Please sign in to comment.