Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ant-design/ant-design
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Sep 14, 2016
2 parents bbe6606 + a25ec29 commit 73a6bfb
Show file tree
Hide file tree
Showing 85 changed files with 449 additions and 355 deletions.
4 changes: 3 additions & 1 deletion components/affix/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface AffixProps {
style?: React.CSSProperties;
onChange?: (affixed?: boolean) => any;
target?: () => Window | HTMLElement;
prefixCls?: string;
}

export default class Affix extends React.Component<AffixProps, any> {
Expand All @@ -69,6 +70,7 @@ export default class Affix extends React.Component<AffixProps, any> {
return window;
},
onChange() {},
prefixCls: 'ant-affix',
};

scrollEvent: any;
Expand Down Expand Up @@ -215,7 +217,7 @@ export default class Affix extends React.Component<AffixProps, any> {

render() {
const className = classNames({
'ant-affix': this.state.affixStyle,
[this.props.prefixCls]: this.state.affixStyle,
});

const props = assign({}, this.props);
Expand Down
2 changes: 1 addition & 1 deletion components/affix/style/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "../../style/themes/default";

.ant-affix {
.@{ant-prefix}-affix {
position: fixed;
z-index: @zindex-affix;
}
16 changes: 8 additions & 8 deletions components/alert/demo/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@ Decent icon make information more clear and more friendly.
import { Alert } from 'antd';

ReactDOM.render(<div>
<Alert message="Copywriting Success Tips" type="success" showIcon />
<Alert message="Copywriting Informational Notes" type="info" showIcon />
<Alert message="Copywriting Warning" type="warning" showIcon />
<Alert message="Copywriting Error" type="error" showIcon />
<Alert message="Success Tips" type="success" showIcon />
<Alert message="Informational Notes" type="info" showIcon />
<Alert message="Warning" type="warning" showIcon />
<Alert message="Error" type="error" showIcon />
<Alert
message="Copywriting success tips"
message="success tips"
description="Detailed description and advices about successful copywriting."
type="success"
showIcon
/>
<Alert
message="Copywriting Informational Notes"
message="Informational Notes"
description="Additional description and informations about copywriting."
type="info"
showIcon
/>
<Alert
message="Copywriting Warning"
message="Warning"
description="This is a warning notice about copywriting."
type="warning"
showIcon
/>
<Alert
message="Copywriting Error"
message="Error"
description="This is an error message about copywriting."
type="error"
showIcon
Expand Down
2 changes: 1 addition & 1 deletion components/alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class Alert extends React.Component<AlertProps, any> {
onEnd={this.animationEnd}
>
<div data-show={this.state.closing} className={alertCls}>
{showIcon ? <Icon className="ant-alert-icon" type={iconType} /> : null}
{showIcon ? <Icon className={`${prefixCls}-icon`} type={iconType} /> : null}
<span className={`${prefixCls}-message`}>{message}</span>
<span className={`${prefixCls}-description`}>{description}</span>
{closable ? <a onClick={this.handleClose} className={`${prefixCls}-close-icon`}>
Expand Down
4 changes: 2 additions & 2 deletions components/alert/style/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "../../style/themes/default";

@alert-prefix-cls: ant-alert;
@alert-prefix-cls: ~"@{ant-prefix}-alert";

.@{alert-prefix-cls} {
position: relative;
Expand Down Expand Up @@ -70,7 +70,7 @@
overflow: hidden;
cursor: pointer;

.anticon-cross {
.@{iconfont-css-prefix}-cross {
color: @legend-color;
transition: color .3s ease;
&:hover {
Expand Down
2 changes: 1 addition & 1 deletion components/back-top/style/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "../../style/themes/default";

@backtop-prefix-cls: ant-back-top;
@backtop-prefix-cls: ~"@{ant-prefix}-back-top";

.@{backtop-prefix-cls} {
z-index: @zindex-back-top;
Expand Down
4 changes: 2 additions & 2 deletions components/badge/style/index.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "../../style/themes/default";

@badge-prefix-cls: ant-badge;
@number-prefix-cls: ant-scroll-number;
@badge-prefix-cls: ~"@{ant-prefix}-badge";
@number-prefix-cls: ~"@{ant-prefix}-scroll-number";

.@{badge-prefix-cls} {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion components/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {

warning(
!('linkRender' in props || 'nameRender' in props),
'`linkRender` and `nameRender` is removed, please use `itemRender` instead.'
'`linkRender` and `nameRender` are removed, please use `itemRender` instead.'
);
}

Expand Down
4 changes: 2 additions & 2 deletions components/breadcrumb/style/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "../../style/themes/default";

@breadcrumb-prefix-cls: ant-breadcrumb;
@breadcrumb-prefix-cls: ~"@{ant-prefix}-breadcrumb";

.@{breadcrumb-prefix-cls} {
color: #999;
Expand Down Expand Up @@ -29,7 +29,7 @@
}

&-link {
> .anticon + span {
> .@{iconfont-css-prefix} + span {
margin-left: 4px;
}
}
Expand Down
10 changes: 5 additions & 5 deletions components/button/button-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import * as React from 'react';
import classNames from 'classnames';
import splitObject from '../_util/splitObject';

const prefix = 'ant-btn-group-';

export type ButtonSize = 'small' | 'large'

export interface ButtonGroupProps {
size?: ButtonSize;
style?: React.CSSProperties;
className?: string;
prefixCls?: string;
}

export default function ButtonGroup(props: ButtonGroupProps) {
const [{ size, className }, others] = splitObject(props, ['size', 'className']);
const [{ prefixCls = 'ant-btn-group', size, className }, others] =
splitObject(props, ['prefixCls', 'size', 'className']);

// large => lg
// small => sm
Expand All @@ -23,8 +23,8 @@ export default function ButtonGroup(props: ButtonGroupProps) {
})[size] || '';

const classes = classNames({
'ant-btn-group': true,
[prefix + sizeCls]: sizeCls,
[prefixCls]: true,
[`${prefixCls}-${sizeCls}`]: sizeCls,
[className]: className,
});

Expand Down
6 changes: 3 additions & 3 deletions components/button/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@import "../../style/mixins/index";
@import "./mixin";

@btn-prefix-cls: ant-btn;
@btn-prefix-cls: ~"@{ant-prefix}-btn";

// Button styles
// -----------------------------
Expand Down Expand Up @@ -69,7 +69,7 @@
padding-left: 29px;
pointer-events: none;
position: relative;
.anticon {
.@{iconfont-css-prefix} {
margin-left: -14px;
transition: all .3s @ease-in-out;
}
Expand All @@ -80,7 +80,7 @@

&-sm&-loading {
padding-left: 24px;
.anticon {
.@{iconfont-css-prefix} {
margin-left: -17px;
}
}
Expand Down
12 changes: 6 additions & 6 deletions components/calendar/style/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "../../style/themes/default";

@full-calendar-prefix-cls: ant-fullcalendar;
@full-calendar-prefix-cls: ~"@{ant-prefix}-fullcalendar";

.@{full-calendar-prefix-cls} {
font-size: @font-size-base;
Expand All @@ -14,16 +14,16 @@
padding: 11px 16px 11px 0;
text-align: right;

.ant-select {
.@{ant-prefix}-select {
text-align: left;
}

.ant-radio-group {
.@{ant-prefix}-radio-group {
margin-left: 8px;
text-align: left;
}

label.ant-radio-button {
label.@{ant-prefix}-radio-button {
height: 22px;
line-height: 20px;
padding: 0 10px;
Expand Down Expand Up @@ -162,10 +162,10 @@
}

&-fullscreen &-header {
.ant-radio-group {
.@{ant-prefix}-radio-group {
margin-left: 16px;
}
label.ant-radio-button {
label.@{ant-prefix}-radio-button {
height: 28px;
line-height: 26px;
}
Expand Down
2 changes: 1 addition & 1 deletion components/card/style/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "../../style/themes/default";

@card-prefix-cls: ant-card;
@card-prefix-cls: ~"@{ant-prefix}-card";

.@{card-prefix-cls} {
background: #fff;
Expand Down
6 changes: 4 additions & 2 deletions components/carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ export interface CarouselProps {
afterChange?: (current: number) => void;
/** 行内样式 */
style?: React.CSSProperties;
prefixCls?: string;
}

export default class Carousel extends React.Component<CarouselProps, any> {
static defaultProps = {
dots: true,
arrows: false,
prefixCls: 'ant-carousel',
};

render() {
Expand All @@ -53,9 +55,9 @@ export default class Carousel extends React.Component<CarouselProps, any> {
props.draggable = false;
}

let className = 'ant-carousel';
let className = props.prefixCls;
if (props.vertical) {
className = `${className} ant-carousel-vertical`;
className = `${className} ${className}-vertical`;
}

return (
Expand Down
4 changes: 2 additions & 2 deletions components/carousel/style/index.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "../../style/themes/default";
@import "../../style/mixins/index";

.ant-carousel {
.@{ant-prefix}-carousel {
.slick-slider {
position: relative;
display: block;
Expand Down Expand Up @@ -204,7 +204,7 @@
}
}

.ant-carousel-vertical {
.@{ant-prefix}-carousel-vertical {
.slick-slider {
padding-bottom: 0;
}
Expand Down
23 changes: 13 additions & 10 deletions components/cascader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type CascaderExpandTrigger = 'click' | 'hover'

export interface ShowSearchType {
filter?: (inputValue: string, path: CascaderOptionType[]) => boolean;
render?: (inputValue: string, path: CascaderOptionType[]) => React.ReactNode;
render?: (inputValue: string, path: CascaderOptionType[], prefixCls: string) => React.ReactNode;
sort?: (a: CascaderOptionType[], b: CascaderOptionType[], inputValue: string) => number;
matchInputWidth?: boolean;
}
Expand Down Expand Up @@ -58,12 +58,14 @@ export interface CascaderProps {
changeOnSelect?: boolean;
/** 浮层可见变化时回调 */
onPopupVisibleChange?: (popupVisible: boolean) => void;
prefixCls?: string;
inputPrefixCls?: string;
}

function highlightKeyword(str: string, keyword: string) {
function highlightKeyword(str: string, keyword: string, prefixCls: string) {
return str.split(keyword)
.map((node: string, index: number) => index === 0 ? node : [
<span className="ant-cascader-menu-item-keyword" key="seperator">{keyword}</span>,
<span className={`${prefixCls}-menu-item-keyword`} key="seperator">{keyword}</span>,
node,
]);
}
Expand All @@ -72,9 +74,9 @@ function defaultFilterOption(inputValue, path) {
return path.some(option => option.label.indexOf(inputValue) > -1);
}

function defaultRenderFilteredOption(inputValue, path) {
function defaultRenderFilteredOption(inputValue, path, prefixCls) {
return path.map(({ label }, index) => {
const node = label.indexOf(inputValue) > -1 ? highlightKeyword(label, inputValue) : label;
const node = label.indexOf(inputValue) > -1 ? highlightKeyword(label, inputValue, prefixCls) : label;
return index === 0 ? node : [' / ', node];
});
}
Expand All @@ -90,6 +92,7 @@ function defaultSortFilteredOption(a, b, inputValue) {
export default class Cascader extends React.Component<CascaderProps, any> {
static defaultProps = {
prefixCls: 'ant-cascader',
inputPrefixCls: 'ant-input',
placeholder: 'Please select',
transitionName: 'slide-up',
popupPlacement: 'bottomLeft',
Expand Down Expand Up @@ -206,7 +209,7 @@ export default class Cascader extends React.Component<CascaderProps, any> {
return flattenOptions;
}

generateFilteredOptions() {
generateFilteredOptions(prefixCls) {
const { showSearch, notFoundContent } = this.props;
const {
filter = defaultFilterOption,
Expand All @@ -220,7 +223,7 @@ export default class Cascader extends React.Component<CascaderProps, any> {
if (filtered.length > 0) {
return filtered.map((path) => {
return {
label: render(inputValue, path),
label: render(inputValue, path, prefixCls),
value: path.map(o => o.value),
};
});
Expand All @@ -238,8 +241,8 @@ export default class Cascader extends React.Component<CascaderProps, any> {
const value = state.value;

const sizeCls = classNames({
'ant-input-lg': size === 'large',
'ant-input-sm': size === 'small',
[`${props.inputPrefixCls}-lg`]: size === 'large',
[`${props.inputPrefixCls}-sm`]: size === 'small',
});
const clearIcon = (allowClear && !disabled && value.length > 0) || state.inputValue ?
<Icon type="cross-circle"
Expand Down Expand Up @@ -279,7 +282,7 @@ export default class Cascader extends React.Component<CascaderProps, any> {

let options = props.options;
if (state.inputValue) {
options = this.generateFilteredOptions();
options = this.generateFilteredOptions(prefixCls);
}
// Dropdown menu should keep previous status until it is fully closed.
if (!state.popupVisible) {
Expand Down
4 changes: 2 additions & 2 deletions components/cascader/style/index.less
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@import "../../style/themes/default";
@import "../../style/mixins/index";

@cascader-prefix-cls: ant-cascader;
@cascader-prefix-cls: ~"@{ant-prefix}-cascader";

.@{cascader-prefix-cls} {
font-size: @font-size-base;
&-input.ant-input {
&-input.@{ant-prefix}-input {
background-color: transparent;
display: block;
cursor: pointer;
Expand Down
Loading

0 comments on commit 73a6bfb

Please sign in to comment.