Skip to content

Commit

Permalink
feat(unstable-pagination): add refactored experimental pagination com…
Browse files Browse the repository at this point in the history
…ponent (#5485)

* feat(unstable_pagination): initial commit of js, scss, and story demo

* fix(unstable-pagination): update naming structure

* fix(unstable-pagination): add styles for refactored component

* fix(unstable-pagination): update imports

* fix(unstable-pagination): flatten styles

* fix(unstable-pagination): update class names

* fix(unstable-pagination): update comments and formatting

* chore: run prettier

* chore: update exports snapshot

* feat(unstable-pagination): remove page-input subcomponent

* fix(pagination): remove page-input styles

* fix: remove page input from api snapshot

* fix(unstable-pagination): update left and right section height

* test(api): update public api snapshot to include new components

* fix(unstable-pagination): adjust btn focus outlines

* fix(unstable-pagination): update select hover state, update borders

Co-authored-by: TJ Egan <[email protected]>
  • Loading branch information
jendowns and tw15egan authored Jun 2, 2020
1 parent cace136 commit 40d9deb
Show file tree
Hide file tree
Showing 10 changed files with 793 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
//
// Copyright IBM Corp. 2016, 2020
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

$css--helpers: true;

@import '../../globals/scss/vars';
@import '../../globals/scss/helper-mixins';
@import '../../globals/scss/typography';
@import '../../globals/scss/layout';
@import '../../globals/scss/css--helpers';
@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
@import '../select/select';

/// Unstable pagination styles
/// @access private
/// @group pagination
@mixin unstable_pagination {
.#{$prefix}--unstable-pagination {
@include reset;
@include carbon--type-style('body-short-01');
width: 100%;
background-color: $ui-01;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1px solid $ui-03;
border-bottom: 1px solid transparent;
height: rem(48px);
}

.#{$prefix}--unstable-pagination__text {
@include carbon--breakpoint('md') {
display: inline-block;
}

margin: 0 $carbon--spacing-05;
color: $text-02;
}

.#{$prefix}--unstable-pagination__left,
.#{$prefix}--unstable-pagination__right {
display: flex;
height: 100%;
align-items: center;
}

.#{$prefix}--unstable-pagination__left {
padding: 0 $carbon--spacing-05 0 0;
}

.#{$prefix}--unstable-pagination__left > .#{$prefix}--form-item,
.#{$prefix}--unstable-pagination__right > .#{$prefix}--form-item {
height: 100%;
}

.#{$prefix}--unstable-pagination__left
.#{$prefix}--unstable-pagination__text {
margin-right: rem(1px);
}

.#{$prefix}--unstable-pagination__right
.#{$prefix}--unstable-pagination__text {
margin-right: $carbon--spacing-05;
margin-left: rem(1px);
}

.#{$prefix}--unstable-pagination__button {
@include reset;
border: none;
border-left: 1px solid $ui-03;
background: none;
cursor: pointer;
height: 100%;
margin: 0;
padding: 0 rem(14px);
display: flex;
justify-content: center;
align-items: center;
color: $ui-05; // for currentColor
fill: $ui-05;
transition: outline $duration--fast-02 motion(standard, productive);
transition: background-color $duration--fast-02 motion(standard, productive);
}

// Unset height/width set by icon-only button:
.#{$prefix}--unstable-pagination__button .#{$prefix}--btn__icon {
height: unset;
width: unset;
}

.#{$prefix}--unstable-pagination__button.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger:focus {
@include focus-outline('outline');
}

.#{$prefix}--unstable-pagination__button:hover {
background: $hover-ui;
color: $ui-05;
}

.#{$prefix}--unstable-pagination__button--no-index {
fill: $disabled-02;
cursor: not-allowed;
}

.#{$prefix}--unstable-pagination__button.#{$prefix}--btn:disabled {
background: transparent;
border-color: $ui-03;
}

.#{$prefix}--unstable-pagination__button:disabled:hover,
.#{$prefix}--unstable-pagination__button--no-index:hover {
cursor: not-allowed;
fill: $disabled-02;
background: transparent;
}

.#{$prefix}--unstable-pagination__page-selector,
.#{$prefix}--unstable-pagination__page-sizer {
height: 100%;
align-items: center;
}

.#{$prefix}--unstable-pagination__page-selector
.#{$prefix}--select-input--inline__wrapper,
.#{$prefix}--unstable-pagination__page-sizer
.#{$prefix}--select-input--inline__wrapper {
display: flex;
height: 100%;
}

.#{$prefix}--unstable-pagination__page-selector .#{$prefix}--select-input,
.#{$prefix}--unstable-pagination__page-sizer .#{$prefix}--select-input {
@include carbon--type-style('body-short-01');
width: auto;
min-width: auto;
height: 100%;
padding: 0 $carbon--spacing-08 0 $carbon--spacing-05;
margin-right: -0.65rem;

@include carbon--breakpoint('md') {
padding-right: carbon--mini-units(4.5);
margin-right: 0;
}
}

.#{$prefix}--unstable-pagination__page-selector
.#{$prefix}--select-input:hover,
.#{$prefix}--unstable-pagination__page-sizer .#{$prefix}--select-input:hover {
background: $hover-ui;
}

.#{$prefix}--unstable-pagination__page-selector .#{$prefix}--select__arrow,
.#{$prefix}--unstable-pagination__page-sizer .#{$prefix}--select__arrow {
top: 50%;
transform: translateY(-50%);

@include carbon--breakpoint('md') {
right: $carbon--spacing-05;
}
}

.#{$prefix}--unstable-pagination__page-selector {
border-left: 1px solid $ui-03;
}

.#{$prefix}--unstable-pagination__page-sizer {
border-right: 1px solid $ui-03;
}
}

@include exports('unstable_pagination') {
@include unstable_pagination;
}
1 change: 1 addition & 0 deletions packages/components/src/globals/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $deprecations--message: 'Deprecated code was found, this code will be removed be
//-------------------------------------
// 🔬 Experimental
//-------------------------------------
@import '../../components/pagination/unstable_pagination';
@import '../../components/ui-shell/ui-shell';

//-------------------------------------
Expand Down
1 change: 1 addition & 0 deletions packages/react/.storybook/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ $prefix: 'bx';
@import '~carbon-components/src/components/tabs/tabs';
@import '~carbon-components/src/components/tag/tag';
@import '~carbon-components/src/components/pagination/pagination';
@import '~carbon-components/src/components/pagination/unstable_pagination';
@import '~carbon-components/src/components/accordion/accordion';
@import '~carbon-components/src/components/progress-indicator/progress-indicator';
@import '~carbon-components/src/components/breadcrumb/breadcrumb';
Expand Down
131 changes: 131 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6134,6 +6134,137 @@ Map {
},
},
},
"PageSelector" => Object {
"defaultProps": Object {
"className": null,
"id": 1,
"labelText": "Current page number",
},
"propTypes": Object {
"className": Object {
"type": "string",
},
"currentPage": Object {
"isRequired": true,
"type": "number",
},
"id": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"labelText": Object {
"type": "string",
},
"totalPages": Object {
"isRequired": true,
"type": "number",
},
},
},
"Unstable_Pagination" => Object {
"defaultProps": Object {
"backwardText": "Previous page",
"children": undefined,
"className": null,
"disabled": false,
"forwardText": "Next page",
"id": 1,
"initialPage": 1,
"itemRangeText": [Function],
"itemText": [Function],
"itemsPerPageText": "Items per page:",
"pageRangeText": [Function],
"pageSize": 10,
"pageSizes": undefined,
"pageText": [Function],
"pagesUnknown": false,
"totalItems": undefined,
},
"propTypes": Object {
"backwardText": Object {
"type": "string",
},
"children": Object {
"args": Array [
Array [
Object {
"type": "node",
},
Object {
"type": "func",
},
],
],
"type": "oneOfType",
},
"className": Object {
"type": "string",
},
"disabled": Object {
"type": "bool",
},
"forwardText": Object {
"type": "string",
},
"id": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"initialPage": Object {
"type": "number",
},
"itemRangeText": Object {
"type": "func",
},
"itemText": Object {
"type": "func",
},
"itemsPerPageText": Object {
"type": "string",
},
"pageRangeText": Object {
"type": "func",
},
"pageSize": Object {
"type": "number",
},
"pageSizes": Object {
"args": Array [
Object {
"type": "number",
},
],
"type": "arrayOf",
},
"pageText": Object {
"type": "func",
},
"pagesUnknown": Object {
"type": "bool",
},
"totalItems": Object {
"type": "number",
},
},
},
"Content" => Object {
"defaultProps": Object {
"tagName": "main",
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe('Carbon Components React', () => {
"OrderedList",
"OverflowMenu",
"OverflowMenuItem",
"PageSelector",
"Pagination",
"PaginationSkeleton",
"PrimaryButton",
Expand Down Expand Up @@ -190,6 +191,7 @@ describe('Carbon Components React', () => {
"TooltipDefinition",
"TooltipIcon",
"UnorderedList",
"Unstable_Pagination",
]
`);
});
Expand Down
Loading

0 comments on commit 40d9deb

Please sign in to comment.