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

Commit

Permalink
feat: Add mdc-theme classes mixin (close #67)
Browse files Browse the repository at this point in the history
  • Loading branch information
matsp committed Mar 14, 2018
1 parent 12ff5d0 commit 79dc321
Show file tree
Hide file tree
Showing 57 changed files with 243 additions and 5 deletions.
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,26 @@ Vue.use(Card)

## theming

#### SASS
### MDC classes

For simple color modifications of components e.g. changing the background color from primary to secondary color it is
possible to use the `theming` prop on each component to set one of the mdc-theme CSS classes.
You don't need to set the full name of the css class just the last part (see example). For a complete list of available
CSS classes have a look [here](https://github.com/material-components/material-components-web/tree/master/packages/mdc-theme#css-classes).

```html
<m-button theming="secondary-bg">
Secondary-Button
</m-button>
```

```html
<style lang="scss">
@import "material-components-vue/dist/theme/styles";
</style>
```

### SASS

Import all SASS files for the imported components and override with SASS variables:

Expand All @@ -109,9 +128,9 @@ Import all SASS files for the imported components and override with SASS variabl
$mdc-theme-primary: #2196f3;
$mdc-theme-secondary: #ff1744;
$mdc-theme-background: #f5f5f5;
@import "~material-components-vue/dist/theme/styles";
@import "~material-components-vue/dist/button/styles";
@import "~material-components-vue/dist/card/styles";
@import "material-components-vue/dist/theme/styles";
@import "material-components-vue/dist/button/styles";
@import "material-components-vue/dist/card/styles";
@import url('https://cdnjs.com/libraries/normalize');
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
Expand All @@ -121,7 +140,7 @@ Import all SASS files for the imported components and override with SASS variabl
Don't forget to include the `@material` directory of your `node_modules` in your sass-loader options.
Otherwise the components won't compile sucessfully.

#### CSS custom properties
### CSS custom properties

Integrate a theme component in your template and pass in an object with CSS custom properties, but keep browser compatibilty in mind.

Expand Down
2 changes: 2 additions & 0 deletions components/button/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

<script>
import { MDCRipple } from '@material/ripple'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
raised: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/card/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
stroked: {
type: Boolean,
Expand Down
2 changes: 2 additions & 0 deletions components/card/CardMedia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
square: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/checkbox/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

<script>
import { MDCCheckbox } from '@material/checkbox'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
model: {
prop: 'checked',
event: 'change'
Expand Down
3 changes: 3 additions & 0 deletions components/chips/Chip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
<script>
import { MDCChip } from '@material/chips'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
data () {
return {
mdcChip: null
Expand Down
3 changes: 3 additions & 0 deletions components/chips/ChipSet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<script>
import { MDCChipSet } from '@material/chips'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
choice: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/dialog/Dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
<script>
import { MDCDialog } from '@material/dialog'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
scrollable: {
type: Boolean,
Expand Down
9 changes: 9 additions & 0 deletions components/drawer/DrawerContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@
<slot />
</nav>
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin]
}
</script>

8 changes: 8 additions & 0 deletions components/drawer/DrawerHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@
</div>
</header>
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin]
}
</script>
8 changes: 8 additions & 0 deletions components/drawer/DrawerPermanent/DrawerPermanent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@
<slot />
</nav>
</template>

<script>
import themeClassMixin from '../../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin]
}
</script>
3 changes: 3 additions & 0 deletions components/drawer/DrawerPersistent/DrawerPersistent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
<script>
import { MDCPersistentDrawer } from '@material/drawer'
import themeClassMixin from '../../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
initialOpen: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/drawer/DrawerTemporary/DrawerTemporary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
<script>
import { MDCTemporaryDrawer } from '@material/drawer'
import themeClassMixin from '../../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
initialOpen: {
type: Boolean,
Expand Down
8 changes: 8 additions & 0 deletions components/drawer/DrawerToolbarSpacer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
<slot/>
</div>
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin]
}
</script>
3 changes: 3 additions & 0 deletions components/elevation/Elevation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
level: {
type: Number,
Expand Down
4 changes: 4 additions & 0 deletions components/fab/Fab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

<script>
import { MDCRipple } from '@material/ripple'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
mini: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/floating-label/FloatingLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<script>
import { MDCFloatingLabel } from '@material/floating-label'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
floatAbove: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/form-field/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<script>
import { MDCFormField } from '@material/form-field'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
alignEnd: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/grid-list/GridList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import { MDCGridList } from '@material/grid-list'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
headerCaption: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/grid-list/GridListTile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
imgSrc: {
type: String,
Expand Down
3 changes: 3 additions & 0 deletions components/icon-toggle/IconToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
import { MDCIconToggle } from '@material/icon-toggle'
import { debounce } from '../'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
iconOn: {
type: String,
Expand Down
3 changes: 3 additions & 0 deletions components/icon/Icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
icon: {
type: String,
Expand Down
3 changes: 3 additions & 0 deletions components/layout-grid/LayoutGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
fixedColumnWidth: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/layout-grid/LayoutGridCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
span: {
type: Number,
Expand Down
8 changes: 8 additions & 0 deletions components/layout-grid/LayoutGridInner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
<slot />
</div>
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin]
}
</script>
3 changes: 3 additions & 0 deletions components/line-ripple/LineRipple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<script>
import { MDCLineRipple } from '@material/line-ripple'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
data () {
return {
mdcLineRipple: null
Expand Down
3 changes: 3 additions & 0 deletions components/linear-progress/LinearProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
<script>
import { MDCLinearProgress } from '@material/linear-progress'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
open: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/list/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
avatar: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions components/list/ListDivider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin],
props: {
inset: {
type: Boolean,
Expand Down
8 changes: 8 additions & 0 deletions components/list/ListGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
<slot />
</div>
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin]
}
</script>
8 changes: 8 additions & 0 deletions components/list/ListGroupDivider.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<template>
<hr class="mdc-list-divider" >
</template>

<script>
import themeClassMixin from '../base/themeClassMixin.js'
export default {
mixins: [themeClassMixin]
}
</script>
Loading

0 comments on commit 79dc321

Please sign in to comment.