diff options
| author | taehoon <th.dev91@gmail.com> | 2019-02-14 03:16:37 -0500 |
|---|---|---|
| committer | taehoon <th.dev91@gmail.com> | 2019-02-20 13:30:31 -0500 |
| commit | a5162bd636880f53a8a47fbd547971f2aaead381 (patch) | |
| tree | a6c3fb688d1742edd68d3e3006f782388c81040b /src/hocs/with_list/with_list.js | |
| parent | b4a5b5203f9c6b35feaf2918baa1da6e344ae3c1 (diff) | |
Add note for empty state to the lists using slot
Diffstat (limited to 'src/hocs/with_list/with_list.js')
| -rw-r--r-- | src/hocs/with_list/with_list.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/hocs/with_list/with_list.js b/src/hocs/with_list/with_list.js index e5770cee..896f8fc8 100644 --- a/src/hocs/with_list/with_list.js +++ b/src/hocs/with_list/with_list.js @@ -1,5 +1,7 @@ import Vue from 'vue' import map from 'lodash/map' +import isEmpty from 'lodash/isEmpty' +import './with_list.scss' const defaultEntryPropsGetter = entry => ({ entry }) const defaultKeyGetter = entry => entry.id @@ -9,6 +11,11 @@ const withList = ({ getKey = defaultKeyGetter // funciton to accept entry and index values and return key prop value }) => (ItemComponent) => ( Vue.component('withList', { + props: [ + 'entries', // array of entry + 'entryProps', // additional props to be passed into each entry + 'entryListeners' // additional event listeners to be passed into each entry + ], render (createElement) { return ( <div class="with-list"> @@ -23,10 +30,10 @@ const withList = ({ } return <ItemComponent {...props} /> })} + {isEmpty(this.entries) && this.$slots.empty && <div class="with-list-empty-content faint">{this.$slots.empty}</div>} </div> ) - }, - props: ['entries', 'entryProps', 'entryListeners'] + } }) ) |
