{
"name": "apcom",
"description": "The frontend of ArmandPhilippot.com built with Next JS.",
"version": "1.1.0",
"license": "MIT",
"author": {
"name": "Armand Philippot",
"email": "contact@armandphilippot.com",
"url": "https://www.armandphilippot.com/"
},
"homepage": "https://github.com/ArmandPhilippot/apcom#readme",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com:ArmandPhilippot/apcom.git"
},
"bugs": {
"url": "https://github.com/ArmandPhilippot/apcom/issues"
},
"private": true,
"scripts": {
"predev": "npm run i18n:compile",
"dev": "next dev",
"prebuild": "npm run i18n:compile",
"build": "next build",
"postbuild": "next-sitemap",
"start": "next start",
"lint": "next lint",
"deploy": "sh ./bin/deploy.sh",
"i18n:compile": "formatjs compile-folder src/i18n lang/",
"i18n:extract": "formatjs extract 'src/**/*.ts*' --out-file src/i18n/en.json",
"release": "standard-version -s",
"test": "jest",
"test:ci": "jest --ci",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"dependencies": {
"@formatjs/swc-plugin": "^1.3.2",
"@mdx-js/loader": "^2.1.0",
"@mdx-js/react": "^2.1.0",
"@next/bundle-analyzer": "^12.1.1",
"@next/mdx": "^12.1.1",
"feed": "^4.2.2",
"graphql": "^16.1.0",
"graphql-request": "^4.2.0",
"modern-normalize": "^1.1.0",
"next": "^12.1.1",
"next-sitemap": "^2.5.14",
"next-themes": "^0.1.1",
"prismjs": "^1.27.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-intl": "^5.24.7",
"schema-dts": "^1.1.0",
"sharp": "^0.30.3",
"swr": "^1.2.2",
"use-ackee": "^3.0.1"
},
"devDependencies": {
"@babel/core": "^7.17.8",
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@formatjs/cli": "^4.8.2",
"@storybook/addon-essentials": "^6.4.19",
"@storybook/addon-interactions": "^6.4.19",
"@storybook/addon-links": "^6.4.19",
"@storybook/builder-webpack5": "^6.4.19",
"@storybook/manager-webpack5": "^6.4.19",
"@storybook/react": "^6.4.19",
"@storybook/testing-library": "^0.0.9",
"@svgr/webpack": "^6.2.1",
"@testing-library/jest-dom": "^5.16.3",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"@types/mdx": "^2.0.1",
"@types/node": "^17.0.23",
"@types/prismjs": "^1.26.0",
"@types/react": "^17.0.43",
"@types/use-ackee": "^2.0.0",
"eslint": "^8.11.0",
"eslint-config-next": "^12.1.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-formatjs": "^3.0.0",
"eslint-plugin-storybook": "^0.5.7",
"eslint-plugin-testing-library": "^5.1.0",
"husky": "^7.0.4",
"jest": "^27.5.1",
"lint-staged": "^12.3.7",
"next-router-mock": "^0.6.5",
"postcss": "^8.4.12",
"prettier": "^2.6.1",
"sass": "^1.49.9",
"standard-version": "^9.3.2",
"storybook-addon-next": "^1.6.2",
"stylelint": "^14.6.1",
"stylelint-config-standard": "^25.0.0",
"stylelint-config-standard-scss": "^3.0.0",
"typescript": "^4.6.3",
"webpack": "^5.70.0"
}
}
/src/components/molecules/buttons?id=ca921d7536cfe950b5a7d442977bbf900b48faf4'>buttons/heading-button.tsx
blob: 0ed9a7691343d69008ed93ee510afc7816c9c115 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
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;
|