Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
52fbd050
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
52fbd050
编写于
9月 28, 2015
作者:
P
popomore
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: support more placement for popover
Ref #312
上级
3baeaeb0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
106 addition
and
28 deletion
+106
-28
components/popover/demo/placement.md
components/popover/demo/placement.md
+33
-5
components/popover/index.jsx
components/popover/index.jsx
+28
-13
components/popover/index.md
components/popover/index.md
+2
-2
style/components/popover.less
style/components/popover.less
+43
-8
未找到文件。
components/popover/demo/placement.md
浏览文件 @
52fbd050
...
...
@@ -2,7 +2,7 @@
-
order: 1
位置有
四
个方向。
位置有
十二
个方向。
---
...
...
@@ -16,23 +16,51 @@ const content = <div>
</
div
>;
ReactDOM
.
render
(<
div
>
<
Popover
placement
=
"left"
title
=
{
text
}
overlay
=
{
content
}
>
<
Popover
placement
=
"leftTop"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
button
className
=
"ant-btn"
>
左上
</
button
>
</
Popover
>
<
Popover
placement
=
"left"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
Button
>
左
</
Button
>
</
Popover
>
<
Popover
placement
=
"top"
title
=
{
text
}
overlay
=
{
content
}
>
<
Popover
placement
=
"leftBottom"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
button
className
=
"ant-btn"
>
左下
</
button
>
</
Popover
>
<
br
/>
<
Popover
placement
=
"topLeft"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
button
className
=
"ant-btn"
>
上左
</
button
>
</
Popover
>
<
Popover
placement
=
"top"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
Button
>
上
</
Button
>
</
Popover
>
<
Popover
placement
=
"bottom"
title
=
{
text
}
overlay
=
{
content
}
>
<
Popover
placement
=
"topRight"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
button
className
=
"ant-btn"
>
上右
</
button
>
</
Popover
>
<
br
/>
<
Popover
placement
=
"bottomLeft"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
button
className
=
"ant-btn"
>
下左
</
button
>
</
Popover
>
<
Popover
placement
=
"bottom"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
Button
>
下
</
Button
>
</
Popover
>
<
Popover
placement
=
"right"
title
=
{
text
}
overlay
=
{
content
}
>
<
Popover
placement
=
"bottomRight"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
button
className
=
"ant-btn"
>
下右
</
button
>
</
Popover
>
<
br
/>
<
Popover
placement
=
"rightTop"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
button
className
=
"ant-btn"
>
右上
</
button
>
</
Popover
>
<
Popover
placement
=
"right"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
Button
>
右
</
Button
>
</
Popover
>
<
Popover
placement
=
"rightBottom"
title
=
{
text
}
overlay
=
{
content
}
trigger
=
"click"
>
<
button
className
=
"ant-btn"
>
右下
</
button
>
</
Popover
>
</
div
>,
document
.
getElementById
(
'
components-popover-demo-placement
'
));
````
<style>
.code-box-demo .ant-btn {
margin-right: 1em;
margin-bottom: 1em;
}
</style>
components/popover/index.jsx
浏览文件 @
52fbd050
import
React
from
'
react
'
;
import
Tooltip
from
'
rc-tooltip
'
;
const
prefixCls
=
'
ant-popover
'
;
export
default
React
.
createClass
({
const
Popover
=
React
.
createClass
({
getDefaultProps
()
{
return
{
prefixCls
:
prefixCls
,
...
...
@@ -13,28 +14,42 @@ export default React.createClass({
overlayStyle
:
{}
};
},
render
()
{
const
overlay
=
<
div
>
<
div
className
=
{
prefixCls
+
'
-title
'
}
>
{
this
.
props
.
title
}
</
div
>
<
div
className
=
{
prefixCls
+
'
-content
'
}
>
{
this
.
props
.
overlay
}
</
div
>
</
div
>;
render
()
{
const
transitionName
=
({
top
:
'
zoom-down
'
,
bottom
:
'
zoom-up
'
,
left
:
'
zoom-right
'
,
right
:
'
zoom-left
'
right
:
'
zoom-left
'
,
topLeft
:
'
zoom-down
'
,
bottomLeft
:
'
zoom-up
'
,
leftTop
:
'
zoom-right
'
,
rightTop
:
'
zoom-left
'
,
topRight
:
'
zoom-down
'
,
bottomRight
:
'
zoom-up
'
,
leftBottom
:
'
zoom-right
'
,
rightBottom
:
'
zoom-left
'
,
})[
this
.
props
.
placement
];
return
(
<
Tooltip
transitionName
=
{
transitionName
}
{
...
this
.
props
}
overlay
=
{
overlay
}
>
{
...
this
.
props
}
overlay
=
{
this
.
getOverlay
()
}
>
{
this
.
props
.
children
}
</
Tooltip
>
);
}
},
getOverlay
()
{
return
<
div
>
<
div
className
=
{
prefixCls
+
'
-title
'
}
>
{
this
.
props
.
title
}
</
div
>
<
div
className
=
{
prefixCls
+
'
-content
'
}
>
{
this
.
props
.
overlay
}
</
div
>
</
div
>;
},
});
export
default
Popover
;
components/popover/index.md
浏览文件 @
52fbd050
...
...
@@ -22,5 +22,5 @@
| trigger | 触发行为,可选
`hover/focus/click`
| string | hover |
| placement | 气泡框位置,可选
`top/left/right/bottom`
| string | top |
| title | 卡片标题 | React.Element | 无 |
|
content
| 卡片内容 | React.Element | 无 |
|
overlayClassName
| 浮层的类名 | string | 无 |
|
overlay
| 卡片内容 | React.Element | 无 |
|
prefixCls
| 浮层的类名 | string | 无 |
style/components/popover.less
浏览文件 @
52fbd050
...
...
@@ -54,7 +54,7 @@
}
// Offset the popover to account for the popover arrow
&-placement-top {
&-placement-top
, &-placement-topLeft, &-placement-topRight
{
margin-top: -@popover-arrow-width;
padding-bottom: @popover-distance;
&:after {
...
...
@@ -65,7 +65,7 @@
}
}
&-placement-right {
&-placement-right
, &-placement-rightTop, &-placement-rightBottom
{
margin-left: @popover-arrow-width;
padding-left: @popover-distance;
&:after {
...
...
@@ -76,7 +76,7 @@
}
}
&-placement-bottom {
&-placement-bottom
, &-placement-bottomLeft, &-placement-bottomRight
{
margin-top: @popover-arrow-width;
padding-top: @popover-distance;
&:after {
...
...
@@ -87,7 +87,7 @@
}
}
&-placement-left {
&-placement-left
, &-placement-leftTop, &-placement-leftBottom
{
margin-left: -@popover-arrow-width;
padding-right: @popover-distance;
&:after {
...
...
@@ -165,7 +165,9 @@
content: "";
}
&-placement-top > &-arrow {
&-placement-top > &-arrow,
&-placement-topLeft > &-arrow,
&-placement-topRight > &-arrow {
left: 50%;
margin-left: -@popover-arrow-outer-width;
border-bottom-width: 0;
...
...
@@ -179,7 +181,16 @@
border-top-color: @popover-arrow-color;
}
}
&-placement-right > &-arrow {
&-placement-topLeft > &-arrow {
left: 15%;
}
&-placement-topRight > &-arrow {
left: 85%;
}
&-placement-right > &-arrow,
&-placement-rightTop > &-arrow,
&-placement-rightBottom > &-arrow {
top: 50%;
left: @popover-distance - @popover-arrow-outer-width + 1;
margin-top: -@popover-arrow-outer-width;
...
...
@@ -193,7 +204,16 @@
border-right-color: @popover-arrow-color;
}
}
&-placement-bottom > &-arrow {
&-placement-rightTop > &-arrow {
top: 15%;
}
&-placement-rightBottom > &-arrow {
top: 85%;
}
&-placement-bottom > &-arrow,
&-placement-bottomLeft > &-arrow,
&-placement-bottomRight > &-arrow {
left: 50%;
margin-left: -@popover-arrow-outer-width;
border-top-width: 0;
...
...
@@ -207,8 +227,16 @@
border-bottom-color: @popover-arrow-color;
}
}
&-placement-bottomLeft > &-arrow {
left: 15%;
}
&-placement-bottomRight > &-arrow {
left: 85%;
}
&-placement-left > &-arrow {
&-placement-left > &-arrow,
&-placement-leftTop > &-arrow,
&-placement-leftBottom > &-arrow {
top: 50%;
right: @popover-distance - @popover-arrow-outer-width + 1;
margin-top: -@popover-arrow-outer-width;
...
...
@@ -222,4 +250,11 @@
bottom: -@popover-arrow-width;
}
}
&-placement-leftTop > &-arrow {
top: 15%;
}
&-placement-leftBottom > &-arrow {
top: 85%;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录