aboutsummaryrefslogtreecommitdiffstats
path: root/tests/jest/__mocks__/fileMock.js
blob: ad66de48d022dc46d780aa10c7aec58a0908b22c (plain)
1
module.exports = '/test-file-stub';
iteral.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
import Heading, { type HeadingProps } from '@components/atoms/headings/heading';
import PlusMinus from '@components/atoms/icons/plus-minus';
import { FC, SetStateAction } from 'react';
import { useIntl } from 'react-intl';
import styles from './heading-button.module.scss';

export type HeadingButtonProps = Pick<HeadingProps, 'level'> & {
  /**
   * Set additional classnames to the button.
   */
  className?: string;
  /**
   * Accordion state.
   */
  expanded: boolean;
  /**
   * Callback function to set accordion state on click.
   */
  setExpanded: (value: SetStateAction<boolean>) => void;
  /**
   * Accordion title.
   */
  title: string;
};

/**
 * HeadingButton component
 *
 * Render a button as accordion title to toggle body.
 */
const HeadingButton: FC<HeadingButtonProps> = ({
  className = '',
  expanded,
  level,
  setExpanded,
  title,
}) => {
  const intl = useIntl();
  const iconState = expanded ? 'minus' : 'plus';
  const titlePrefix = expanded
    ? intl.formatMessage({
        defaultMessage: 'Collapse',
        description: 'HeadingButton: title prefix (expanded state)',
        id: 'UX9Bu8',
      })
    : intl.formatMessage({
        defaultMessage: 'Expand',
        description: 'HeadingButton: title prefix (collapsed state)',
        id: 'bcyOgC',
      });

  return (
    <button
      type="button"
      className={`${styles.wrapper} ${className}`}
      onClick={() => setExpanded(!expanded)}
    >
      <Heading level={level} withMargin={false} className={styles.heading}>
        <span className="screen-reader-text">{titlePrefix} </span>
        {title}
      </Heading>
      <PlusMinus state={iconState} className={styles.icon} />
    </button>
  );
};

export default HeadingButton;