Skip to content

Commit 3d91708

Browse files
committedAug 4, 2017
feat(MdCard): create needed files to start creation of cards
1 parent 682c283 commit 3d91708

File tree

12 files changed

+180
-0
lines changed

12 files changed

+180
-0
lines changed
 

‎docs/app/i18n/en-US.js

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export default {
2828
app: {
2929
title: 'App'
3030
},
31+
card: {
32+
title: 'Card'
33+
},
3134
checkbox: {
3235
title: 'Checkbox'
3336
},
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<example src="./examples/RegularCards.vue" />
2+
<example src="./examples/CardsWithHover.vue" />
3+
4+
<template>
5+
<page-container centered :title="$t('pages.card.title')">
6+
<div class="page-container-section">
7+
<p>The content surfaces that comprise applications are referred to in this spec as material, or sheets of material. The content component is commonly used to resemble a piece of paper. It'll be useful to theme a arbitrary content.</p>
8+
</div>
9+
10+
<div class="page-container-section">
11+
<h2>Card</h2>
12+
13+
<code-example title="Regular Cards" :component="examples['regular-cards']" />
14+
<code-example title="Cards with hover" :component="examples['cards-with-hover']" />
15+
16+
<api-item title="API - md-card">
17+
<p>This component do not have any extra option.</p>
18+
</api-item>
19+
</div>
20+
</page-container>
21+
</template>
22+
23+
<script>
24+
import examples from 'docs-mixins/docsExample'
25+
26+
export default {
27+
name: 'Card',
28+
mixins: [examples],
29+
data: () => ({
30+
31+
})
32+
}
33+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<div>
3+
<md-card md-with-hover>Regular card</md-card>
4+
<md-card md-with-hover class="md-primary">Primary card</md-card>
5+
<md-card md-with-hover class="md-accent">Accent card</md-card>
6+
</div>
7+
</template>
8+
9+
<style lang="scss" scoped>
10+
.md-card {
11+
width: 200px;
12+
padding: 16px;
13+
display: inline-block;
14+
}
15+
</style>
16+
17+
<script>
18+
export default {
19+
name: 'RegularCards'
20+
}
21+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<div>
3+
<md-card>Regular card</md-card>
4+
<md-card class="md-primary">Primary card</md-card>
5+
<md-card class="md-accent">Accent card</md-card>
6+
</div>
7+
</template>
8+
9+
<style lang="scss" scoped>
10+
.md-card {
11+
width: 200px;
12+
padding: 16px;
13+
display: inline-block;
14+
}
15+
</style>
16+
17+
<script>
18+
export default {
19+
name: 'RegularCards'
20+
}
21+
</script>

‎docs/app/routes.js

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export const routes = [
4949
name: 'components/drawer',
5050
component: () => import('./pages/Components/Drawer/Drawer.vue')
5151
},
52+
{
53+
path: '/components/card',
54+
name: 'components/card',
55+
component: () => import('./pages/Components/Card/Card.vue')
56+
},
5257
{
5358
path: '/components/form',
5459
name: 'form',

‎docs/app/template/MainNavContent.vue

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<div class="main-nav-level">
88
<router-link to="/components/app">{{ $t('pages.app.title') }}</router-link>
99
<router-link to="/components/button">{{ $t('pages.button.title') }}</router-link>
10+
<router-link to="/components/card">{{ $t('pages.card.title') }}</router-link>
1011
<router-link to="/components/content">{{ $t('pages.content.title') }}</router-link>
1112
<router-link to="/components/divider">{{ $t('pages.divider.title') }}</router-link>
1213
<router-link to="/components/drawer">{{ $t('pages.drawer.title') }}</router-link>

‎src/components/MdCard/MdCard.test.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import mountTemplate from 'test/utils/mountTemplate'
2+
import MdCard from './MdCard.vue'
3+
4+
test('should render the content', async () => {
5+
const template = '<md-card>Lorem ipsum</md-card>'
6+
const wrapper = await mountTemplate(MdCard, template)
7+
8+
expect(wrapper.hasClass('md-card')).toBe(true)
9+
expect(wrapper.text()).toBe('Lorem ipsum')
10+
})
11+
12+
test('should render the theme class', async () => {
13+
const template = '<md-card md-theme="alt">Lorem ipsum</md-card>'
14+
const wrapper = await mountTemplate(MdCard, template)
15+
16+
expect(wrapper.hasClass('md-theme-alt')).toBe(true)
17+
})

‎src/components/MdCard/MdCard.vue

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<template>
2+
<div class="md-card" :class="[$mdActiveTheme, cardClasses]">
3+
<slot></slot>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import MdComponent from 'core/MdComponent'
9+
10+
export default new MdComponent({
11+
name: 'MdCard',
12+
props: {
13+
mdWithHover: Boolean
14+
},
15+
computed: {
16+
cardClasses () {
17+
return {
18+
'md-with-hover': this.mdWithHover
19+
}
20+
}
21+
}
22+
})
23+
</script>
24+
25+
<style lang="scss">
26+
@import "~components/MdAnimation/variables";
27+
@import "~components/MdElevation/mixins";
28+
29+
$md-card-radius: 2px;
30+
31+
.md-card {
32+
@include md-elevation(2);
33+
overflow: auto;
34+
display: flex;
35+
flex-direction: column;
36+
position: relative;
37+
z-index: 1;
38+
border-radius: $md-card-radius;
39+
transition: .3s $md-transition-default-timing;
40+
transition-property: color, background-color;
41+
will-change: color, background-color;
42+
43+
&.md-with-hover {
44+
cursor: pointer;
45+
transition: .3s $md-transition-stand-timing;
46+
transition-property: background-color, box-shadow;
47+
will-change: background-color, box-shadow;
48+
49+
&:hover {
50+
z-index: 2;
51+
@include md-elevation(8);
52+
}
53+
}
54+
}
55+
</style>

‎src/components/MdCard/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import MdCard from './MdCard'
2+
3+
export default Vue => {
4+
Vue.component(MdCard.name, MdCard)
5+
}

‎src/components/MdCard/theme.scss

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.md-card {
2+
@include md-theme-component() {
3+
@include md-theme-property(background-color, background);
4+
@include md-theme-property(color, text-primary, background);
5+
6+
&.md-primary {
7+
@include md-theme-property(background-color, primary);
8+
@include md-theme-property(color, text-primary, primary);
9+
}
10+
11+
&.md-accent {
12+
@include md-theme-property(background-color, accent);
13+
@include md-theme-property(color, text-primary, accent);
14+
}
15+
}
16+
}

‎src/components/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import MdApp from './MdApp'
22
import MdButton from './MdButton'
3+
import MdCard from './MdCard'
34
import MdCheckbox from './MdCheckbox'
45
import MdContent from './MdContent'
56
import MdDivider from './MdDivider'
@@ -19,6 +20,7 @@ import MdToolbar from './MdToolbar'
1920
export default {
2021
MdApp,
2122
MdButton,
23+
MdCard,
2224
MdCheckbox,
2325
MdContent,
2426
MdDivider,

‎src/theme/all.scss

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import "../base/theme";
22
@import "../components/MdButton/theme";
3+
@import "../components/MdCard/theme";
34
@import "../components/MdCheckbox/theme";
45
@import "../components/MdContent/theme";
56
@import "../components/MdDivider/theme";

0 commit comments

Comments
 (0)