mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
feat(pagination-nav): add tooltipPosition
prop (#1733)
* Add `tooltipPosition` to `PaginationNav` per #1656 * Rebuild test * Update description in documentation Co-authored-by: Enrico Sacchetti <esacchetti@gmail.com> * chore: update docs --------- Co-authored-by: Samuel Janda <hi@simpleprogramming.com.au> Co-authored-by: Enrico Sacchetti <esacchetti@gmail.com> Co-authored-by: Enrico Sacchetti <enrico@theetrain.ca>
This commit is contained in:
parent
edcb14b3c9
commit
60a796ea48
5 changed files with 50 additions and 11 deletions
|
@ -2696,14 +2696,15 @@ None.
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
|
|
||||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||||
| :----------- | :------- | :--------------- | :------- | -------------------- | ---------------------------- | ----------------------------------------- |
|
| :-------------- | :------- | :--------------- | :------- | ------------------------------------------------------------------------------------------------ | ---------------------------- | ------------------------------------------------------------------- |
|
||||||
| page | No | <code>let</code> | Yes | <code>number</code> | <code>1</code> | Specify the current page index |
|
| page | No | <code>let</code> | Yes | <code>number</code> | <code>1</code> | Specify the current page index |
|
||||||
| total | No | <code>let</code> | No | <code>number</code> | <code>10</code> | Specify the total number of pages |
|
| total | No | <code>let</code> | No | <code>number</code> | <code>10</code> | Specify the total number of pages |
|
||||||
| shown | No | <code>let</code> | No | <code>number</code> | <code>10</code> | Specify the total number of pages to show |
|
| shown | No | <code>let</code> | No | <code>number</code> | <code>10</code> | Specify the total number of pages to show |
|
||||||
| loop | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to loop the navigation |
|
| loop | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to loop the navigation |
|
||||||
| forwardText | No | <code>let</code> | No | <code>string</code> | <code>"Next page"</code> | Specify the forward button text |
|
| forwardText | No | <code>let</code> | No | <code>string</code> | <code>"Next page"</code> | Specify the forward button text |
|
||||||
| backwardText | No | <code>let</code> | No | <code>string</code> | <code>"Previous page"</code> | Specify the backward button text |
|
| backwardText | No | <code>let</code> | No | <code>string</code> | <code>"Previous page"</code> | Specify the backward button text |
|
||||||
|
| tooltipPosition | No | <code>let</code> | No | <code>"top" | "right" | "bottom" | "left" | "outside" | "inside"</code> | <code>"bottom"</code> | Set the position of the tooltip relative to the pagination buttons. |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
|
|
@ -8520,6 +8520,18 @@
|
||||||
"isRequired": false,
|
"isRequired": false,
|
||||||
"constant": false,
|
"constant": false,
|
||||||
"reactive": false
|
"reactive": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tooltipPosition",
|
||||||
|
"kind": "let",
|
||||||
|
"description": "Set the position of the tooltip relative to the pagination buttons.",
|
||||||
|
"type": "\"top\" | \"right\" | \"bottom\" | \"left\" | \"outside\" | \"inside\"",
|
||||||
|
"value": "\"bottom\"",
|
||||||
|
"isFunction": false,
|
||||||
|
"isFunctionDeclaration": false,
|
||||||
|
"isRequired": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"moduleExports": [],
|
"moduleExports": [],
|
||||||
|
|
|
@ -43,3 +43,9 @@ Use the `forwardText` and `backwardText` props to customize the button text.
|
||||||
forwardText="Next"
|
forwardText="Next"
|
||||||
backwardText="Previous"
|
backwardText="Previous"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
## Tooltip Position
|
||||||
|
|
||||||
|
Use the `tooltipPosition` prop to change the alignment of the tooltip.
|
||||||
|
|
||||||
|
<PaginationNav tooltipPosition="outside" total={3} loop />
|
|
@ -23,6 +23,12 @@
|
||||||
/** Specify the backward button text */
|
/** Specify the backward button text */
|
||||||
export let backwardText = "Previous page";
|
export let backwardText = "Previous page";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the position of the tooltip relative to the pagination buttons.
|
||||||
|
* @type {"top" | "right" | "bottom" | "left" | "outside" | "inside"}
|
||||||
|
*/
|
||||||
|
export let tooltipPosition = "bottom";
|
||||||
|
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher } from "svelte";
|
||||||
import CaretLeft from "../icons/CaretLeft.svelte";
|
import CaretLeft from "../icons/CaretLeft.svelte";
|
||||||
import CaretRight from "../icons/CaretRight.svelte";
|
import CaretRight from "../icons/CaretRight.svelte";
|
||||||
|
@ -76,7 +82,11 @@
|
||||||
<Button
|
<Button
|
||||||
kind="ghost"
|
kind="ghost"
|
||||||
tooltipAlignment="center"
|
tooltipAlignment="center"
|
||||||
tooltipPosition="bottom"
|
tooltipPosition="{tooltipPosition === 'inside'
|
||||||
|
? 'right'
|
||||||
|
: tooltipPosition === 'outside'
|
||||||
|
? 'left'
|
||||||
|
: tooltipPosition}"
|
||||||
iconDescription="{backwardText}"
|
iconDescription="{backwardText}"
|
||||||
disabled="{!loop && page === 1}"
|
disabled="{!loop && page === 1}"
|
||||||
icon="{CaretLeft}"
|
icon="{CaretLeft}"
|
||||||
|
@ -147,7 +157,11 @@
|
||||||
<Button
|
<Button
|
||||||
kind="ghost"
|
kind="ghost"
|
||||||
tooltipAlignment="center"
|
tooltipAlignment="center"
|
||||||
tooltipPosition="bottom"
|
tooltipPosition="{tooltipPosition === 'inside'
|
||||||
|
? 'left'
|
||||||
|
: tooltipPosition === 'outside'
|
||||||
|
? 'right'
|
||||||
|
: tooltipPosition}"
|
||||||
iconDescription="{forwardText}"
|
iconDescription="{forwardText}"
|
||||||
disabled="{!loop && page === total}"
|
disabled="{!loop && page === total}"
|
||||||
icon="{CaretRight}"
|
icon="{CaretRight}"
|
||||||
|
|
|
@ -38,6 +38,12 @@ export interface PaginationNavProps
|
||||||
* @default "Previous page"
|
* @default "Previous page"
|
||||||
*/
|
*/
|
||||||
backwardText?: string;
|
backwardText?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the position of the tooltip relative to the pagination buttons.
|
||||||
|
* @default "bottom"
|
||||||
|
*/
|
||||||
|
tooltipPosition?: "top" | "right" | "bottom" | "left" | "outside" | "inside";
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class PaginationNav extends SvelteComponentTyped<
|
export default class PaginationNav extends SvelteComponentTyped<
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue