Skip to content

Commit

Permalink
popout menu gets hover state when open
Browse files Browse the repository at this point in the history
  • Loading branch information
teallarson committed Jul 11, 2022
1 parent 15d36f4 commit 7742d58
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
10 changes: 7 additions & 3 deletions airbyte-webapp/src/components/base/Popout/Popout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ const ControlComponent = (props: ControlProps<Value, false>) => (
<div ref={props.innerRef}>
{props.selectProps.selectProps.targetComponent({
onOpen: props.selectProps.selectProps.onOpen,
isOpen: props.selectProps.menuIsOpen,
value: props.selectProps.value,
})}
</div>
);

type PopoutProps = DropdownProps & {
interface PopoutProps extends DropdownProps {
targetComponent: (props: { onOpen: () => void; isOpen?: boolean; value: Value }) => ReactNode;
};
}

const Popout: React.FC<PopoutProps> = ({ onChange, targetComponent, ...props }) => {
const [isOpen, toggleOpen] = useToggle(false);
Expand Down Expand Up @@ -61,7 +62,10 @@ const Popout: React.FC<PopoutProps> = ({ onChange, targetComponent, ...props })
return (
<>
<DropDown
selectProps={{ targetComponent, onOpen: toggleOpen }}
selectProps={{
targetComponent,
onOpen: toggleOpen,
}}
autoFocus
backspaceRemovesValue={false}
controlShouldRenderValue={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ import SettingsIcon from "views/layout/SideBar/components/SettingsIcon";
import SidebarPopout, { Icon, Item } from "views/layout/SideBar/components/SidebarPopout";
import SourceIcon from "views/layout/SideBar/components/SourceIcon";
import { NotificationIndicator } from "views/layout/SideBar/NotificationIndicator";
import { useCalculateSidebarStyles } from "views/layout/SideBar/SideBar";
import { useCalculateSidebarStyles, getPopoutStyles } from "views/layout/SideBar/SideBar";

import { RoutePaths } from "../../../../../pages/routePaths";
import styles from "../../../../../views/layout/SideBar/SideBar.module.scss"; // eslint-disable-line

const CreditsIcon = styled(FontAwesomeIcon)`
font-size: 21px;
Expand Down Expand Up @@ -140,8 +139,8 @@ const SideBar: React.FC = () => {
</li>
<li>
<SidebarPopout options={[{ value: "docs" }, { value: "slack" }, { value: "status" }, { value: "recipes" }]}>
{({ onOpen }) => (
<div className={styles.menuItem} onClick={onOpen}>
{({ onOpen, isOpen }) => (
<div className={getPopoutStyles(isOpen)} onClick={onOpen}>
<DocsIcon />
<Text>
<FormattedMessage id="sidebar.resources" />
Expand All @@ -167,8 +166,8 @@ const SideBar: React.FC = () => {
},
]}
>
{({ onOpen }) => (
<div className={styles.menuItem} onClick={onOpen}>
{({ onOpen, isOpen }) => (
<div className={getPopoutStyles(isOpen)} onClick={onOpen}>
<FontAwesomeIcon icon={faQuestionCircle} size="2x" />
<Text>
<FormattedMessage id="sidebar.support" />
Expand Down
5 changes: 5 additions & 0 deletions airbyte-webapp/src/views/layout/SideBar/SideBar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@
background: colors.$dark-blue-400;
}
}

&.popoutOpen {
background: colors.$dark-blue-600;
transition: variables.$transition-out;
}
}
8 changes: 6 additions & 2 deletions airbyte-webapp/src/views/layout/SideBar/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export const useCalculateSidebarStyles = () => {
return ({ isActive }: { isActive: boolean }) => menuItemStyle(isActive);
};

export const getPopoutStyles = (isOpen?: boolean) => {
return classnames(styles.menuItem, { [styles.popoutOpen]: isOpen });
};

const SideBar: React.FC = () => {
const config = useConfig();
const workspace = useCurrentWorkspace();
Expand Down Expand Up @@ -124,8 +128,8 @@ const SideBar: React.FC = () => {
</li>
<li>
<SidebarPopout options={[{ value: "docs" }, { value: "slack" }, { value: "recipes" }]}>
{({ onOpen }) => (
<div className={styles.menuItem} onClick={onOpen}>
{({ onOpen, isOpen }) => (
<div className={getPopoutStyles(isOpen)} onClick={onOpen}>
<DocsIcon />
<Text>
<FormattedMessage id="sidebar.resources" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const Icon = styled.div`
`;

const SidebarPopout: React.FC<{
children: (props: { onOpen: () => void }) => React.ReactNode;
children: (props: { onOpen: () => void; isOpen?: boolean }) => React.ReactNode;
options: Array<{ value: string; label?: React.ReactNode }>;
}> = ({ children, options }) => {
const config = useConfig();
Expand Down Expand Up @@ -110,7 +110,12 @@ const SidebarPopout: React.FC<{

return (
<Popout
targetComponent={(targetProps) => children({ onOpen: targetProps.onOpen })}
targetComponent={(targetProps) =>
children({
onOpen: targetProps.onOpen,
isOpen: targetProps.isOpen,
})
}
styles={{
menuPortal: (base) => ({
...base,
Expand Down

0 comments on commit 7742d58

Please sign in to comment.