Skip to content

Commit

Permalink
refactor(VBanner): tuning pass (#15109)
Browse files Browse the repository at this point in the history
* refactor(VBanner): tuning pass

* refactor(VBanner): remove append slot & remove align-items css
  • Loading branch information
johnleider committed Jun 21, 2022
1 parent d30f489 commit 61ae05d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 76 deletions.
13 changes: 6 additions & 7 deletions packages/vuetify/src/components/VBanner/VBanner.sass
Expand Up @@ -3,11 +3,10 @@
@use './variables' as *

.v-banner
align-items: center
display: grid
flex: 1 1
font-size: $banner-font-size
grid-template-areas: "prepend text actions"
grid-template-areas: "prepend content actions"
grid-template-columns: max-content auto max-content
grid-template-rows: max-content max-content
line-height: $banner-line-height
Expand All @@ -30,7 +29,7 @@

&--stacked
&:not(.v-banner--one-line)
grid-template-areas: "prepend text" ". actions"
grid-template-areas: "prepend content" ". actions"

.v-banner-text
padding-inline-end: $banner-stacked-padding-inline-end
Expand Down Expand Up @@ -68,8 +67,9 @@
&--sticky
top: $banner-sticky-top

.v-banner-avatar,
.v-banner-icon,
.v-banner__content
grid-area: content

.v-banner__prepend
align-self: flex-start
grid-area: prepend
Expand All @@ -89,9 +89,8 @@
.v-banner-text
-webkit-box-orient: vertical
display: -webkit-box
grid-area: text
overflow: hidden
padding-inline-end: $banner-text-padding-end
overflow: hidden

.v-banner--one-line &
-webkit-line-clamp: 1
Expand Down
53 changes: 28 additions & 25 deletions packages/vuetify/src/components/VBanner/VBanner.tsx
Expand Up @@ -2,10 +2,10 @@
import './VBanner.sass'

// Components
import { VAvatar } from '@/components/VAvatar'
import { VBannerActions } from './VBannerActions'
import { VBannerAvatar } from './VBannerAvatar'
import { VBannerIcon } from './VBannerIcon'
import { VBannerText } from './VBannerText'
import { VDefaultsProvider } from '@/components/VDefaultsProvider'

// Composables
import { makeBorderProps, useBorder } from '@/composables/border'
Expand Down Expand Up @@ -66,11 +66,7 @@ export const VBanner = defineComponent({
const color = toRef(props, 'color')
const density = toRef(props, 'density')

provideDefaults({
VBannerActions: { color, density },
VBannerAvatar: { density, image: toRef(props, 'avatar') },
VBannerIcon: { color, density, icon: toRef(props, 'icon') },
})
provideDefaults({ VBannerActions: { color, density } })

useRender(() => {
const hasText = !!(props.text || slots.text)
Expand Down Expand Up @@ -99,27 +95,34 @@ export const VBanner = defineComponent({
role="banner"
>
{ hasPrepend && (
<>
{ slots.prepend
? (
<div class="v-banner__prepend">
{ slots.prepend() }
</div>
)
: props.avatar ? (<VBannerAvatar />)
: props.icon ? (<VBannerIcon />)
: undefined
}
</>
<VDefaultsProvider
defaults={{
VAvatar: {
color: color.value,
density: density.value,
icon: props.icon,
image: props.avatar,
},
}}
>
<div class="v-banner__prepend">
{ slots.prepend
? slots.prepend()
: (props.avatar || props.icon) && (<VAvatar />)
}
</div>
</VDefaultsProvider>
) }

{ hasText && (
<VBannerText>
{ slots.text ? slots.text() : props.text }
</VBannerText>
) }
<div class="v-banner__content">
{ hasText && (
<VBannerText>
{ slots.text ? slots.text() : props.text }
</VBannerText>
) }

{ slots.default?.() }
{ slots.default?.() }
</div>

{ slots.actions && (
<VBannerActions>
Expand Down
21 changes: 0 additions & 21 deletions packages/vuetify/src/components/VBanner/VBannerAvatar.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions packages/vuetify/src/components/VBanner/VBannerIcon.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions packages/vuetify/src/components/VBanner/index.ts
@@ -1,5 +1,3 @@
export { VBanner } from './VBanner'
export { VBannerActions } from './VBannerActions'
export { VBannerAvatar } from './VBannerAvatar'
export { VBannerIcon } from './VBannerIcon'
export { VBannerText } from './VBannerText'

0 comments on commit 61ae05d

Please sign in to comment.