Skip to content

Commit

Permalink
feat(Coupon): migrate to tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
vbulant authored and mvidalgarcia committed Mar 5, 2024
1 parent 54fe70d commit 6827ccb
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/src/data/tailwind-migration-status.yaml
Expand Up @@ -22,7 +22,7 @@ CarrierLogo: true
Checkbox: true
ChoiceGroup: true
Collapse: true
Coupon: false
Coupon: true
CountryFlag: true
Desktop: true
Dialog: true
Expand Down
6 changes: 5 additions & 1 deletion packages/orbit-components/src/Coupon/Coupon.ct-story.tsx
Expand Up @@ -3,5 +3,9 @@ import React from "react";
import Coupon from ".";

export default function CouponVisualStory() {
return <Coupon>1337420</Coupon>;
return (
<div className="p-md">
<Coupon>1337420</Coupon>
</div>
);
}
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.
8 changes: 6 additions & 2 deletions packages/orbit-components/src/Coupon/Coupon.stories.tsx
Expand Up @@ -34,12 +34,16 @@ Default.story = {

export const Playground = () => {
const dataTest = text("dataTest", "test");
const id = text("id", "couponId");
const content = text("content", "CODE");

return (
<Text>
Lorem ipsum dolor sit amet, consectetuer <Coupon dataTest={dataTest}>{content}</Coupon> elit.
Proin pede metus, vulputate nec, fermentum fringilla, vehicula vitae, justo.
Lorem ipsum dolor sit amet, consectetuer{" "}
<Coupon dataTest={dataTest} id={id}>
{content}
</Coupon>{" "}
elit. Proin pede metus, vulputate nec, fermentum fringilla, vehicula vitae, justo.
</Text>
);
};
Expand Down
10 changes: 8 additions & 2 deletions packages/orbit-components/src/Coupon/__tests__/index.test.tsx
Expand Up @@ -5,8 +5,14 @@ import Coupon from "..";

describe("Coupon", () => {
it("should have expected DOM output", () => {
render(<Coupon dataTest="test">code</Coupon>);
expect(screen.getByTestId("test")).toBeInTheDocument();
render(
<Coupon dataTest="test" id="couponId">
code
</Coupon>,
);
const coupon = screen.getByTestId("test");
expect(coupon).toBeInTheDocument();
expect(coupon).toHaveAttribute("id", "couponId");
expect(screen.getByText("code")).toBeInTheDocument();
});
});
30 changes: 6 additions & 24 deletions packages/orbit-components/src/Coupon/index.tsx
@@ -1,35 +1,17 @@
"use client";

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

import defaultTheme from "../defaultTheme";
import type { Props } from "./types";

const StyledCoupon = styled.mark`
${({ theme }) => css`
display: inline;
background: none;
font-size: ${theme.orbit.fontSizeTextSmall};
letter-spacing: 0.75px;
text-transform: uppercase;
border: 1px dashed ${theme.orbit.paletteCloudDark};
padding: 2px ${theme.orbit.spaceXXSmall};
line-height: inherit;
font-weight: ${theme.orbit.fontWeightMedium};
border-radius: ${theme.orbit.borderRadiusNormal};
color: ${theme.orbit.paletteInkDark};
`}
`;

StyledCoupon.defaultProps = {
theme: defaultTheme,
};

const Coupon = ({ children, dataTest, id }: Props) => (
<StyledCoupon data-test={dataTest} id={id}>
<mark
className="orbit-coupon text-small border-cloud-dark py-xxxs px-xxs rounded-normal text-ink-dark inline border border-dashed bg-transparent font-medium uppercase tracking-[0.75px]"
data-test={dataTest}
id={id}
>
{children}
</StyledCoupon>
</mark>
);

export default Coupon;

0 comments on commit 6827ccb

Please sign in to comment.