form-ruler.scss 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. --tick-width: 5px;
  42. position: relative;
  43. width: calc(var(--width) + 2px);
  44. height: calc(var(--height) + 2px);
  45. border: 1px solid #D3D4D5;
  46. border-radius: var(--height);
  47. box-sizing: border-box;
  48. overflow: hidden;
  49. &::before,
  50. &::after {
  51. content: '';
  52. position: absolute;
  53. left: 50%;
  54. transform: translateX(-50%);
  55. }
  56. &::before {
  57. top: 0;
  58. @include triangle(14px, var(--active-color), 'down');
  59. }
  60. &::after {
  61. bottom: 0;
  62. @include triangle(14px, var(--active-color), 'up');
  63. }
  64. &__inner {
  65. display: flex;
  66. flex-direction: row;
  67. align-items: center;
  68. height: 100%;
  69. }
  70. &__axis {
  71. position: relative;
  72. height: 32px;
  73. transform: translateY(calc(var(--height) * 0.25));
  74. font-size: 12px;
  75. width: 5px;
  76. box-sizing: border-box;
  77. text {
  78. position: absolute;
  79. left: 2px;
  80. bottom: -10px;
  81. }
  82. .tick {
  83. height: calc(var(--height) * 0.2);
  84. border-left: 1px solid #D3D4D5;
  85. }
  86. .median {
  87. height: calc(var(--height) * 0.32);
  88. border-left: 1px solid #D3D4D5;
  89. }
  90. .integer {
  91. height: calc(var(--height) * 0.5);
  92. border-left: 1px solid #D3D4D5;
  93. }
  94. }
  95. }