hairline.less 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // inspired by https://github.com/nolimits4web/Framework7/blob/v2/src/less/mixins.less#L76
  2. // but more powerful, both support viewport scale and not scale usage.
  3. @import '../themes/default.less';
  4. .scale-hairline-common() {
  5. position: relative;
  6. border: none;
  7. &::before {
  8. content: '';
  9. position: absolute;
  10. left: 0;
  11. top: 0;
  12. width: 200%;
  13. height: 200%;
  14. transform-origin: 0 0;
  15. transform: scale(0.5);
  16. box-sizing: border-box;
  17. pointer-events: none;
  18. }
  19. }
  20. .hairline(@direction, @color: @border-color-base, @radius: 0)
  21. when
  22. (@direction = 'top') {
  23. &::before {
  24. border-top: 1px solid @color;
  25. border-radius: @radius * 2;
  26. }
  27. }
  28. .hairline(@direction, @color: @border-color-base, @radius: 0)
  29. when
  30. (@direction = 'right') {
  31. &::before {
  32. border-right: 1px solid @color;
  33. border-radius: @radius * 2;
  34. }
  35. }
  36. .hairline(@direction, @color: @border-color-base, @radius: 0)
  37. when
  38. (@direction = 'bottom') {
  39. &::before {
  40. border-bottom: 1px solid @color;
  41. border-radius: @radius * 2;
  42. }
  43. }
  44. .hairline(@direction, @color: @border-color-base, @radius: 0)
  45. when
  46. (@direction = 'left') {
  47. &::before {
  48. border-left: 1px solid @color;
  49. border-radius: @radius * 2;
  50. }
  51. }
  52. .hairline(@direction, @color: @border-color-base, @radius: 0)
  53. when
  54. (@direction = 'all') {
  55. &::before {
  56. border: 1px solid @color;
  57. border-radius: @radius * 2;
  58. }
  59. }
  60. .hairline-remove(@position) when (@position = 'left') {
  61. &:before {
  62. border-left: 0;
  63. }
  64. }
  65. .hairline-remove(@position) when (@position = 'right') {
  66. &:before {
  67. border-right: 0;
  68. }
  69. }
  70. .hairline-remove(@position) when (@position = 'top') {
  71. &:before {
  72. border-top: 0;
  73. }
  74. }
  75. .hairline-remove(@position) when (@position = 'bottom') {
  76. &:before {
  77. border-bottom: 0;
  78. }
  79. }
  80. .hairline-remove(@position) when (@position = 'all') {
  81. &:before {
  82. border: 0;
  83. display: none !important;
  84. }
  85. }