Skip to content

Commit

Permalink
refactor(VDivider): remove border and dimension composables
Browse files Browse the repository at this point in the history
replace with 2 new properties, length and thickness
  • Loading branch information
johnleider committed Jan 26, 2021
1 parent e70ba18 commit 78f6fec
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions packages/vuetify/src/components/VDivider/VDivider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,48 @@
import './VDivider.sass'

// Utilities
import { defineComponent, h } from 'vue'
import { computed, defineComponent, h } from 'vue'
import { convertToUnit } from '@/util/helpers'
import makeProps from '@/util/makeProps'

// Composables
import {
makeBorderProps,
makeDimensionProps,
useBorder,
useDimension,
useTheme,
} from '@/composables'
import { useTheme } from '@/composables'

// Types
type DividerKey = 'maxHeight' | 'maxWidth' | 'minHeight' | 'minWidth'
type DividerStyles = Partial<Record<DividerKey, string>>

export default defineComponent({
name: 'VDivider',

props: {
...makeBorderProps(),
...makeDimensionProps({
height: undefined,
maxHeight: undefined,
maxWidth: undefined,
width: undefined,
}),
...makeProps({
inset: Boolean,
length: [Number, String],
thickness: [Number, String],
vertical: Boolean,
}),
},

setup (props, { attrs }) {
const { borderClasses } = useBorder(props)
const { dimensionStyles } = useDimension(props)
const { themeClasses } = useTheme()
const dividerStyles = computed(() => {
const styles: DividerStyles = {}

if (props.length) {
const length = convertToUnit(props.length)

styles[props.vertical ? 'maxHeight' : 'maxWidth'] = length
}

if (props.thickness) {
const length = convertToUnit(props.thickness)

styles[props.vertical ? 'minWidth' : 'minHeight'] = length
}

return styles
})

return () => (
h('hr', {
Expand All @@ -45,9 +54,10 @@ export default defineComponent({
'v-divider--vertical': props.vertical,
},
themeClasses.value,
borderClasses.value,
],
style: [dimensionStyles.value],
style: [
dividerStyles.value,
],
ariaOrientation: !attrs.role || attrs.role === 'separator'
? props.vertical ? 'vertical' : 'horizontal'
: undefined,
Expand Down

0 comments on commit 78f6fec

Please sign in to comment.