zhangyong
2023-08-22 1353e87cb21a4032d585d7404bae9042f2ebcf08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
@use 'mixins/mixins' as *;
@use 'mixins/var' as *;
@use 'common/var' as *;
 
@include b(tooltip-v2) {
  @include e(content) {
    --#{$namespace}-tooltip-v2-padding: 5px 10px;
    --#{$namespace}-tooltip-v2-border-radius: 4px;
 
    @include css-var-from-global(
      ('tooltip-v2', 'border-color'),
      ('border-color')
    );
 
    border-radius: getCssVar('tooltip-v2-border-radius');
    color: getCssVar('color-black');
    background-color: getCssVar('color-white');
    padding: getCssVar('tooltip-v2-padding');
    border: 1px solid getCssVar('border-color');
 
    $content-selector: &;
 
    $sides: (
      'top': 'bottom',
      'bottom': 'top',
      'left': 'right',
      'right': 'left',
    );
 
    @include e(arrow) {
      position: absolute;
      color: getCssVar('color-white');
      width: var(--#{$namespace}-tooltip-v2-arrow-width);
      height: var(--#{$namespace}-tooltip-v2-arrow-height);
      pointer-events: none;
      left: var(--#{$namespace}-tooltip-v2-arrow-x);
      top: var(--#{$namespace}-tooltip-v2-arrow-y);
 
      &::before {
        content: '';
        width: 0;
        height: 0;
        border: var(--#{$namespace}-tooltip-v2-arrow-border-width) solid
          transparent;
        position: absolute;
      }
 
      &::after {
        content: '';
        width: 0;
        height: 0;
        border: var(--#{$namespace}-tooltip-v2-arrow-border-width) solid
          transparent;
        position: absolute;
      }
 
      @each $side, $opposite in $sides {
        #{$content-selector}[data-side^='#{$side}'] & {
          #{$opposite}: 0;
        }
 
        #{$content-selector}[data-side^='#{$side}'] &::before {
          border-#{$side}-color: var(--#{$namespace}-color-white);
          border-#{$side}-width: var(
            --#{$namespace}-tooltip-v2-arrow-border-width
          );
          border-#{$opposite}: 0;
          #{$side}: calc(100% - 1px);
        }
 
        #{$content-selector}[data-side^='#{$side}'] &::after {
          border-#{$side}-color: var(--#{$namespace}-border-color);
          border-#{$side}-width: var(
            --#{$namespace}-tooltip-v2-arrow-border-width
          );
          border-#{$opposite}: 0;
          #{$side}: 100%;
          z-index: -1;
        }
      }
    }
 
    &.is-dark {
      --#{$namespace}-tooltip-v2-border-color: transparent;
      background-color: getCssVar('color-black');
      color: getCssVar('color-white');
      border-color: transparent;
 
      @include e(arrow) {
        background-color: getCssVar('color-black');
        border-color: transparent;
      }
    }
  }
}