Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 3ad11bc

Browse files
authored
fix(card): bring back prop primaryAction (#319)
1 parent 2d1cb41 commit 3ad11bc

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

components/card/Card.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
:class="classes"
44
class="mdc-card"
55
>
6-
<slot />
6+
<div
7+
v-if="primaryAction"
8+
class="mdc-card__primary-action"
9+
tabindex="0"
10+
v-on="$listeners"
11+
>
12+
<slot />
13+
</div>
14+
<slot v-else />
715
<div
816
v-if="$slots['actionButtons'] || $slots['actionIcons'] || $slots['fullBleedButton']"
917
:class="actionClasses"
@@ -42,6 +50,10 @@ export default {
4250
fullBleedAction: {
4351
type: Boolean,
4452
default: false
53+
},
54+
primaryAction: {
55+
type: Boolean,
56+
default: false
4557
}
4658
},
4759
data () {
@@ -59,9 +71,6 @@ export default {
5971
return {
6072
'mdc-card__actions--full-bleed': this.fullBleedAction
6173
}
62-
},
63-
primaryAction () {
64-
return this.$slots.actionableContent != null
6574
}
6675
},
6776
mounted () {

components/card/__test__/Card.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ describe('Card', () => {
105105
expect(w.classes()).toContain('mdc-card__action--icon')
106106
})
107107
})
108+
109+
it('should render with primary action', () => {
110+
let wrapper = mount(Card, {
111+
slots: {
112+
default: [CardMedia]
113+
},
114+
propsData: {
115+
primaryAction: true
116+
}
117+
})
118+
expect(wrapper).toMatchSnapshot()
119+
120+
let primaryAction = wrapper.find('.mdc-card__primary-action')
121+
expect(primaryAction.exists()).toBe(true)
122+
expect(primaryAction.find('.mdc-card__media').exists()).toBe(true)
123+
})
108124
})
109125

110126
describe('CardPrimaryAction', () => {

components/card/__test__/__snapshots__/Card.spec.js.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,15 @@ exports[`Card should render with no prop 1`] = `
6767
</div>
6868
`;
6969

70+
exports[`Card should render with primary action 1`] = `
71+
<div class="mdc-card">
72+
<div tabindex="0" class="mdc-card__primary-action">
73+
<div class="mdc-card__media mdc-card__media--square">
74+
<div class="mdc-card__media-content"></div>
75+
</div>
76+
</div>
77+
<!---->
78+
</div>
79+
`;
80+
7081
exports[`CardPrimaryAction should render with no prop 1`] = `<div tabindex="0" class="mdc-card__primary-action"></div>`;

0 commit comments

Comments
 (0)