Skip to content

Commit

Permalink
fix: pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoya committed Dec 9, 2020
1 parent acb2558 commit 90e1459
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 42 deletions.
12 changes: 5 additions & 7 deletions packages/big-design/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import React, { cloneElement, isValidElement, memo, useCallback, useMemo, useRef
import { usePopper } from 'react-popper';

import { useUniqueId } from '../../hooks';
import { Box } from '../Box';
import { List } from '../List';
import { StyledMenuContainer } from '../List/styled';

import { StyledBox } from './styled';
import { DropdownItem, DropdownLinkItem, DropdownProps } from './types';

import { DropdownItemGroup } from '.';
import { DropdownItem, DropdownItemGroup, DropdownLinkItem, DropdownProps } from './types';

export const Dropdown = memo(
({
Expand Down Expand Up @@ -88,7 +86,7 @@ export const Dropdown = memo(
const renderToggle = useMemo(() => {
return (
isValidElement(toggle) &&
cloneElement<React.HTMLAttributes<any> & React.RefAttributes<any>>(toggle as any, {
cloneElement(toggle, {
...getToggleButtonProps({
'aria-expanded': isOpen, // Because of memoization, we need to manually set this option
disabled,
Expand All @@ -101,7 +99,7 @@ export const Dropdown = memo(
return (
<StyledBox>
{renderToggle}
<StyledMenuContainer ref={popperRef} style={styles.popper} {...attributes.poppper}>
<Box ref={popperRef} style={styles.popper} {...attributes.poppper} zIndex="popover">
<List
{...props}
autoWidth={autoWidth}
Expand All @@ -114,7 +112,7 @@ export const Dropdown = memo(
maxHeight={maxHeight}
update={update}
/>
</StyledMenuContainer>
</Box>
</StyledBox>
);
},
Expand Down
8 changes: 4 additions & 4 deletions packages/big-design/src/components/List/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface PrivateProps {
forwardedRef: Ref<HTMLLIElement>;
}

type Items = DropdownItem | DropdownLinkItem | SelectOption<unknown> | SelectAction;
type Items<T> = DropdownItem | DropdownLinkItem | SelectOption<T> | SelectAction;

const StyleableListItem = typedMemo(
<T extends unknown>({
Expand Down Expand Up @@ -116,7 +116,7 @@ export const ListItem = memo(
)),
);

const getContent = (item: Items, isHighlighted: boolean) => {
const getContent = (item: Items<unknown>, isHighlighted: boolean) => {
const { content, disabled, description, icon } = item;

const baseContent = (
Expand Down Expand Up @@ -147,7 +147,7 @@ const getContent = (item: Items, isHighlighted: boolean) => {
return disabled && 'tooltip' in item && item.tooltip ? wrapInTooltip(item.tooltip, finalContent) : finalContent;
};

const renderIcon = (item: Items, isHighlighted: boolean) => {
const renderIcon = (item: Items<unknown>, isHighlighted: boolean) => {
return (
isValidElement(item.icon) &&
cloneElement(item.icon, {
Expand All @@ -157,7 +157,7 @@ const renderIcon = (item: Items, isHighlighted: boolean) => {
);
};

const iconColor = (item: Items, isHighlighted: boolean) => {
const iconColor = (item: Items<unknown>, isHighlighted: boolean) => {
if (item.disabled) {
return 'secondary40';
}
Expand Down
1 change: 1 addition & 0 deletions packages/big-design/src/components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const StyleableList = typedMemo(
);

export const List = memo(
// Using unknown because memo looses the generic type
forwardRef<HTMLUListElement, ListProps<unknown>>((props, ref) => <StyleableList {...props} forwardedRef={ref} />),
);

Expand Down
5 changes: 0 additions & 5 deletions packages/big-design/src/components/List/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,4 @@ export const StyledList = styled.ul<Partial<ListProps<unknown>>>`
z-index: ${({ theme }) => theme.zIndex.popover};
`;

export const StyledMenuContainer = styled.div`
z-index: ${({ theme }) => theme.zIndex.popover};
`;

StyledList.defaultProps = { theme: defaultTheme };
StyledMenuContainer.defaultProps = { theme: defaultTheme };
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { usePopper } from 'react-popper';

import { useUniqueId } from '../../hooks';
import { typedMemo, warning } from '../../utils';
import { Box } from '../Box';
import { FormControlLabel } from '../Form';
import { Input } from '../Input';
import { List } from '../List';
import { StyledMenuContainer } from '../List/styled';
import { SelectAction, SelectOption, SelectOptionGroup } from '../Select';
import { DropdownButton, StyledDropdownIcon, StyledInputContainer } from '../Select/styled';

Expand Down Expand Up @@ -380,7 +380,7 @@ export const MultiSelect = typedMemo(
<div>
{renderLabel}
<div {...getComboboxProps()}>{renderInput}</div>
<StyledMenuContainer ref={popperRef} style={styles.popper} {...attributes.poppper}>
<Box ref={popperRef} style={styles.popper} {...attributes.poppper} zIndex="popover">
<List
action={action}
addItem={addSelectedItem}
Expand All @@ -396,7 +396,7 @@ export const MultiSelect = typedMemo(
selectedItems={selectedOptions}
update={update}
/>
</StyledMenuContainer>
</Box>
</div>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ exports[`render pagination component 1`] = `
box-sizing: border-box;
}
.c8 {
box-sizing: border-box;
z-index: 1060;
}
.c1 {
-webkit-align-content: stretch;
-ms-flex-line-pack: stretch;
Expand Down Expand Up @@ -73,10 +78,6 @@ exports[`render pagination component 1`] = `
z-index: 1060;
}
.c8 {
z-index: 1060;
}
.c3 {
position: relative;
}
Expand Down Expand Up @@ -436,6 +437,11 @@ exports[`render pagination component with invalid page info 1`] = `
box-sizing: border-box;
}
.c8 {
box-sizing: border-box;
z-index: 1060;
}
.c1 {
-webkit-align-content: stretch;
-ms-flex-line-pack: stretch;
Expand Down Expand Up @@ -492,10 +498,6 @@ exports[`render pagination component with invalid page info 1`] = `
z-index: 1060;
}
.c8 {
z-index: 1060;
}
.c3 {
position: relative;
}
Expand Down Expand Up @@ -855,6 +857,11 @@ exports[`render pagination component with invalid range info 1`] = `
box-sizing: border-box;
}
.c8 {
box-sizing: border-box;
z-index: 1060;
}
.c1 {
-webkit-align-content: stretch;
-ms-flex-line-pack: stretch;
Expand Down Expand Up @@ -911,10 +918,6 @@ exports[`render pagination component with invalid range info 1`] = `
z-index: 1060;
}
.c8 {
z-index: 1060;
}
.c3 {
position: relative;
}
Expand Down Expand Up @@ -1275,6 +1278,11 @@ exports[`render pagination component with no items 1`] = `
box-sizing: border-box;
}
.c8 {
box-sizing: border-box;
z-index: 1060;
}
.c1 {
-webkit-align-content: stretch;
-ms-flex-line-pack: stretch;
Expand Down Expand Up @@ -1331,10 +1339,6 @@ exports[`render pagination component with no items 1`] = `
z-index: 1060;
}
.c8 {
z-index: 1060;
}
.c3 {
position: relative;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/big-design/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import React, {
import { usePopper } from 'react-popper';

import { typedMemo, warning } from '../../utils';
import { Box } from '../Box';
import { FormControlLabel } from '../Form';
import { Input } from '../Input';
import { List } from '../List';
import { StyledMenuContainer } from '../List/styled';
import { SelectOption, SelectOptionGroup, SelectProps } from '../Select';
import { DropdownButton, StyledDropdownIcon, StyledInputContainer } from '../Select/styled';
import { SelectAction } from '../Select/types';
Expand Down Expand Up @@ -295,7 +295,7 @@ export const Select = typedMemo(
<div>
{renderLabel}
<div {...getComboboxProps()}>{renderInput}</div>
<StyledMenuContainer ref={popperRef} style={styles.popper} {...attributes.poppper}>
<Box ref={popperRef} style={styles.popper} {...attributes.poppper} zIndex="popover">
<List
action={action}
autoWidth={autoWidth}
Expand All @@ -309,7 +309,7 @@ export const Select = typedMemo(
selectedItem={selectedItem && 'value' in selectedItem ? selectedItem : null}
update={update}
/>
</StyledMenuContainer>
</Box>
</div>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ exports[`renders a pagination component 1`] = `
box-sizing: border-box;
}
.c11 {
box-sizing: border-box;
z-index: 1060;
}
.c4 {
-webkit-align-content: stretch;
-ms-flex-line-pack: stretch;
Expand Down Expand Up @@ -92,10 +97,6 @@ exports[`renders a pagination component 1`] = `
z-index: 1060;
}
.c11 {
z-index: 1060;
}
.c6 {
position: relative;
}
Expand Down

0 comments on commit 90e1459

Please sign in to comment.