1
- import { GlButton , GlTableLite } from '@gitlab/ui' ;
1
+ import { GlButton , GlTableLite , GlKeysetPagination } from '@gitlab/ui' ;
2
2
import CrudComponent from './crud_component.vue' ;
3
3
4
4
export default {
@@ -44,6 +44,50 @@ const Template = (args, { argTypes }) => ({
44
44
` ,
45
45
} ) ;
46
46
47
+ const TableTemplate = ( args , { argTypes } ) => ( {
48
+ components : { CrudComponent, GlButton, GlTableLite } ,
49
+ props : Object . keys ( argTypes ) ,
50
+ template : `
51
+ <crud-component v-bind="$props" ref="crudComponent">
52
+ <gl-table-lite
53
+ :items="tableItems"
54
+ :fields="tableFields" />
55
+
56
+ <template #form>
57
+ <p>Add form</p>
58
+ <div class="gl-flex gl-gap-3">
59
+ <gl-button variant="confirm">Add item</gl-button>
60
+ <gl-button @click="$refs.crudComponent.hideForm">Cancel</gl-button>
61
+ </div>
62
+ </template>
63
+ </crud-component>
64
+ ` ,
65
+ } ) ;
66
+
67
+ const ContentListTemplate = ( args , { argTypes } ) => ( {
68
+ components : { CrudComponent, GlButton, GlKeysetPagination } ,
69
+ props : Object . keys ( argTypes ) ,
70
+ template : `
71
+ <crud-component v-bind="$props" ref="crudComponent">
72
+ <ul class="content-list">
73
+ <li v-for="item in items">{{ item.label }}</li>
74
+ </ul>
75
+
76
+ <template #form>
77
+ <p>Add form</p>
78
+ <div class="gl-flex gl-gap-3">
79
+ <gl-button variant="confirm">Add item</gl-button>
80
+ <gl-button @click="$refs.crudComponent.hideForm">Cancel</gl-button>
81
+ </div>
82
+ </template>
83
+
84
+ <template v-if="pagination" #pagination>
85
+ <gl-keyset-pagination v-bind="paginationProps" />
86
+ </template>
87
+ </crud-component>
88
+ ` ,
89
+ } ) ;
90
+
47
91
const defaultArgs = {
48
92
descriptionEnabled : false ,
49
93
customActions : false ,
@@ -83,7 +127,7 @@ WithFooter.args = {
83
127
isEmpty : false ,
84
128
} ;
85
129
86
- export const WithPagnation = Template . bind ( { } ) ;
130
+ export const WithPagnation = ContentListTemplate . bind ( { } ) ;
87
131
WithPagnation . args = {
88
132
...defaultArgs ,
89
133
title : 'CRUD Component title' ,
@@ -92,7 +136,22 @@ WithPagnation.args = {
92
136
count : 99 ,
93
137
toggleText : 'Add action' ,
94
138
pagination : true ,
139
+ paginationProps : { hasPreviousPage : false , hasNextPage : true } ,
95
140
isEmpty : false ,
141
+ items : [
142
+ {
143
+ label : 'First item' ,
144
+ } ,
145
+ {
146
+ label : 'Second item' ,
147
+ } ,
148
+ {
149
+ label : 'Third item' ,
150
+ } ,
151
+ {
152
+ label : 'Fourth item' ,
153
+ } ,
154
+ ] ,
96
155
} ;
97
156
98
157
export const WithCustomActions = Template . bind ( { } ) ;
@@ -138,46 +197,6 @@ isCollapsible.args = {
138
197
isEmpty : false ,
139
198
} ;
140
199
141
- const TableTemplate = ( args , { argTypes } ) => ( {
142
- components : { CrudComponent, GlButton, GlTableLite } ,
143
- props : Object . keys ( argTypes ) ,
144
- template : `
145
- <crud-component v-bind="$props" ref="crudComponent">
146
- <gl-table-lite
147
- :items="tableItems"
148
- :fields="tableFields" />
149
-
150
- <template #form>
151
- <p>Add form</p>
152
- <div class="gl-flex gl-gap-3">
153
- <gl-button variant="confirm">Add item</gl-button>
154
- <gl-button @click="$refs.crudComponent.hideForm">Cancel</gl-button>
155
- </div>
156
- </template>
157
- </crud-component>
158
- ` ,
159
- } ) ;
160
-
161
- const ContentListTemplate = ( args , { argTypes } ) => ( {
162
- components : { CrudComponent, GlButton } ,
163
- props : Object . keys ( argTypes ) ,
164
- template : `
165
- <crud-component v-bind="$props" ref="crudComponent">
166
- <ul class="content-list">
167
- <li v-for="item in items">{{ item.label }}</li>
168
- </ul>
169
-
170
- <template #form>
171
- <p>Add form</p>
172
- <div class="gl-flex gl-gap-3">
173
- <gl-button variant="confirm">Add item</gl-button>
174
- <gl-button @click="$refs.crudComponent.hideForm">Cancel</gl-button>
175
- </div>
176
- </template>
177
- </crud-component>
178
- ` ,
179
- } ) ;
180
-
181
200
export const TableExample = TableTemplate . bind ( { } ) ;
182
201
TableExample . args = {
183
202
title : 'Hooks' ,
0 commit comments