Skip to content

Commit

Permalink
feat(VCardText/Subtitle): add opacity support
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed Apr 16, 2024
1 parent 565a794 commit 8633854
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/api-generator/src/locale/en/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"modelValue": "The v-model value of the component. If component supports the **multiple** prop, this defaults to an empty array.",
"name": "Sets the component's name attribute.",
"noDataText": "Text shown when no items are provided to the component.",
"opacity": "Sets the component's opacity value",
"origin": "Sets the transition origin on the element. You can find more information on the MDN documentation [for transition origin](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin).",
"persistent": "Clicking outside or pressing **esc** key will not dismiss the dialog.",
"persistentCounter": "Forces counter to always be visible.",
Expand Down
1 change: 1 addition & 0 deletions packages/vuetify/src/components/VCard/VCard.sass
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
font-size: $card-text-font-size
font-weight: $card-text-font-weight
letter-spacing: $card-text-letter-spacing
opacity: $card-text-opacity
padding: $card-text-padding
text-transform: $card-text-text-transform

Expand Down
6 changes: 0 additions & 6 deletions packages/vuetify/src/components/VCard/VCardSubtitle.ts

This file was deleted.

39 changes: 39 additions & 0 deletions packages/vuetify/src/components/VCard/VCardSubtitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Composables
import { makeComponentProps } from '@/composables/component'
import { makeTagProps } from '@/composables/tag'

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

export const makeVCardSubtitleProps = propsFactory({
opacity: [Number, String],

...makeComponentProps(),
...makeTagProps(),
}, 'VCardSubtitle')

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

props: makeVCardSubtitleProps(),

setup (props, { slots }) {
useRender(() => (
<props.tag
class={[
'v-card-subtitle',
props.class,
]}
style={[
{ '--v-card-subtitle-opacity': props.opacity },
props.style,
]}
v-slots={ slots }
/>
))

return {}
},
})

export type VCardSubtitle = InstanceType<typeof VCardSubtitle>
6 changes: 0 additions & 6 deletions packages/vuetify/src/components/VCard/VCardText.ts

This file was deleted.

39 changes: 39 additions & 0 deletions packages/vuetify/src/components/VCard/VCardText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Composables
import { makeComponentProps } from '@/composables/component'
import { makeTagProps } from '@/composables/tag'

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

export const makeVCardTextProps = propsFactory({
opacity: [Number, String],

...makeComponentProps(),
...makeTagProps(),
}, 'VCardText')

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

props: makeVCardTextProps(),

setup (props, { slots }) {
useRender(() => (
<props.tag
class={[
'v-card-text',
props.class,
]}
style={[
{ '--v-card-text-opacity': props.opacity },
props.style,
]}
v-slots={ slots }
/>
))

return {}
},
})

export type VCardText = InstanceType<typeof VCardText>
3 changes: 2 additions & 1 deletion packages/vuetify/src/components/VCard/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $card-subtitle-font-weight: tools.map-deep-get(settings.$typography, 'body-2', '
$card-subtitle-header-padding: 0 0 .25rem !default;
$card-subtitle-letter-spacing: tools.map-deep-get(settings.$typography, 'body-2', 'letter-spacing') !default;
$card-subtitle-line-height: tools.map-deep-get(settings.$typography, 'body-2', 'line-height') !default;
$card-subtitle-opacity: var(--v-medium-emphasis-opacity) !default;
$card-subtitle-opacity: var(--v-card-subtitle-opacity, var(--v-medium-emphasis-opacity)) !default;
$card-subtitle-overflow: hidden !default;
$card-subtitle-padding: 0 1rem !default;
$card-subtitle-text-overflow: ellipsis !default;
Expand All @@ -76,6 +76,7 @@ $card-text-compact-line-height: 1.15rem !default;
$card-text-flex: 1 1 auto !default;
$card-text-font-size: tools.map-deep-get(settings.$typography, 'body-2', 'size') !default;
$card-text-font-weight: tools.map-deep-get(settings.$typography, 'body-2', 'weight') !default;
$card-text-opacity: var(--v-card-text-opacity, 1) !default;
$card-text-letter-spacing: tools.map-deep-get(settings.$typography, 'body-2', 'letter-spacing') !default;
$card-text-line-height: tools.map-deep-get(settings.$typography, 'body-2', 'line-height') !default;
$card-text-padding: 1rem !default;
Expand Down

0 comments on commit 8633854

Please sign in to comment.