瀏覽代碼

Add documents for Pagination component

杜府 3 年之前
父節點
當前提交
33fd92c456

+ 1 - 0
doc/components/pagination/FAQ.md

@@ -0,0 +1 @@
+

+ 1 - 0
doc/components/pagination/FAQ_en.md

@@ -0,0 +1 @@
+

+ 24 - 0
doc/components/pagination/api.md

@@ -0,0 +1,24 @@
+## Pagination Props
+
+| 属性             | 类型    | 默认值                                   | 可选值                              | 必传 | 说明                 |
+| ---------------- | ------- | ---------------------------------------- | ----------------------------------- | ---- | -------------------- |
+| total            | Number  | 0                                        | -                                   | Y    | 总条数。             |
+| pageSize         | Number  | 10                                       | -                                   | N    | 每页条数。           |
+| current          | Number  | 1                                        | -                                   | N    | 当前页。             |
+| maxShowPage      | Number  | 7                                        | 5/7/9/11                            | N    | 最大显示页码数。     |
+| radius           | String  | 'md'                                     | 'base'/'md'/'lg'/'xl'/'full'/'none' | N    | 圆角风格。           |
+| type             | String  | 'bold'                                   | 'border'/'block'/'bold'             | N    | 高亮页码类型。       |
+| pageCol          | Number  | 3                                        | -                                   | N    | 省略页码列数。       |
+| showNextOmitPage | Boolean | false                                    | true/false                          | N    | 是否显示后省略页码。 |
+| showPreOmitPage  | Boolean | false                                    | true/false                          | N    | 是否显示前省略页码。 |
+| injClass         | String  | ''                                       | Class                               | N    | 注入 CSS 名称。。    |
+| noDataText       | String  | 当前语言的 common.noData                 | -                                   | N    | 无数据显示文本。     |
+| onePageText      | String  | 当前语言的 pagination.defaultOnlyOnePage | -                                   | N    | 仅一页显示文本。     |
+
+## Pagination Events
+
+| 名称   | 参数                                      | 描述               |
+| ------ | ----------------------------------------- | ------------------ |
+| change | event:事件对象,其中 detail 为当前页码。 | 页码变化时触发。   |
+| next   | event:事件对象,其中 detail 为当前页码。 | 点击下一页时触发。 |
+| pre    | event:事件对象,其中 detail 为当前页码。 | 点击上一页时触发。 |

+ 24 - 0
doc/components/pagination/api_en.md

@@ -0,0 +1,24 @@
+## Pagination Props
+
+| Property         | Type    | Default Value                 | Options                             | Required | Description                                                      |
+| ---------------- | ------- | ----------------------------- | ----------------------------------- | -------- | ---------------------------------------------------------------- |
+| total            | Number  | 0                             | -                                   | Y        | Total number of items.                                           |
+| pageSize         | Number  | 10                            | -                                   | N        | Number of items per page.                                        |
+| current          | Number  | 1                             | -                                   | N        | Current page number.                                             |
+| maxShowPage      | Number  | 7                             | 5/7/9/11                            | N        | Maximum number of page numbers to display.                       |
+| radius           | String  | 'md'                          | 'base'/'md'/'lg'/'xl'/'full'/'none' | N        | Style of pagination button corners.                              |
+| type             | String  | 'bold'                        | 'border'/'block'/'bold'             | N        | Style of highlighted page number.                                |
+| pageCol          | Number  | 3                             | -                                   | N        | Number of columns to display omitted page numbers.               |
+| showNextOmitPage | Boolean | false                         | true/false                          | N        | Whether to display omitted page numbers after the current page.  |
+| showPreOmitPage  | Boolean | false                         | true/false                          | N        | Whether to display omitted page numbers before the current page. |
+| injClass         | String  | ''                            | Class                               | N        | Injected CSS class name.                                         |
+| noDataText       | String  | Common.noData                 | -                                   | N        | Text to display when there is no data.                           |
+| onePageText      | String  | pagination.defaultOnlyOnePage | -                                   | N        | Text to display when there is only one page.                     |
+
+## Pagination Events
+
+| Name   | Parameter(s)                                     | Description                                      |
+| ------ | ------------------------------------------------ | ------------------------------------------------ |
+| change | event: Event object, detail: current page number | Triggered when the page number is changed.       |
+| next   | event: Event object, detail: current page number | Triggered when the "next" button is clicked.     |
+| pre    | event: Event object, detail: current page number | Triggered when the "previous" button is clicked. |

+ 41 - 0
doc/components/pagination/guide.md

@@ -0,0 +1,41 @@
+## 设计思路
+
+私以为,分页不应该是上滑加载下一页,这种交互会让用户无心理预期而产生不适,所以 STDF 的分页组件交互须满足以下几个条件:
+
+-   页码变化事件必须是用户主动触发。
+-   无论何时都须同时显示上一页、下一页、首页、尾页、当前页,用户对全部数据有预期且可直接点击跳转到这些关键页码。
+-   移动端横向显示区域有限,即便如此,也可以通过点击省略页码跳转到任意页码。
+
+## 事件监听
+
+Pagination 组件对外暴露了三个事件:change、next、pre,分别对应页码变化、下一页、上一页。next 和 pre 事件同时也会触发 change 事件,请按需监听。
+
+## total
+
+Pagination 组件内将不显示 total 数据,请根据具体业务决定是否在页面内显示。
+
+## current
+
+current 为当前页码,内部默认从 1 开始计数,外部也可传入一个初始页码。
+
+## maxShowPage
+
+maxShowPage 表示最大显示页码数,即算上首页、尾页、显示页、省略号等在内一起算的数量,可选值为 5、7、9、11。此数值越大同时显示的页码越多,但也会导致单项宽度变小,影响用户操作,请根据具体业务决定。
+
+## 省略页码
+
+当总页码数大于 maxShowPage 时,就会有省略页码,省略页码分为前省略页码和后省略页码。当总页码数不是很多时,同时只会省略前后页码中的一个,当总页码数很多时,同时会省略前后页码。
+
+所有省略的页码都可以通过点击省略号展开,展开区域支持上下滚动,且支持通过 pageCol 属性控制每行显示的页码数量。**并支持点击任意页码跳转到该页码。**
+
+如果担心用户首次使用时无法知晓此交互,可以根据具体业务,比如用户首次使用时且总页码数大于 maxShowPage 时,通过传入 showNextOmitPage 默认将后省略页码展开,加以引导。
+
+## type
+
+type 表示高亮页码类型,可选值为 border、block、bold。border 表示高亮页码为边框,block 表示高亮页码为块,bold 表示高亮页码加粗且弱化其他页码。
+
+## CSS 注入
+
+通过 injClass 参数可以向组件内部外层注入 CSS 名称(不仅限于 Tailwind CSS),这将使组件样式有更多自定义可能性,示例中通过 injClass 实现了自定义圆角风格、两边间距、阴影等。
+
+若注入的 CSS 没生效,请在注入的 CSS 名称前添加“!” ,可参考 [Tailwind Important modifier](https://tailwindcss.com/docs/configuration#important-modifier)。

+ 41 - 0
doc/components/pagination/guide_en.md

@@ -0,0 +1,41 @@
+## Design Concept
+
+In my opinion, pagination should not be based on scrolling up to load the next page. This interaction can cause user uncomfortable as there is no psychological expectation. Therefore, the STDF pagination component should meet the following conditions:
+
+-   The page change event must be triggered by the user.
+-   The previous page, next page, first page, last page, and current page must always be displayed, and the user can directly click to jump to these key page numbers.
+-   On mobile devices, the horizontal display area is limited. Nevertheless, users can still click on the ellipsis to jump to any page number.
+
+## Event Listening
+
+The Pagination component exposes three events to the outside: change, next, and pre, corresponding to page number changes, next page, and previous page, respectively. The next and pre events will also trigger the change event, so listen as needed.
+
+## total
+
+The total data will not be displayed inside the Pagination component, so decide whether to display it on the page based on specific business requirements.
+
+## current
+
+Current represents the current page number, which is counted from 1 internally by default. An initial page number can also be passed in from the outside.
+
+## maxShowPage
+
+MaxShowPage represents the maximum number of displayed page numbers, including the first page, last page, displayed page, ellipsis, and so on. The optional values are 5, 7, 9, and 11. The larger the value, the more page numbers will be displayed at the same time, but the width of each item will be smaller, affecting user operations. Decide based on specific business requirements.
+
+## Ellipsis Page Number
+
+When the total number of pages is greater than maxShowPage, there will be ellipsis page numbers, which are divided into front ellipsis page numbers and back ellipsis page numbers. When the total number of pages is not very large, only one of the front and back ellipsis page numbers will be omitted at the same time. When the total number of pages is very large, both the front and back ellipsis page numbers will be omitted at the same time.
+
+All omitted page numbers can be expanded by clicking on the ellipsis, and the expandable area supports scrolling up and down. The number of page numbers displayed per row can be controlled by the pageCol property. **And clicking on any page number in the expanded area will jump to that page number.**
+
+If you are concerned that users may not understand this interaction when they use it for the first time, and the total number of pages is greater than maxShowPage, you can pass in showNextOmitPage by default to expand the back ellipsis page numbers and guide them.
+
+## Type
+
+Type represents the type of highlighted page numbers, with optional values of border, block, and bold. Border represents that the highlighted page number is the border, block represents that the highlighted page number is the block, and bold represents that the highlighted page number is bold and the other page numbers are weakened.
+
+## CSS Injection
+
+The injClass parameter can be used to inject a CSS class name (not limited to Tailwind CSS) into the outer layer of the component, which will provide more possibilities for customizing the component style. In the example, custom rounded corners, spacing on both sides, shadows, and other styles are achieved through injClass.
+
+If the injected CSS does not take effect, add "!" in front of the injected CSS class name, as shown in the [Tailwind Important modifier](https://tailwindcss.com/docs/configuration#important-modifier).

+ 15 - 0
doc/components/pagination/version.md

@@ -0,0 +1,15 @@
+<!-- "[!tag|A|0|]"表示一个 tag,其中A表示新增,B表示 BUG,O表示优化,第二个数字表示 BUG 等级,0暂无意义。 -->
+<!-- "[!issue|dufu1991|]"表示一个 issue 提出者,其中 dufu1991 是提出者的id。 -->
+<!-- "[!contribute|dufu1991|]"表示一个贡献者,其中 eric1932 是贡献者的id。 -->
+
+<!-- 记得带上版本号和更新日期,以下是一个示例:
+
+## 0.0.1
+
+-   [!tag|B|1|]严重 BUG。[!contribute|dufu1991|][!issue|dufu1991|]
+-   [!tag|B|2|]一般 BUG。
+-   [!tag|B|3|]轻微 BUG。
+-   [!tag|O|0|]优化。
+-   [!tag|A|0|]新增。
+
+<font size=1>2022-07-18</font> -->

+ 15 - 0
doc/components/pagination/version_en.md

@@ -0,0 +1,15 @@
+<!-- "[!tag|A|0|]" This represents a tag, where A stands for addition, B stands for bug, and O stands for optimization. The second digit represents the severity level of the bug, with 0 having no significance. -->
+<!-- "[!issue|dufu1991|]" Indicates an issue submitter, where dufu1991 is the submitter's ID. -->
+<!-- "[!contribute|dufu1991|]" Indicates a contributor, where dufu1991 is the ID of the contributor. -->
+
+<!-- Remember to include the version number and update date. Here is an example:
+
+## 0.0.1
+
+-   [!tag|B|1|]严重 BUG。[!contribute|dufu1991|][!issue|dufu1991|]
+-   [!tag|B|2|]一般 BUG。
+-   [!tag|B|3|]轻微 BUG。
+-   [!tag|O|0|]优化。
+-   [!tag|A|0|]新增。
+
+<font size=1>2022-07-18</font> -->

+ 4 - 0
doc/guide/changelog.md

@@ -1,3 +1,7 @@
+## 0.1.0
+
+-   新增 Pagination 组件,详见 [Pagination](https://stdf.design/#/components?nav=pagination&tab=0)。
+
 ## 0.0.27
 
 -   0.0.12 ~ 0.0.27 版本无实质更新,仅用于测试 GitHub Action。

+ 4 - 0
doc/guide/changelog_en.md

@@ -1,3 +1,7 @@
+## 0.1.0
+
+-   Add Pagination component, please see [Pagination](https://stdf.design/#/components?nav=pagination&tab=0).
+
 ## 0.0.27
 
 -   0.0.12 ~ 0.0.27 versions have no substantial updates, only for testing GitHub Action.

+ 2 - 2
doc/guide/future.md

@@ -1,8 +1,8 @@
 ## 💪 新增 💪
 
-- [ ] 新增 Pagination-分页组件,个人反感无限滚动,考虑点击加载更多。
 - [ ] 新增 NumKeyboard-数字键盘组件,一般用于输入数字。
 - [ ] 新增 SecurityCode-安全码组件,一般用于输入短信或邮件收到的数字校验码。
+- [x] 新增 Pagination-分页组件。
 
 ---
 
@@ -15,4 +15,4 @@
 
 ## 💪 持续 💪
 
-- [ ] 丰富 Loading 加载组件类型。
+- 丰富 Loading 加载组件类型。

+ 1 - 1
doc/guide/future_en.md

@@ -1,8 +1,8 @@
 ## 💪 New Features 💪
 
-- [ ] Added Pagination component, as I dislike infinite scrolling and prefer click-to-load-more functionality.
 - [ ] Added NumKeyboard component for inputting numbers.
 - [ ] Added SecurityCode component for entering verification codes received via SMS or email.
+- [x] Added Pagination component.
 
 ---