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

Commit

Permalink
fix(card): bring back prop primaryAction (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
tychenjiajun committed Jul 1, 2019
1 parent 2d1cb41 commit 3ad11bc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
17 changes: 13 additions & 4 deletions components/card/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
:class="classes"
class="mdc-card"
>
<slot />
<div
v-if="primaryAction"
class="mdc-card__primary-action"
tabindex="0"
v-on="$listeners"
>
<slot />
</div>
<slot v-else />
<div
v-if="$slots['actionButtons'] || $slots['actionIcons'] || $slots['fullBleedButton']"
:class="actionClasses"
Expand Down Expand Up @@ -42,6 +50,10 @@ export default {
fullBleedAction: {
type: Boolean,
default: false
},
primaryAction: {
type: Boolean,
default: false
}
},
data () {
Expand All @@ -59,9 +71,6 @@ export default {
return {
'mdc-card__actions--full-bleed': this.fullBleedAction
}
},
primaryAction () {
return this.$slots.actionableContent != null
}
},
mounted () {
Expand Down
16 changes: 16 additions & 0 deletions components/card/__test__/Card.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ describe('Card', () => {
expect(w.classes()).toContain('mdc-card__action--icon')
})
})

it('should render with primary action', () => {
let wrapper = mount(Card, {
slots: {
default: [CardMedia]
},
propsData: {
primaryAction: true
}
})
expect(wrapper).toMatchSnapshot()

let primaryAction = wrapper.find('.mdc-card__primary-action')
expect(primaryAction.exists()).toBe(true)
expect(primaryAction.find('.mdc-card__media').exists()).toBe(true)
})
})

describe('CardPrimaryAction', () => {
Expand Down
11 changes: 11 additions & 0 deletions components/card/__test__/__snapshots__/Card.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,15 @@ exports[`Card should render with no prop 1`] = `
</div>
`;

exports[`Card should render with primary action 1`] = `
<div class="mdc-card">
<div tabindex="0" class="mdc-card__primary-action">
<div class="mdc-card__media mdc-card__media--square">
<div class="mdc-card__media-content"></div>
</div>
</div>
<!---->
</div>
`;

exports[`CardPrimaryAction should render with no prop 1`] = `<div tabindex="0" class="mdc-card__primary-action"></div>`;

0 comments on commit 3ad11bc

Please sign in to comment.