index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="cip-divider"
  3. :class="dividerClass"
  4. :style="{ width: width,
  5. height: config.dividerHeight,
  6. color: config.textColor,
  7. 'border-color': config.dividerColor
  8. }">
  9. {{modelValue || config.defaultValue}}
  10. </div>
  11. </template>
  12. <script>
  13. import { computed } from 'vue'
  14. import { formInputProps } from '../../form-input-props'
  15. import { useFormInput } from '@cip/components/hooks/form-input'
  16. export default {
  17. props: formInputProps,
  18. setup (props, context) {
  19. const formInput = useFormInput(props, context)
  20. const contentPosition = computed(() => {
  21. return props.config?.contentPosition ?? 'center'
  22. })
  23. const dividerClass = computed(() => {
  24. if (contentPosition.value === 'left') return 'divider-left'
  25. if (contentPosition.value === 'right') return 'divider-right'
  26. return ''
  27. })
  28. return {
  29. ...formInput,
  30. contentPosition: contentPosition.value,
  31. dividerClass: dividerClass.value
  32. }
  33. }
  34. }
  35. </script>
  36. <style lang="less">
  37. .cip-divider{
  38. display: flex;
  39. align-items: center;
  40. border-style: solid;
  41. border-width: 0;
  42. border-color: #ebedf0;
  43. color: #969799;
  44. margin: 16px 0;
  45. font-size: 14px;
  46. line-height: 24px;
  47. &::before, &::after{
  48. display: block;
  49. flex: 1;
  50. box-sizing: border-box;
  51. height: 1px;
  52. border-color: inherit;
  53. border-style: inherit;
  54. border-width: var(--van-border-width-base) 0 0;
  55. transform: scaleY(.5);
  56. content: "";
  57. }
  58. &::before{
  59. margin-right: 16px;
  60. }
  61. &::after{
  62. margin-left: 16px;
  63. }
  64. &.divider-left::before{
  65. max-width: 10%;
  66. }
  67. &.divider-right::after{
  68. max-width: 10%;
  69. }
  70. }
  71. </style>