useBorders.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import useVars from './useVars.js'
  2. import { getClasses } from '../utils/classes.js'
  3. import useColor from './useColor.js'
  4. function useHook() { // useBorders
  5. const { colors, color } = useColor()
  6. const { pxs, percents, border_radius } = useVars()
  7. const BorderRadius = {
  8. title: 'Border Radius',
  9. classes: getClasses(border_radius, {
  10. name: [
  11. 'rounded-',
  12. 'rounded-s-',
  13. 'rounded-e-',
  14. 'rounded-t-',
  15. 'rounded-r-',
  16. 'rounded-b-',
  17. 'rounded-l-',
  18. 'rounded-ss-',
  19. 'rounded-se-',
  20. 'rounded-ee-',
  21. 'rounded-es-',
  22. 'rounded-tl-',
  23. 'rounded-tr-',
  24. 'rounded-br-',
  25. 'rounded-bl-'
  26. ],
  27. value: [
  28. 'border-radius',
  29. 'border-start-start-radius, border-end-start-radius',
  30. 'border-start-end-radius, border-end-end-radius',
  31. 'border-top-left-radius, border-top-right-radius',
  32. 'border-top-right-radius, border-bottom-right-radius',
  33. 'border-bottom-right-radius, border-bottom-left-radius',
  34. 'border-top-left-radius, border-bottom-left-radius',
  35. 'border-start-start-radius',
  36. 'border-start-end-radius',
  37. 'border-end-end-radius',
  38. 'border-end-start-radius',
  39. 'border-top-left-radius',
  40. 'border-top-right-radius',
  41. 'border-bottom-right-radius',
  42. 'border-bottom-left-radius',
  43. ],
  44. })
  45. }
  46. const BorderWidth = {
  47. title: 'Border Width',
  48. classes: getClasses(
  49. ', 0, 2, 3, 4, 8'.split(',').map(d => {
  50. d = d.trim()
  51. return {
  52. name: d,
  53. value: d === '' ? '1rpx' : `${d * 2}rpx`
  54. }
  55. }), {
  56. name: [
  57. 'border-',
  58. 'border-x-',
  59. 'border-y-',
  60. 'border-s-',
  61. 'border-e-',
  62. 'border-t-',
  63. 'border-r-',
  64. 'border-b-',
  65. 'border-l-',
  66. ],
  67. value: [
  68. 'border-width',
  69. 'border-left-width, border-right-width',
  70. 'border-top-width, border-bottom-width',
  71. 'border-inline-start-width',
  72. 'border-inline-end-width',
  73. 'border-top-width',
  74. 'border-right-width',
  75. 'border-bottom-width',
  76. 'border-left-width',
  77. ],
  78. }),
  79. }
  80. const BorderColor = {
  81. title: 'Border Color',
  82. classes: color.map(c => {
  83. return {
  84. ...c,
  85. name: `border-${c.name}`,
  86. value: [`border-color: ${c.value};`],
  87. desc: c.rgb,
  88. }
  89. })
  90. }
  91. const BorderStyle = {
  92. title: 'Border Style',
  93. classes: getClasses('solid, dashed, dotted, double, hidden, none', { name: 'border-', value: 'border-style' })
  94. }
  95. const DivideWidth = { title: 'Divide Width', classes: [] }
  96. const DivideColor = { title: 'Divide Color', classes: [] }
  97. const DivideStyle = { title: 'Divide Style', classes: [] }
  98. const OutlineWidth = { title: 'Outline Width', classes: [] }
  99. const OutlineColor = { title: 'Outline Color', classes: [] }
  100. const OutlineStyle = { title: 'Outline Style', classes: [] }
  101. const OutlineOffset = { title: 'Outline Offset', classes: [] }
  102. const RingWidth = { title: 'Ring Width', classes: [] }
  103. const RingColor = { title: 'Ring Color', classes: [] }
  104. const RingOffsetWidth = { title: 'Ring Offset Width', classes: [] }
  105. const RingOffsetColor = { title: 'Ring Offset Color', classes: [] }
  106. return {
  107. BorderRadius,
  108. BorderWidth,
  109. BorderColor,
  110. BorderStyle,
  111. DivideWidth,
  112. DivideColor,
  113. DivideStyle,
  114. OutlineWidth,
  115. OutlineColor,
  116. OutlineStyle,
  117. OutlineOffset,
  118. RingWidth,
  119. RingColor,
  120. RingOffsetWidth,
  121. RingOffsetColor
  122. }
  123. }
  124. export default useHook