form-ruler.scss 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* components/form-ruler/form-ruler.wxss */
  2. // 定义一个混合,用于生成三角形
  3. @mixin triangle($size, $color, $direction) {
  4. height: 0;
  5. width: 0;
  6. border-color: transparent;
  7. border-style: solid;
  8. border-width: $size * 0.5;
  9. @if $direction=='up' {
  10. border-bottom-color: $color;
  11. }
  12. @else if $direction=='right' {
  13. border-left-color: $color;
  14. }
  15. @else if $direction=='down' {
  16. border-top-color: $color;
  17. }
  18. @else if $direction=='left' {
  19. border-right-color: $color;
  20. }
  21. @else {
  22. @error "Unknown direction #{$direction}.";
  23. }
  24. }
  25. .show-data {
  26. display: flex;
  27. flex-direction: row;
  28. justify-content: center;
  29. align-items: flex-end;
  30. margin: 12px 0;
  31. font-size: 12px;
  32. .value {
  33. margin: 0 4px;
  34. font-size: 18px;
  35. }
  36. }
  37. .form-ruler {
  38. --height: 56px;
  39. --width: 100%;
  40. // --active-color: #34A76B;
  41. --active-color:#1D6FF6;
  42. --tick-width: 5px;
  43. position: relative;
  44. width: calc(var(--width) + 2px);
  45. height: calc(var(--height) + 2px);
  46. border: 1px solid #D3D4D5;
  47. border-radius: var(--height);
  48. box-sizing: border-box;
  49. overflow: hidden;
  50. &::before,
  51. &::after {
  52. content: '';
  53. position: absolute;
  54. left: 50%;
  55. transform: translateX(-50%);
  56. }
  57. &::before {
  58. top: 0;
  59. @include triangle(14px, var(--active-color), 'down');
  60. }
  61. &::after {
  62. bottom: 0;
  63. @include triangle(14px, var(--active-color), 'up');
  64. }
  65. &__inner {
  66. display: flex;
  67. flex-direction: row;
  68. align-items: center;
  69. height: 100%;
  70. }
  71. &__axis {
  72. position: relative;
  73. height: 32px;
  74. transform: translateY(calc(var(--height) * 0.25));
  75. font-size: 12px;
  76. width: 5px;
  77. box-sizing: border-box;
  78. text {
  79. position: absolute;
  80. left: 2px;
  81. bottom: -10px;
  82. }
  83. .tick {
  84. height: calc(var(--height) * 0.2);
  85. border-left: 1px solid #D3D4D5;
  86. }
  87. .median {
  88. height: calc(var(--height) * 0.32);
  89. border-left: 1px solid #D3D4D5;
  90. }
  91. .integer {
  92. height: calc(var(--height) * 0.5);
  93. border-left: 1px solid #D3D4D5;
  94. }
  95. }
  96. }