Skip to content

Commit

Permalink
Merge pull request #932 from XiaoMi/hotfix/theme
Browse files Browse the repository at this point in the history
Hotfix/theme
  • Loading branch information
solarjoker authored Feb 7, 2020
2 parents e7e860b + b187f6c commit 0d4f9f2
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 21 deletions.
9 changes: 7 additions & 2 deletions components/dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import classNames from 'classnames'
import PropTypes from 'prop-types'
import DropdownButton from './DropdownButton'
import DropdownMenu, { propTypesOfMenuData } from './DropdownMenu'
import Provider from '../context'

import { prefixCls } from '.'
import { getIsTriggerEqualHover, getIsTriggerEqualContextmenu, trimTriggers } from './utils'
class Dropdown extends React.Component {
Expand Down Expand Up @@ -92,7 +94,7 @@ class Dropdown extends React.Component {
document.removeEventListener('click', this.handleDocumentClick)
}
render () {
const { className, style, title, type, placement, data, disabled, width, onButtonClick } = this.props
const { className, style, title, type, placement, data, disabled, width, onButtonClick, theme } = this.props
const { visible } = this.state
const dropdownCls = classNames(prefixCls, prefixCls + '--' + type, className, disabled && `${prefixCls}--disabled`)
return (
Expand All @@ -101,13 +103,15 @@ class Dropdown extends React.Component {
{...this.getPopperShowHandler()}
{...this.getPopperHideHandler()}
type={type}
theme={theme}
visible={visible}
onButtonClick={onButtonClick}
disabled={disabled}
>
{title}
</DropdownButton>
<DropdownMenu
theme={theme}
visible={visible}
attachEle={this.refDropdown.current}
data={data}
Expand Down Expand Up @@ -143,4 +147,5 @@ Dropdown.defaultProps = {
trigger: 'hover',
width: 240
}
export default Dropdown
export default Provider(Dropdown)
export {Dropdown}
4 changes: 2 additions & 2 deletions components/dropdown/DropdownMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import classNames from 'classnames'
import Popper from '../popper'
import { prefixCls } from '.'
import DropdownMenuItem from './DropdownMenuItem'
import Provider from '../context'

class DropdownMenu extends React.Component {
render () {
Expand Down Expand Up @@ -36,6 +35,7 @@ class DropdownMenu extends React.Component {
<ul className={menuCls}>
{data.map((item, index) => (
<DropdownMenuItem
theme={theme}
key={index}
{...item}
parentPopperVisible={visible}
Expand All @@ -50,7 +50,7 @@ class DropdownMenu extends React.Component {
)
}
}
export default Provider(DropdownMenu)
export default DropdownMenu
export const propTypesOfMenuData = PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
Expand Down
4 changes: 3 additions & 1 deletion components/dropdown/DropdownMenuItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export default class DropdownMenuItem extends React.Component {
href,
disabled,
onMenuItemClick,
width
width,
theme
} = this.props
const { visible } = this.state
const shouldRenderDivider = title === '-'
Expand Down Expand Up @@ -93,6 +94,7 @@ export default class DropdownMenuItem extends React.Component {
<Icon name='right' className={iconCls} />
<DropdownMenu
data={children}
theme={theme}
visible={visible && parentPopperVisible}
placement='right-start'
attachEle={this.refItem.current}
Expand Down
2 changes: 1 addition & 1 deletion components/menu/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.15);

.hi-menu-item {
&--active:not(.hi-submenu) {
&--active {
background-color: rgba($value, 0.15);

&::after {
Expand Down
15 changes: 14 additions & 1 deletion components/table/style/Table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,12 @@ $borderColor: #e6e7e8 !default;
@each $key, $value in $theme-colors {
.theme__#{$key}.hi-table {
.hi-table-container table th {
background-color: rgba($value, 0.1);
background-color: rgba($value, 0.3);
color: #83868c;
}

.hi-table-container table tr {
background-color: #fff;
color: #83868c;
}

Expand All @@ -481,5 +486,13 @@ $borderColor: #e6e7e8 !default;
background-color: rgba($value, 0.15);
color: $value;
}

&.striped {
table {
tr:nth-child(2n) {
background: rgba($value, 0.1);
}
}
}
}
}
5 changes: 3 additions & 2 deletions components/transfer/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Item extends Component {
sourceNode,
dir,
draggable,
dividerPosition
dividerPosition,
theme
} = this.props
const sourceStyle =
sourceNode === item.id && isDragging
Expand All @@ -27,7 +28,7 @@ class Item extends Component {
color: 'rgba(204,204,204,1)'
}
: {}
const itemCls = classNames('hi-transfer__item', item.disabled && 'hi-transfer__item--disabled')
const itemCls = classNames('hi-transfer__item', `theme__${theme}`, item.disabled && 'hi-transfer__item--disabled')
const el = (
<li style={sourceStyle} className={itemCls} onClick={onClick.bind(this)}>
{targetNode === item.id &&
Expand Down
13 changes: 8 additions & 5 deletions components/transfer/Transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import Input from '../input'
import classNames from 'classnames'
import Item from './Item'
import shallowEqual from 'shallowequal'
import Provider from '../context'

import './style/index'

export default class Transfer extends Component {
class Transfer extends Component {
constructor (props) {
super(props)
this.state = {
Expand Down Expand Up @@ -260,7 +260,8 @@ export default class Transfer extends Component {
draggable,
emptyContent,
title,
disabled
disabled,
theme
} = this.props
const {
sourceSelectedKeys,
Expand Down Expand Up @@ -321,6 +322,7 @@ export default class Transfer extends Component {
dividerPosition={dividerPosition}
draggable={draggable}
key={index}
theme={theme}
onClick={this.clickItemEvent.bind(this, item, index, dir)}
mode={mode === 'basic' && type === 'default' ? 'basic' : 'multiple'}
item={item}
Expand Down Expand Up @@ -364,7 +366,7 @@ export default class Transfer extends Component {
}

render () {
const { mode, type } = this.props
const { mode, type, theme } = this.props
const { sourceList, targetList, sourceSelectedKeys, targetSelectedKeys, limited } = this.state
const operCls = classNames(
'hi-transfer__operation',
Expand All @@ -373,7 +375,7 @@ export default class Transfer extends Component {
const isLeftDisabled = targetSelectedKeys.length === 0
const isRightDisabled = sourceSelectedKeys.length === 0 || limited
return (
<div className='hi-transfer'>
<div className={`hi-transfer theme__${theme}`}>
{this.renderContainer('left', sourceList)}
<div className={operCls}>
{(mode !== 'basic' || type !== 'default') &&
Expand Down Expand Up @@ -406,6 +408,7 @@ export default class Transfer extends Component {
)
}
}
export default Provider(Transfer)
Transfer.defaultProps = {
mode: 'basic',
type: 'default',
Expand Down
14 changes: 12 additions & 2 deletions components/transfer/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,18 @@

@each $key, $value in $theme-colors {
.hi-transfer {
&__item {
.theme__#{$key}.hi-checkbox-legacy--checked .hi-checkbox-legacy__input {
&.theme__#{$key} {
.hi-transfer__divider--up {
background-color: $value;
}

.hi-transfer__divider--down {
background-color: $value;
}
}

&__item.theme__#{$key} {
.hi-checkbox-legacy--checked .hi-checkbox-legacy__input {
border: 1px solid $value;
}

Expand Down
1 change: 1 addition & 0 deletions components/tree/TreeDivider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const TreeDivider = props => {
<div
className={ClassNames(
'hi-tree__divider',
`theme__${props.theme}`,
`hi-tree__divider--${props.placement}`
)}
>
Expand Down
8 changes: 4 additions & 4 deletions components/tree/TreeItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TreeItem extends Component {
)}
>
{targetNode === item.id && dropDividerPosition === 'up' && isOver && (
<TreeDivider placement='top' />
<TreeDivider placement='top' theme={theme} />
)}
<div
className={classNames('item__wrapper', {
Expand All @@ -81,7 +81,7 @@ class TreeItem extends Component {
{(!item.children || (item.children && !expanded)) &&
targetNode === item.id &&
dropDividerPosition === 'down' &&
isOver && <TreeDivider placement='bottom' />}
isOver && <TreeDivider theme={theme} placement='bottom' />}
{
<span
onClick={() => {
Expand Down Expand Up @@ -182,7 +182,7 @@ class TreeItem extends Component {
{item.title}
{/* {renderRightClickMenu(item)} */}
{targetNode === item.id && dropDividerPosition === 'sub' && isOver && (
<TreeDivider placement='inner' />
<TreeDivider placement='inner' theme={this.props.theme} />
)}
</span>
)
Expand Down Expand Up @@ -221,7 +221,7 @@ class TreeItem extends Component {
expanded &&
targetNode === item.id &&
dropDividerPosition === 'down' &&
isOver && <TreeDivider placement='bottom' />}
isOver && <TreeDivider placement='bottom' theme={this.props.theme} />}
</li>
)
return draggable ? connectDropTarget(treeItem) : treeItem
Expand Down
2 changes: 1 addition & 1 deletion components/tree/TreeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ class TreeNode extends Component {
}
}

let contextMenuPanel = <ul className='right-click-menu' style={{left: rect.left + rect.width + 5, top: rect.top + _st}}>
let contextMenuPanel = <ul className={`right-click-menu theme__${this.props.theme}`} style={{left: rect.left + rect.width + 5, top: rect.top + _st}}>
{
_cm.length > 0
? _cm.map((cm, index) => {
Expand Down
16 changes: 16 additions & 0 deletions components/tree/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -570,5 +570,21 @@ $tree: 'hi-tree' !default;
background-color: $value;
}
}

.hi-tree__divider {
.divider-line {
background-color: $value;
}

.divider-circle {
border: 1px solid $value;
}
}
}

.theme__#{$key}.right-click-menu {
li:hover {
background-color: rgba($value, 0.15);
}
}
}

0 comments on commit 0d4f9f2

Please sign in to comment.