Skip to content

Commit

Permalink
[3739] Use custom DownChevron and CrossIcon when supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Matuska committed Mar 3, 2020
1 parent d787303 commit 75f335c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/react-select/src/components/MultiValue.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @flow
/** @jsx jsx */
import { type Node } from 'react';
import { useMemo, type Node } from 'react';
import { jsx, ClassNames } from '@emotion/core';
import { CrossIcon } from './indicators';
import type { CommonProps } from '../types';
import { defaultComponents } from './index';

export type MultiValueProps = CommonProps & {
children: Node,
Expand Down Expand Up @@ -88,7 +88,9 @@ export type MultiValueRemoveProps = {
export function MultiValueRemove({
children,
innerProps,
selectProps: { components = {} },
}: MultiValueRemoveProps) {
const CrossIcon = useMemo(() => defaultComponents({ components }).CrossIcon, [components]);
return <div {...innerProps}>{children || <CrossIcon size={14} />}</div>;
}

Expand Down
13 changes: 8 additions & 5 deletions packages/react-select/src/components/indicators.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// @flow
/** @jsx jsx */
import { type Node } from 'react';
import { useMemo, type Node } from 'react';
import { jsx, keyframes } from '@emotion/core';

import type { CommonProps, Theme } from '../types';
import { defaultComponents } from './index';

// ==============================
// Dropdown & Clear Icons
Expand Down Expand Up @@ -73,7 +74,8 @@ const baseCSS = ({

export const dropdownIndicatorCSS = baseCSS;
export const DropdownIndicator = (props: IndicatorProps) => {
const { children, className, cx, getStyles, innerProps } = props;
const { children, className, cx, getStyles, innerProps, selectProps: { components = {} } } = props;
const DownChevronComponent = useMemo(() => defaultComponents({ components }).DownChevron, [components]);
return (
<div
{...innerProps}
Expand All @@ -86,14 +88,15 @@ export const DropdownIndicator = (props: IndicatorProps) => {
className
)}
>
{children || <DownChevron />}
{children || <DownChevronComponent />}
</div>
);
};

export const clearIndicatorCSS = baseCSS;
export const ClearIndicator = (props: IndicatorProps) => {
const { children, className, cx, getStyles, innerProps } = props;
const { children, className, cx, getStyles, innerProps, selectProps: { components = {} } } = props;
const CrossIconComponent = useMemo(() => defaultComponents({ components }).CrossIcon, [components]);
return (
<div
{...innerProps}
Expand All @@ -106,7 +109,7 @@ export const ClearIndicator = (props: IndicatorProps) => {
className
)}
>
{children || <CrossIcon />}
{children || <CrossIconComponent />}
</div>
);
};
Expand Down

0 comments on commit 75f335c

Please sign in to comment.