Skip to content

Commit

Permalink
refactor(VSheet): add useRender and split props into factory
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed Feb 16, 2023
1 parent f00ee78 commit 2705883
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions packages/vuetify/src/components/VSheet/VSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,30 @@ import { makeThemeProps, provideTheme } from '@/composables/theme'
import { useBackgroundColor } from '@/composables/color'

// Utilities
import { genericComponent, pick, propsFactory, useRender } from '@/util'
import { toRef } from 'vue'
import { genericComponent } from '@/util'

// Types
import type { ExtractPropTypes } from 'vue'

export const makeVSheetProps = propsFactory({
color: String,

...makeBorderProps(),
...makeDimensionProps(),
...makeElevationProps(),
...makeLocationProps(),
...makePositionProps(),
...makeRoundedProps(),
...makeTagProps(),
...makeThemeProps(),
}, 'v-sheet')

export const VSheet = genericComponent()({
name: 'VSheet',

props: {
color: String,

...makeBorderProps(),
...makeDimensionProps(),
...makeElevationProps(),
...makeLocationProps(),
...makePositionProps(),
...makeRoundedProps(),
...makeTagProps(),
...makeThemeProps(),
...makeVSheetProps(),
},

setup (props, { slots }) {
Expand All @@ -42,7 +49,7 @@ export const VSheet = genericComponent()({
const { positionClasses } = usePosition(props)
const { roundedClasses } = useRounded(props)

return () => (
useRender(() => (
<props.tag
class={[
'v-sheet',
Expand All @@ -60,8 +67,14 @@ export const VSheet = genericComponent()({
]}
v-slots={ slots }
/>
)
))

return {}
},
})

export type VSheet = InstanceType<typeof VSheet>

export function filterSheetProps (props: ExtractPropTypes<ReturnType<typeof makeVSheetProps>>) {
return pick(props, Object.keys(VSheet?.props ?? {}) as any)
}

0 comments on commit 2705883

Please sign in to comment.