Skip to content

Commit

Permalink
fix: hide menu toggles when no extra options [fixes igeligel#2]
Browse files Browse the repository at this point in the history
  • Loading branch information
zorfling committed Oct 26, 2021
1 parent 18b8ed3 commit 809b13f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/MoreOptionsIconContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { CSSProperties } from 'react';
import styled from 'styled-components';
import { IconChevronDown } from './IconChevronDown';
import { IconChevronUp } from './IconChevronUp';
Expand Down Expand Up @@ -37,6 +37,7 @@ type MoreOptionsIconContainerProps = {
| undefined;
active: boolean;
right?: boolean;
style?: CSSProperties;
};

type ReactRef =
Expand All @@ -47,12 +48,13 @@ type ReactRef =

export const MoreOptionsIconContainer = React.forwardRef(
(props: MoreOptionsIconContainerProps, ref: ReactRef) => {
const { onClick, active, right } = props;
const { onClick, active, right, style } = props;
return (
<MoreOptionsIconContainerStyle
right={right || false}
ref={ref}
onClick={onClick}
style={style}
>
{!active && <IconChevronDown />}
{active && <IconChevronUp />}
Expand Down
2 changes: 1 addition & 1 deletion src/OptionsOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const OptionsOverlay = <T extends Options>(
minHeight={`${convertCardSizes.height}px`}
maxHeight={`${convertCardSizes.height}px`}
>
{shownMenuOptions.map((option) => {
{shownMenuOptions.map(option => {
return (
<OverlayOption
key={option.name}
Expand Down
10 changes: 8 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const InOutTextarea: FC<Props> = props => {
if (a.active) return -1;
return 0;
})
.map((option) => {
.map(option => {
return (
<InMenuOptionStuff
key={option.name}
Expand All @@ -142,6 +142,9 @@ export const InOutTextarea: FC<Props> = props => {
ref={inOptionsMenuRef}
onClick={onInMoreOptionsClick}
active={showAdditionalInOptions}
style={{
visibility: menuInOptions.length > 0 ? 'visible' : 'hidden',
}}
/>
</SideBar>
<Spacer />
Expand All @@ -153,7 +156,7 @@ export const InOutTextarea: FC<Props> = props => {
if (a.active) return -1;
return 0;
})
.map((option) => {
.map(option => {
return (
<OutMenuOptionStuff
key={option.name}
Expand All @@ -173,6 +176,9 @@ export const InOutTextarea: FC<Props> = props => {
ref={outOptionsMenuRef}
onClick={onOutMoreOptionsClick}
active={showAdditionalOutOptions}
style={{
visibility: menuOutOptions.length > 0 ? 'visible' : 'hidden',
}}
/>
</SideBar>
</CaseBar>
Expand Down

0 comments on commit 809b13f

Please sign in to comment.