Skip to content

Commit d8985b6

Browse files
authored
Added pagination action to Toniq List Table and Toniq Pagination (#134)
1 parent 68f7acb commit d8985b6

File tree

10 files changed

+76
-11
lines changed

10 files changed

+76
-11
lines changed

package-lock.json

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@toniq-labs/design-system-root",
3-
"version": "16.21.0",
3+
"version": "16.21.1",
44
"private": true,
55
"description": "Root design system mono-repo package.",
66
"homepage": "https://github.com/Toniq-Labs/toniq-labs-design-system",

packages/design-system/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@toniq-labs/design-system",
3-
"version": "16.21.0",
3+
"version": "16.21.1",
44
"private": false,
55
"description": "Design system elements for Toniq Labs",
66
"keywords": [

packages/design-system/src/elements/toniq-list-table/toniq-list-table.element.book.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {defineBookPage} from 'element-book';
33
import {CSSResult, HTMLTemplateResult, css, html, listen, unsafeCSS} from 'element-vir';
44
import {noNativeFormStyles} from 'vira';
55
import {elementsBookPage} from '../../element-book/book-pages/elements.book';
6-
import {CryptoBtc24Icon} from '../../icons';
6+
import {CryptoBtc24Icon, Target24Icon} from '../../icons';
77
import {toniqFontStyles} from '../../styles';
88
import {toniqColors} from '../../styles/colors';
99
import {defineToniqElementNoInputs} from '../define-toniq-element';
@@ -1010,6 +1010,22 @@ const examples: ReadonlyArray<
10101010
},
10111011
},
10121012
},
1013+
{
1014+
title: 'with pagination and custom action',
1015+
inputs: {
1016+
pagination: {
1017+
currentPage: 1,
1018+
pageCount: 10,
1019+
},
1020+
paginationAction: html`
1021+
<${ToniqIcon.assign({icon: Target24Icon})}
1022+
${listen('click', () => {
1023+
alert('pagination action');
1024+
})}
1025+
></${ToniqIcon}>
1026+
`,
1027+
},
1028+
},
10131029
{
10141030
title: 'squished horizontally',
10151031
styles: css`

packages/design-system/src/elements/toniq-list-table/toniq-list-table.element.ts

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@augment-vir/common';
99
import {
1010
CSSResult,
11+
HTMLTemplateResult,
1112
HtmlInterpolation,
1213
classMap,
1314
css,
@@ -80,6 +81,7 @@ export type ListTableInputs = {
8081
* in fixed/consistent column sizes in all rows
8182
*/
8283
nonBlocking?: boolean | undefined;
84+
paginationAction?: HTMLTemplateResult | undefined;
8385
};
8486

8587
export type CreateRowObjectCallback<EntryType, Columns extends ColumnsBase> = (
@@ -410,6 +412,7 @@ export const ToniqListTable = defineToniqElement<ListTableInputs>()({
410412
<${ToniqPagination.assign({
411413
currentPage: inputs.pagination.currentPage,
412414
pageCount: inputs.pagination.pageCount,
415+
paginationAction: inputs.paginationAction,
413416
})}
414417
class=${classMap({
415418
'blocked-pagination': !!inputs.showLoading,

packages/design-system/src/elements/toniq-pagination/toniq-pagination.element.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import {classMap, css, defineElementEvent, html, listen} from 'element-vir';
1+
import {
2+
classMap,
3+
css,
4+
defineElementEvent,
5+
html,
6+
HTMLTemplateResult,
7+
listen,
8+
renderIf,
9+
} from 'element-vir';
210
import {noNativeFormStyles, noUserSelect} from 'vira';
311
import {pagination} from '../../augments/array';
412
import {ArrowLeft24Icon, ArrowRight24Icon} from '../../icons';
@@ -17,6 +25,7 @@ export const ToniqPagination = defineToniqElement<{
1725
* into "...". Instances of "..." are included in the pagesShown count.
1826
*/
1927
pagesShown?: number | undefined;
28+
paginationAction?: HTMLTemplateResult | undefined;
2029
}>()({
2130
tagName: 'toniq-pagination',
2231
styles: css`
@@ -129,6 +138,12 @@ export const ToniqPagination = defineToniqElement<{
129138
>
130139
<${ToniqIcon.assign({icon: ArrowRight24Icon})}></${ToniqIcon}>
131140
</button>
141+
${renderIf(
142+
!!inputs.paginationAction,
143+
html`
144+
<button class="control">${inputs.paginationAction}</button>
145+
`,
146+
)}
132147
`;
133148
}
134149
},

packages/design-system/src/icons/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import {Social24Icon} from './svgs/core-24/social-24.icon';
7777
import {Square24Icon} from './svgs/core-24/square-24.icon';
7878
import {SquareCheck24Icon} from './svgs/core-24/square-check-24.icon';
7979
import {Tag24Icon} from './svgs/core-24/tag-24.icon';
80+
import {Target24Icon} from './svgs/core-24/target-24.icon';
8081
import {Trash24Icon} from './svgs/core-24/trash-24.icon';
8182
import {Upload24Icon} from './svgs/core-24/upload-24.icon';
8283
import {UploadCloud24Icon} from './svgs/core-24/upload-cloud-24.icon';
@@ -209,6 +210,7 @@ export * from './svgs/core-24/social-24.icon';
209210
export * from './svgs/core-24/square-24.icon';
210211
export * from './svgs/core-24/square-check-24.icon';
211212
export * from './svgs/core-24/tag-24.icon';
213+
export * from './svgs/core-24/target-24.icon';
212214
export * from './svgs/core-24/trash-24.icon';
213215
export * from './svgs/core-24/upload-24.icon';
214216
export * from './svgs/core-24/upload-cloud-24.icon';
@@ -347,6 +349,7 @@ export const allIconsByCategory = {
347349
Square24Icon,
348350
SquareCheck24Icon,
349351
Tag24Icon,
352+
Target24Icon,
350353
Trash24Icon,
351354
Upload24Icon,
352355
UploadCloud24Icon,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {html} from 'element-vir';
2+
import {defineIcon} from 'vira';
3+
import {toniqIconCssVars} from '../../../styles/icon-css-vars';
4+
5+
export const Target24Icon = defineIcon({
6+
name: 'Target24Icon',
7+
svgTemplate: html`
8+
<svg
9+
xmlns="http://www.w3.org/2000/svg"
10+
stroke=${toniqIconCssVars['toniq-icon-stroke-color'].value}
11+
fill="none"
12+
stroke-linecap="round"
13+
stroke-linejoin="round"
14+
width="24"
15+
height="24"
16+
viewBox="0 0 24 24"
17+
>
18+
<path
19+
stroke-width=${toniqIconCssVars['toniq-icon-stroke-width'].value}
20+
d="M9 12a3 3 0 1 0 6 0 3 3 0 0 0-6 0"
21+
/>
22+
<path
23+
stroke-width=${toniqIconCssVars['toniq-icon-stroke-width'].value}
24+
d="M4 12a8 8 0 1 0 16 0 8 8 0 0 0-16 0m8-10v2m0 16v2m8-10h2M2 12h2"
25+
/>
26+
</svg>
27+
`,
28+
});

packages/native-elements-test/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@toniq-labs/design-system-native-elements-test",
3-
"version": "16.21.0",
3+
"version": "16.21.1",
44
"private": true,
55
"scripts": {
66
"compile": "virmator compile",

packages/scripts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@toniq-labs/design-system-scripts",
3-
"version": "16.21.0",
3+
"version": "16.21.1",
44
"private": true,
55
"scripts": {
66
"compile": "virmator compile",

0 commit comments

Comments
 (0)