Skip to content

Commit

Permalink
feat(Pagination): migrate to tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
vbulant authored and mvidalgarcia committed Mar 11, 2024
1 parent 22464a6 commit c440d74
Show file tree
Hide file tree
Showing 29 changed files with 90 additions and 45 deletions.
2 changes: 1 addition & 1 deletion docs/src/data/tailwind-migration-status.yaml
Expand Up @@ -64,7 +64,7 @@ ModalSection: true
NavigationBar: true
NotificationBadge: true
OrbitProvider: true
Pagination: false
Pagination: true
Popover: true
Portal: true
Radio: true
Expand Down
51 changes: 51 additions & 0 deletions packages/orbit-components/src/Pagination/Pagination.ct-story.tsx
@@ -0,0 +1,51 @@
import * as React from "react";

import Pagination from ".";

export default function PaginationStory() {
return (
<div className="p-md">
<Pagination
labelNext="Previous"
labelPrev="Next"
labelProgress="1 of 6"
onPageChange={() => {}}
pageCount={6}
/>
<Pagination
labelNext="Previous"
labelPrev="Next"
labelProgress="1 of 6"
onPageChange={() => {}}
pageCount={6}
size="small"
/>
<Pagination
hideLabels={false}
labelNext="Previous"
labelPrev="Next"
labelProgress="1 of 6"
onPageChange={() => {}}
pageCount={6}
size="small"
/>
<Pagination
labelNext="Next"
labelPrev="Previous"
labelProgress="44 of 100"
onPageChange={() => {}}
pageCount={100}
selectedPage={44}
/>
<Pagination
hideLabels={false}
labelNext="Next"
labelPrev="Previous"
labelProgress="100 of 100"
onPageChange={() => {}}
pageCount={100}
selectedPage={100}
/>
</div>
);
}
23 changes: 23 additions & 0 deletions packages/orbit-components/src/Pagination/Pagination.ct.tsx
@@ -0,0 +1,23 @@
import * as React from "react";
import { test, expect } from "@playwright/experimental-ct-react";

import PaginationStory from "./Pagination.ct-story";
import RenderInRtl from "../utils/rtl/RenderInRtl";

test.describe("visual Pagination", () => {
test("default", async ({ mount }) => {
const component = await mount(<PaginationStory />);

await expect(component).toHaveScreenshot();
});

test("rtl", async ({ mount }) => {
const component = await mount(
<RenderInRtl>
<PaginationStory />
</RenderInRtl>,
);

await expect(component).toHaveScreenshot();
});
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,54 +1,25 @@
import * as React from "react";
import styled, { css } from "styled-components";
import cx from "clsx";

import type * as Common from "../../common/types";
import Button from "../../Button";
import defaultTheme from "../../defaultTheme";
import type { Props as ButtonPrimitiveProps } from "../../primitives/ButtonPrimitive/types";

interface Props {
children: React.ReactNode;
transparent?: boolean;
className?: string;
size?: Common.InputSize;
}

const StyledButton = styled.div<Props>`
${({ theme, transparent }) => css`
&:hover,
&:active,
&:focus {
background: ${theme.orbit.backgroundButtonSecondary};
color: ${theme.orbit.colorTextButtonSecondary};
transform: none;
cursor: default;
}
${transparent &&
css`
&&& {
background-color: transparent;
box-shadow: none;
}
`};
`}
`;

StyledButton.defaultProps = {
theme: defaultTheme,
};

const ActiveButtonAsComponent =
({ transparent }) =>
({ children, ...props }: Props) => {
return (
<StyledButton {...props} transparent={transparent}>
{children}
</StyledButton>
);
const Component =
({ className: customClassName }: { className: Props["className"] }) =>
({ children, className }: ButtonPrimitiveProps) => {
return <div className={cx("pointer-events-none", customClassName, className)}>{children}</div>;
};

const ActiveButton = ({ children, transparent, size }: Props) => {
const ActiveButton = ({ children, className, size }: Props) => {
return (
<Button type="secondary" size={size} asComponent={ActiveButtonAsComponent({ transparent })}>
<Button type="secondary" size={size} asComponent={Component({ className })}>
{children}
</Button>
);
Expand Down
12 changes: 6 additions & 6 deletions packages/orbit-components/src/Pagination/index.tsx
Expand Up @@ -39,18 +39,18 @@ const Pagination = ({
<>
<ButtonLink
onClick={() => pageChanged(selectedPage - 1)}
iconLeft={<ChevronBackward />}
iconLeft={<ChevronBackward reverseOnRtl />}
type="secondary"
title={labelPrev}
size={size}
disabled={selectedPage <= 1}
/>
<ActiveButton transparent size={size}>
<ActiveButton className="bg-transparent" size={size}>
{labelProgress}
</ActiveButton>
<ButtonLink
onClick={() => pageChanged(selectedPage + 1)}
iconLeft={<ChevronForward />}
iconLeft={<ChevronForward reverseOnRtl />}
type="secondary"
title={labelNext}
size={size}
Expand All @@ -61,7 +61,7 @@ const Pagination = ({
<>
<ButtonLink
onClick={() => pageChanged(selectedPage - 1)}
iconLeft={<ChevronBackward />}
iconLeft={<ChevronBackward reverseOnRtl />}
type="secondary"
title={hideLabels ? labelPrev : undefined}
size={size}
Expand All @@ -88,8 +88,8 @@ const Pagination = ({
</Stack>
<ButtonLink
onClick={() => pageChanged(selectedPage + 1)}
iconRight={!hideLabels && <ChevronForward />}
iconLeft={hideLabels && <ChevronForward />}
iconRight={!hideLabels && <ChevronForward reverseOnRtl />}
iconLeft={hideLabels && <ChevronForward reverseOnRtl />}
type="secondary"
title={hideLabels ? labelNext : undefined}
size={size}
Expand Down

0 comments on commit c440d74

Please sign in to comment.