insomnia/packages/insomnia-components/components/sidebar/sidebar-header.js
Mike Ellan b7bc88a326
Design sidebar (#2328)
* updated lock file

* Rolling sidebar from SB into application

* Type fix on the method label output

* Update packages/insomnia-components/components/sidebar.js

Co-authored-by: Opender Singh <opender94@gmail.com>

* PR Feedback - Keys, useCallback Hook

* stubbing component breakout

* PR Feedback

- Breaking out most UI elements into components
- Filter component in place
- Various CSS tweaks

* Removing unused file

* Updating toggle

* Resuable sidebar section (#2359)

* Introduce resuable sidebar section
* Stop eslint complaining
* add react-use
* Lint fixes
* Make the storybook story less wide

* Component development

Abstracting out line level components i.e.
Section > Header > Filter > Panel > Items

Various code fixes

* Cleaning up section visibility state

* Reverting visibiilty state updater

* Adding paths on click for spec scrolling

* refreshing package-lock to resolve conflict

* PR feedback for sidebar components

* Update packages/insomnia-components/components/sidebar/sidebar-header.js

Co-authored-by: Opender Singh <opender94@gmail.com>

* Including lock

* Merge fix

* Component structuring, prop clean-up, css updates

* Cleaning up components, pr feedback, fixing styling

* array index reference clean-up/clarity

* Leveraging useToggle rather than manual useState toggling

* Cleaning up logs

* Hide info section if missing from spec.

* Update packages/insomnia-components/components/sidebar/sidebar-responses.js

Co-authored-by: Opender Singh <opender94@gmail.com>

* Update packages/insomnia-components/components/sidebar/sidebar-schemas.js

Co-authored-by: Opender Singh <opender94@gmail.com>

* Pull fragment

* Destructuring and filter cleanup

* Clearing filter value and DOM on section collapse

* Merge latest

* Merge conflict cleanup

Co-authored-by: Opender Singh <opender94@gmail.com>
2020-07-22 09:13:06 -04:00

81 lines
1.6 KiB
JavaScript

// @flow
import * as React from 'react';
import styled from 'styled-components';
import { motion } from 'framer-motion';
import SvgIcon, { IconEnum } from '../svg-icon';
type Props = {
headerTitle: string,
toggleSection: (toggle: SyntheticKeyboardEvent<HTMLButtonElement>) => void,
toggleFilter?: () => void,
sectionVisible: boolean,
children?: React.Node,
};
const StyledHeader: React.ComponentType<{}> = styled.li`
display: flex;
justify-content: space-between;
align-items: center;
&:hover {
background-color: var(--hl-xs);
}
h6 {
font-size: var(--font-size-xs);
display: flex;
flex-grow: 1;
&:hover {
cursor: default;
}
}
h6:hover {
text-decoration: underline;
}
label {
color: red !important;
position: absolute;
padding-top: var(--padding-xs);
}
& > * {
padding: var(--padding-md) var(--padding-md) var(--padding-md) var(--padding-md);
font-size: var(--font-size-md);
svg {
margin-left: var(--padding-sm);
&:hover {
fill: var(--color-font);
opacity: 1;
}
}
}
`;
const SidebarHeader = ({
headerTitle,
toggleSection,
toggleFilter,
sectionVisible,
children,
}: Props) => (
<StyledHeader>
<h6 onClick={toggleSection}>{headerTitle}</h6>
<div>
{children || (
<motion.span
onClick={toggleFilter}
initial={{ opacity: sectionVisible ? 0.6 : 0 }}
animate={{ opacity: sectionVisible ? 0.6 : 0 }}>
<SvgIcon icon={IconEnum.search} />
</motion.span>
)}
</div>
</StyledHeader>
);
export default SidebarHeader;