mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
34 lines
810 B
JavaScript
34 lines
810 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import React from 'react';
|
|
import Button from '../Button';
|
|
import ButtonIcon from '../ButtonIcon';
|
|
|
|
import styles from './ExpandCollapseToggle.css';
|
|
|
|
type ExpandCollapseToggleProps = {|
|
|
isOpen: boolean,
|
|
setIsOpen: Function,
|
|
|};
|
|
|
|
export default function ExpandCollapseToggle({
|
|
isOpen,
|
|
setIsOpen,
|
|
}: ExpandCollapseToggleProps) {
|
|
return (
|
|
<Button
|
|
className={styles.ExpandCollapseToggle}
|
|
onClick={() => setIsOpen(prevIsOpen => !prevIsOpen)}
|
|
title={`${isOpen ? 'Collapse' : 'Expand'} prop value`}>
|
|
<ButtonIcon type={isOpen ? 'expanded' : 'collapsed'} />
|
|
</Button>
|
|
);
|
|
}
|