Skip to content

Commit

Permalink
feat: Add more customize icon support
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Nov 28, 2019
1 parent faaea0d commit acfb384
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export interface PickerSharedProps<DateType> {
// Render
suffixIcon?: React.ReactNode;
clearIcon?: React.ReactNode;
prevIcon?: React.ReactNode;
nextIcon?: React.ReactNode;
superPrevIcon?: React.ReactNode;
superNextIcon?: React.ReactNode;
getPopupContainer?: (node: HTMLElement) => HTMLElement;

// Events
Expand Down
5 changes: 5 additions & 0 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export interface PanelSharedProps<DateType> {
locale: Locale;
disabledDate?: (date: DateType) => boolean;

prevIcon?: React.ReactNode;
nextIcon?: React.ReactNode;
superPrevIcon?: React.ReactNode;
superNextIcon?: React.ReactNode;

/**
* Typescript can not handle generic type so we can not use `forwardRef` here.
* Thus, move ref into operationRef.
Expand Down
1 change: 1 addition & 0 deletions src/panels/DatePanel/DateHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function DateHeader<DateType>(props: DateHeaderProps<DateType>) {

return (
<Header
{...props}
prefixCls={headerPrefixCls}
onSuperPrev={onPrevYear}
onPrev={onPrevMonth}
Expand Down
1 change: 1 addition & 0 deletions src/panels/DecadePanel/DecadeHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function DecadeHeader<DateType>(props: YearHeaderProps<DateType>) {

return (
<Header
{...props}
prefixCls={headerPrefixCls}
onSuperPrev={onPrevDecades}
onSuperNext={onNextDecades}
Expand Down
19 changes: 15 additions & 4 deletions src/panels/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import * as React from 'react';

export interface HeaderProps {
prefixCls: string;

// Icons
prevIcon?: React.ReactNode;
nextIcon?: React.ReactNode;
superPrevIcon?: React.ReactNode;
superNextIcon?: React.ReactNode;

/** Last one step */
onPrev?: () => void;
/** Next one step */
Expand All @@ -16,6 +23,10 @@ export interface HeaderProps {

function Header({
prefixCls,
prevIcon = '\u2039',
nextIcon = '\u203A',
superPrevIcon = '\u00AB',
superNextIcon = '\u00BB',
onSuperPrev,
onSuperNext,
onPrev,
Expand All @@ -31,7 +42,7 @@ function Header({
tabIndex={-1}
className={`${prefixCls}-super-prev-btn`}
>
{'\u00AB'}
{superPrevIcon}
</button>
)}
{onPrev && (
Expand All @@ -41,7 +52,7 @@ function Header({
tabIndex={-1}
className={`${prefixCls}-prev-btn`}
>
{'\u2039'}
{prevIcon}
</button>
)}
<div className={`${prefixCls}-view`}>{children}</div>
Expand All @@ -52,7 +63,7 @@ function Header({
tabIndex={-1}
className={`${prefixCls}-next-btn`}
>
{'\u203A'}
{nextIcon}
</button>
)}
{onSuperNext && (
Expand All @@ -62,7 +73,7 @@ function Header({
tabIndex={-1}
className={`${prefixCls}-super-next-btn`}
>
{'\u00BB'}
{superNextIcon}
</button>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/panels/TimePanel/TimeBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface BodyOperationRef {
onUpDown: (diff: number) => void;
}

export interface TimeBodyProps<DateType> extends SharedTimeProps {
export interface TimeBodyProps<DateType> extends SharedTimeProps<DateType> {
prefixCls: string;
locale: Locale;
generateConfig: GenerateConfig<DateType>;
Expand Down
1 change: 1 addition & 0 deletions src/panels/YearPanel/YearHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function YearHeader<DateType>(props: YearHeaderProps<DateType>) {

return (
<Header
{...props}
prefixCls={headerPrefixCls}
onSuperPrev={onPrevDecade}
onSuperNext={onNextDecade}
Expand Down

1 comment on commit acfb384

@vercel
Copy link

@vercel vercel bot commented on acfb384 Nov 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.