-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chips): Add 'mdc-chip-set' and 'mdc-chip'
- Loading branch information
Showing
14 changed files
with
284 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## Usage | ||
|
||
```html | ||
<mdc-chip-set> | ||
<mdc-chip>Chip content 1</mdc-chip> | ||
<mdc-chip>Chip content 2</mdc-chip> | ||
<mdc-chip>Chip content 3</mdc-chip> | ||
</mdc-chip-set> | ||
``` | ||
|
||
### props | ||
|
||
#### mdc-chip | ||
|
||
mdc-chip is a compact element that allows a user to enter information or select a choice. mdc-chip dispatches | ||
`@MDCChip:interaction` event. | ||
|
||
| prop | Type | Default | Description | | ||
| -------------- | ------- | -------- | ------------------------------------------- | | ||
| `event` | String | optional | optional event to emit on click | | ||
| `event-target` | Object | vm.$root | optional event target, defaults to root bus | | ||
| `event-args` | Array | [] | optional event args | | ||
| `icon` | String | optional | optional leading or trailing icon | | ||
| `trailing` | Boolean | false | if true icon is a trailing icon | | ||
|
||
> emits `@MDCChip:interaction` event with the chip as parameter | ||
### Chips with icons | ||
|
||
```html | ||
<mdc-chip-set> | ||
<mdc-chip icon="save">Chip content 1</mdc-chip> | ||
<mdc-chip icon="delete" trailing>Chip content 2</mdc-chip> | ||
<mdc-chip>Chip content 3</mdc-chip> | ||
</mdc-chip-set> | ||
``` | ||
|
||
### reference | ||
|
||
* <https://material.io/components/web/catalog/chips> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<template> | ||
<div class="mdc-demo mdc-demo--container"> | ||
<mdc-chip-set> | ||
<mdc-chip>Chip content 1</mdc-chip> | ||
<mdc-chip>Chip content 2</mdc-chip> | ||
<mdc-chip>Chip content 3</mdc-chip> | ||
</mdc-chip-set> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import './styles.scss' | ||
import {autoInit} from '../base' | ||
import plugin from './index.js' | ||
export default plugin | ||
|
||
autoInit(plugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {BasePlugin} from '../base' | ||
import mdcChip from './mdc-chip.vue' | ||
import mdcChipSet from './mdc-chip-set.vue' | ||
|
||
export { | ||
mdcChip, | ||
mdcChipSet | ||
} | ||
|
||
export default BasePlugin({ | ||
mdcChip, | ||
mdcChipSet | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<template> | ||
<div ref="root" class="mdc-chip-set" :class="classes"> | ||
<slot></slot> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import MDCChipSetFoundation from '@material/chips/chip-set/foundation'; | ||
export default { | ||
name: 'mdc-chip-set', | ||
props: {}, | ||
data() { | ||
return { | ||
classes: {}, | ||
}; | ||
}, | ||
methods: {}, | ||
mounted() { | ||
this.foundation = new MDCChipSetFoundation({ | ||
hasClass: className => this.$refs.root.classList.contains(className), | ||
}); | ||
this.foundation.init(); | ||
}, | ||
beforeDestroy() { | ||
this.foundation.destroy(); | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<div class="mdc-chip" :class="classes" :style="styles" tabindex="0" @click="dispatchEvent"> | ||
<div classes="mdc-chip__text"> | ||
<i class="material-icons mdc-chip__icon mdc-chip__icon--leading" v-if="icon && !trailing">{{icon}}</i> | ||
<slot></slot> | ||
<i class="material-icons mdc-chip__icon mdc-chip__icon--trailing" tabindex="0" role="button" v-if="icon && trailing">{{icon}}</i> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import MDCChipFoundation from '@material/chips/chip/foundation'; | ||
import { CustomLinkMixin, DispatchEventMixin, emitCustomEvent } from '../base'; | ||
import { RippleBase } from '../ripple'; | ||
export default { | ||
name: 'mdc-chip', | ||
mixins: [CustomLinkMixin, DispatchEventMixin], | ||
props: { | ||
icon: [String], | ||
trailing: Boolean, | ||
}, | ||
data() { | ||
return { | ||
classes: {}, | ||
styles: {}, | ||
}; | ||
}, | ||
methods: {}, | ||
mounted() { | ||
this.foundation = new MDCChipFoundation({ | ||
registerInteractionHandler: (type, handler) => this.$el.addEventListener(type, handler), | ||
deregisterInteractionHandler: (type, handler) => this.$el.removeEventListener(type, handler), | ||
notifyInteraction: () => | ||
emitCustomEvent(this.$el, MDCChipFoundation.strings.INTERACTION_EVENT, { chip: this }, true), | ||
}); | ||
this.foundation.init(); | ||
this.ripple = new RippleBase(this); | ||
this.ripple.init(); | ||
}, | ||
beforeDestroy() { | ||
this.ripple.destroy(); | ||
this.foundation.destroy(); | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import '@material/chips/mdc-chips'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { pluginSanityCheck } from '../unit-test' | ||
import plugin from './index.js'; | ||
|
||
pluginSanityCheck(__dirname, plugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
@import "./button/styles"; | ||
@import "./card/styles"; | ||
@import "./checkbox/styles"; | ||
@import "./dialog/styles"; | ||
@import "./drawer/styles"; | ||
@import "./elevation/styles"; | ||
@import "./fab/styles"; | ||
@import "./grid-list/styles"; | ||
@import "./icon/styles"; | ||
@import "./icon-toggle/styles"; | ||
@import "./layout-app/styles"; | ||
@import "./layout-grid/styles"; | ||
@import "./linear-progress/styles"; | ||
@import "./list/styles"; | ||
@import "./menu/styles"; | ||
@import "./radio/styles"; | ||
@import "./ripple/styles"; | ||
@import "./select/styles"; | ||
@import "./slider/styles"; | ||
@import "./snackbar/styles"; | ||
@import "./switch/styles"; | ||
@import "./tabs/styles"; | ||
@import "./textfield/styles"; | ||
@import "./toolbar/styles"; | ||
@import "./theme/styles"; | ||
@import "./typography/styles"; | ||
@import './button/styles'; | ||
@import './card/styles'; | ||
@import './checkbox/styles'; | ||
@import './chips/styles'; | ||
@import './dialog/styles'; | ||
@import './drawer/styles'; | ||
@import './elevation/styles'; | ||
@import './fab/styles'; | ||
@import './grid-list/styles'; | ||
@import './icon/styles'; | ||
@import './icon-toggle/styles'; | ||
@import './layout-app/styles'; | ||
@import './layout-grid/styles'; | ||
@import './linear-progress/styles'; | ||
@import './list/styles'; | ||
@import './menu/styles'; | ||
@import './radio/styles'; | ||
@import './ripple/styles'; | ||
@import './select/styles'; | ||
@import './slider/styles'; | ||
@import './snackbar/styles'; | ||
@import './switch/styles'; | ||
@import './tabs/styles'; | ||
@import './textfield/styles'; | ||
@import './toolbar/styles'; | ||
@import './theme/styles'; | ||
@import './typography/styles'; |
Oops, something went wrong.