diff --git a/.github/contributing/component-structure.md b/.github/contributing/component-structure.md index e5451d235c..2d6dab71a3 100644 --- a/.github/contributing/component-structure.md +++ b/.github/contributing/component-structure.md @@ -50,25 +50,27 @@ export interface ComponentNameSlots { import { computed } from 'vue' import { Primitive } from 'reka-ui' import { useAppConfig } from '#imports' -import { useComponentUI } from '../composables/useComponentUI' +import { useComponentProps } from '../composables/useComponentProps' import { tv } from '../utils/tv' -// 7. Props with withDefaults for runtime defaults -const props = withDefaults(defineProps(), { - as: 'div' -}) +// 7. Raw props (use withDefaults only when you actually need a runtime default) +const _props = defineProps() const slots = defineSlots() -// 8. App config -const appConfig = useAppConfig() as ComponentName['AppConfig'] +// 8. Theme-aware proxy: resolves explicit > > withDefaults +// > app.config.ui..defaultVariants. The `ui` prop is deep-merged +// automatically, so reach for `props.ui?.` in the template. +// `theme.defaultVariants` is NOT in this chain — it only feeds `tv()` +// class resolution. +const props = useComponentProps('componentName', _props) -// 9. Theme-aware ui prop - merges Theme context with component ui prop -const uiProp = useComponentUI('componentName', props) +// 9. App config +const appConfig = useAppConfig() as ComponentName['AppConfig'] // 10. Computed UI - always computed for reactivity -const ui = computed(() => tv({ - extend: tv(theme), - ...(appConfig.ui?.componentName || {}) +const ui = computed(() => tv({ + extend: tv(theme), + ...(appConfig.ui?.componentName || {}) })({ color: props.color, size: props.size @@ -76,8 +78,8 @@ const ui = computed(() => tv({ @@ -113,34 +115,40 @@ export interface CollapsibleSlots {