From ec5005e5b68f81848e952b3ed0350ca82217e86a Mon Sep 17 00:00:00 2001 From: Mitchell Soares Date: Mon, 9 Sep 2019 10:43:04 -0400 Subject: [PATCH 01/14] Added label prop to Pagination --- src/components/Pagination/Pagination.scss | 9 +++++++++ src/components/Pagination/Pagination.tsx | 19 +++++++++++++++---- .../Pagination/tests/Pagination.test.tsx | 8 ++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/components/Pagination/Pagination.scss b/src/components/Pagination/Pagination.scss index 0ab14501ea7..b7c5488eb82 100644 --- a/src/components/Pagination/Pagination.scss +++ b/src/components/Pagination/Pagination.scss @@ -8,6 +8,7 @@ $difference-between-touch-area-and-backdrop: control-height() - // This is the adjustment needed to get the icon to appear flush with other // content around it. $plain-horizontal-adjustment: spacing(tight); +$labelMinWidth: rem(80px); $stacking-order: ( item: 10, @@ -108,6 +109,7 @@ $stacking-order: ( ); border: border(dark); border-radius: border-radius(); + line-height: 1; color: color('ink'); text-align: center; @@ -166,3 +168,10 @@ $stacking-order: ( border-top-left-radius: 0; border-bottom-left-radius: 0; } + +.Label { + min-width: $labelMinWidth; + display: flex; + align-items: center; + justify-content: center; +} diff --git a/src/components/Pagination/Pagination.tsx b/src/components/Pagination/Pagination.tsx index f05239e0d04..7f5158991fe 100644 --- a/src/components/Pagination/Pagination.tsx +++ b/src/components/Pagination/Pagination.tsx @@ -1,5 +1,6 @@ import React from 'react'; import {ArrowLeftMinor, ArrowRightMinor} from '@shopify/polaris-icons'; +import {TextStyle} from '../TextStyle'; import {classNames} from '../../utilities/css'; import {useI18n} from '../../utilities/i18n'; import {isInputFocused} from '../../utilities/is-input-focused'; @@ -35,6 +36,8 @@ export interface PaginationDescriptor { onNext?(): void; /** Callback when previous button is clicked */ onPrevious?(): void; + /** Show page number information */ + label?: string; } export interface PaginationProps extends PaginationDescriptor { @@ -55,16 +58,17 @@ export function Pagination({ previousKeys, plain, accessibilityLabel, + label, }: PaginationProps) { const intl = useI18n(); const node: React.RefObject = React.createRef(); - let label: string; + let navLabel: string; if (accessibilityLabel) { - label = accessibilityLabel; + navLabel = accessibilityLabel; } else { - label = intl.translate('Polaris.Pagination.pagination'); + navLabel = intl.translate('Polaris.Pagination.pagination'); } const className = classNames(styles.Pagination, plain && styles.plain); @@ -163,10 +167,17 @@ export function Pagination({ /> )); + const labelMarkup = label ? ( +
+ {label} +
+ ) : null; + return ( -