Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide menu toggles when no extra options [fixes #2] #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/MoreOptionsIconContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IconChevronUp } from './IconChevronUp';

interface IMoreOptionsIconContainer {
right: boolean;
isHidden?: boolean;
}

const MoreOptionsIconContainerStyle = styled.div<IMoreOptionsIconContainer>`
Expand All @@ -26,6 +27,8 @@ const MoreOptionsIconContainerStyle = styled.div<IMoreOptionsIconContainer>`

padding-right: ${props => (props.right ? '10px' : '0px')};

visibility: ${({ isHidden }) => (isHidden ? 'hidden' : 'visible')};

:hover {
color: hsl(220deg 15% 50%);
}
Expand All @@ -37,6 +40,7 @@ type MoreOptionsIconContainerProps = {
| undefined;
active: boolean;
right?: boolean;
isHidden?: boolean;
};

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

export const MoreOptionsIconContainer = React.forwardRef(
(props: MoreOptionsIconContainerProps, ref: ReactRef) => {
const { onClick, active, right } = props;
const { onClick, active, right, isHidden } = props;
return (
<MoreOptionsIconContainerStyle
right={right || false}
ref={ref}
onClick={onClick}
isHidden={isHidden}
>
{!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
6 changes: 4 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,7 @@ export const InOutTextarea: FC<Props> = props => {
ref={inOptionsMenuRef}
onClick={onInMoreOptionsClick}
active={showAdditionalInOptions}
isHidden={menuInOptions.length === 0}
/>
</SideBar>
<Spacer />
Expand All @@ -153,7 +154,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 +174,7 @@ export const InOutTextarea: FC<Props> = props => {
ref={outOptionsMenuRef}
onClick={onOutMoreOptionsClick}
active={showAdditionalOutOptions}
isHidden={menuOutOptions.length === 0}
/>
</SideBar>
</CaseBar>
Expand Down