Skip to content

Commit

Permalink
feat(StopoverArrow): migrate to tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
vbulant committed Feb 29, 2024
1 parent e0b5d1a commit 166e7a9
Show file tree
Hide file tree
Showing 30 changed files with 49 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/src/data/tailwind-migration-status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SocialButton: true
Stack: true
Stepper: true
StepperStateless: true
StopoverArrow: false
StopoverArrow: true
Switch: true
Tab: true
TabPanel: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from "react";

import STOPS from "./consts";

import StopoverArrow from ".";

export default function StopoverArrowStory() {
return (
<div className="p-md">
{Object.values(STOPS).map(stops => (
<StopoverArrow stops={stops} />
))}
</div>
);
}
23 changes: 23 additions & 0 deletions packages/orbit-components/src/StopoverArrow/StopoverArrow.ct.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from "react";
import { test, expect } from "@playwright/experimental-ct-react";

import StopoverArrowStory from "./StopoverArrow.ct-story";
import RenderInRtl from "../utils/rtl/RenderInRtl";

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

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

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

await expect(component).toHaveScreenshot();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export default {
export const Playground = () => {
const stops = select("stops", Object.values(STOPS), STOPS.ZERO);
const dataTest = text("dataTest", "test");
const id = text("id", "ID");

return <StopoverArrow stops={stops} dataTest={dataTest} />;
return <StopoverArrow stops={stops} dataTest={dataTest} id={id} />;
};

Playground.story = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import STOPS from "../consts";
describe("StopoverArrow", () => {
it("should have expected DOM output", () => {
const dataTest = "test";
const id = "ID";
const stops = STOPS.THREE;
render(<StopoverArrow dataTest={dataTest} stops={stops} />);
render(<StopoverArrow dataTest={dataTest} stops={stops} id={id} />);
expect(screen.getByTitle(`Stopover arrow, ${stops} stops`)).toBeInTheDocument();
expect(screen.getByTestId(dataTest)).toBeInTheDocument();
const el = screen.getByTestId(dataTest);
expect(el).toBeInTheDocument();
expect(el).toHaveAttribute("id", id);
});
});
24 changes: 3 additions & 21 deletions packages/orbit-components/src/StopoverArrow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
"use client";

import * as React from "react";
import styled, { css } from "styled-components";

import { useRandomIdSeed } from "../hooks/useRandomId";
import defaultTheme from "../defaultTheme";
import STOPS from "./consts";
import type { Props } from "./types";

const StyledArrow = styled.svg`
vertical-align: middle;
fill: currentColor;
color: ${({ theme }) => theme.orbit.colorStopoverArrow};
width: ${({ theme }) => theme.orbit.widthStopoverArrow};
height: ${({ theme }) => theme.orbit.heightStopoverArrow};
${({ theme }) =>
theme.rtl &&
css`
transform: scale(-1, 1);
`};
`;

StyledArrow.defaultProps = {
theme: defaultTheme,
};

const Stops = ({ stops }: Props) => {
if (stops === STOPS.ONE) {
return (
Expand Down Expand Up @@ -52,7 +33,8 @@ const StopoverArrow = ({ stops = STOPS.ZERO, dataTest, id }: Props) => {
const descrId = randomId("descr");

return (
<StyledArrow
<svg
className="orbit-stopover-arrow text-ink-light h-[7px] w-[36px] fill-current align-middle rtl:-scale-x-100"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 28 8"
aria-labelledby={`${titleId} ${descrId}`}
Expand All @@ -63,7 +45,7 @@ const StopoverArrow = ({ stops = STOPS.ZERO, dataTest, id }: Props) => {
<title id={titleId}>Stopover arrow, {stops} stops</title>
<desc id={descrId}>Shows how many stopovers there are between two locations</desc>
<Stops stops={stops} />
</StyledArrow>
</svg>
);
};

Expand Down

0 comments on commit 166e7a9

Please sign in to comment.