Skip to content

Commit

Permalink
fix: arrow style (ant-design#35401)
Browse files Browse the repository at this point in the history
* fix: arrow style

* fix: raise arrow z-index

* fix: fix defualt arrow color

* fix: mix shadow

* chore: code clean

* chore: code clean

* fix: use fadeout instead

* test: fix style lint
  • Loading branch information
MadCcc authored May 7, 2022
1 parent 9b56ad8 commit 7873bf7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
1 change: 1 addition & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{
"ignoreFunctions": [
"fade",
"fadeout",
"tint",
"darken",
"ceil",
Expand Down
12 changes: 9 additions & 3 deletions components/style/mixins/rounded-arrow.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
@e-y: @f-y + @outer-radius-without-unit * (1 / sqrt(2));
@f-x: 2 * @width-without-unit + @corner-height;
@f-y: @width-without-unit - @corner-height;
@g-x: @f-x - 1;
@g-y: @f-y;
@h-x: @a-x;
@h-y: @a-y - 1;

border-radius: 0 0 @arrow-border-radius;
pointer-events: none;
Expand All @@ -27,11 +31,13 @@
left: -@width;
width: @width * 3;
height: @width * 3;
background: linear-gradient(to left, @bg-color 50%, @bg-color 50%) no-repeat ceil(-@width + 1px)
ceil(-@width + 1px); // Hack firefox: https://github.com/ant-design/ant-design/pull/33710#issuecomment-1015287825
background: @bg-color;
// Hack firefox: https://github.com/ant-design/ant-design/pull/33710#issuecomment-1015287825
background-repeat: no-repeat;
background-position: ceil(-@width + 1px) ceil(-@width + 1px);
content: '';
clip-path: path(
'M @{a-x} @{a-y} A @{outer-radius-without-unit} @{outer-radius-without-unit} 0 0 1 @{b-x} @{b-y} L @{c-x} @{c-y} A @{inner-radius-without-unit} @{inner-radius-without-unit} 0 0 0 @{d-x} @{d-y} L @{e-x} @{e-y} A @{outer-radius-without-unit} @{outer-radius-without-unit} 0 0 1 @{f-x} @{f-y} Z'
'M @{a-x} @{a-y} A @{outer-radius-without-unit} @{outer-radius-without-unit} 0 0 1 @{b-x} @{b-y} L @{c-x} @{c-y} A @{inner-radius-without-unit} @{inner-radius-without-unit} 0 0 0 @{d-x} @{d-y} L @{e-x} @{e-y} A @{outer-radius-without-unit} @{outer-radius-without-unit} 0 0 1 @{f-x} @{f-y} L @{g-x} @{g-y} L @{h-x} @{h-y} Z'
);
}
}
32 changes: 23 additions & 9 deletions components/tooltip/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
max-width: @tooltip-max-width;
visibility: visible;

&-content {
position: relative;
}

&-hidden {
display: none;
}
Expand Down Expand Up @@ -68,6 +72,7 @@
// Arrows
&-arrow {
position: absolute;
z-index: 2;
display: block;
width: @tooltip-arrow-rotate-width;
height: @tooltip-arrow-rotate-width;
Expand All @@ -76,7 +81,12 @@
pointer-events: none;

&-content {
--antd-arrow-background-color: @tooltip-bg;
// Use linear gradient to mix box shadow of tooltip inner
--antd-arrow-background-color: linear-gradient(
to right bottom,
fadeout(@tooltip-bg, 10%),
@tooltip-bg
);

position: absolute;
top: 0;
Expand All @@ -97,7 +107,8 @@
&-placement-top &-arrow,
&-placement-topLeft &-arrow,
&-placement-topRight &-arrow {
bottom: @tooltip-distance - @tooltip-arrow-rotate-width + 0.24px;
bottom: 0;
transform: translateY(100%);

&-content {
box-shadow: @tooltip-arrow-shadow-width @tooltip-arrow-shadow-width 7px fade(@black, 7%);
Expand All @@ -107,7 +118,7 @@

&-placement-top &-arrow {
left: 50%;
transform: translateX(-50%);
transform: translateY(100%) translateX(-50%);
}

&-placement-topLeft &-arrow {
Expand All @@ -121,7 +132,8 @@
&-placement-right &-arrow,
&-placement-rightTop &-arrow,
&-placement-rightBottom &-arrow {
left: @tooltip-distance - @tooltip-arrow-rotate-width + 0.1px;
left: 0;
transform: translateX(-100%);

&-content {
box-shadow: -@tooltip-arrow-shadow-width @tooltip-arrow-shadow-width 7px fade(@black, 7%);
Expand All @@ -131,7 +143,7 @@

&-placement-right &-arrow {
top: 50%;
transform: translateY(-50%);
transform: translateX(-100%) translateY(-50%);
}

&-placement-rightTop &-arrow {
Expand All @@ -145,7 +157,8 @@
&-placement-left &-arrow,
&-placement-leftTop &-arrow,
&-placement-leftBottom &-arrow {
right: @tooltip-distance - @tooltip-arrow-rotate-width + 0.08px;
right: 0;
transform: translateX(100%);

&-content {
box-shadow: @tooltip-arrow-shadow-width -@tooltip-arrow-shadow-width 7px fade(@black, 7%);
Expand All @@ -155,7 +168,7 @@

&-placement-left &-arrow {
top: 50%;
transform: translateY(-50%);
transform: translateX(100%) translateY(-50%);
}

&-placement-leftTop &-arrow {
Expand All @@ -169,7 +182,8 @@
&-placement-bottom &-arrow,
&-placement-bottomLeft &-arrow,
&-placement-bottomRight &-arrow {
top: @tooltip-distance - @tooltip-arrow-rotate-width + 0.1px;
top: 0;
transform: translateY(-100%);

&-content {
box-shadow: -@tooltip-arrow-shadow-width -@tooltip-arrow-shadow-width 7px fade(@black, 7%);
Expand All @@ -179,7 +193,7 @@

&-placement-bottom &-arrow {
left: 50%;
transform: translateX(-50%);
transform: translateY(-100%) translateX(-50%);
}

&-placement-bottomLeft &-arrow {
Expand Down

0 comments on commit 7873bf7

Please sign in to comment.