Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CallOutBanner): migrate to tailwind #4293

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -15,7 +15,7 @@ ButtonGroup: true
ButtonLink: true
ButtonMobileStore: true
ButtonPrimitive: true
CallOutBanner: false
CallOutBanner: true
Card: true
CardSection: true
CarrierLogo: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,33 @@ import NewWindow from "../icons/NewWindow";

import CallOutBanner from ".";

export default function CallOutBannerVisualStory() {
export default function CallOutBannerStory() {
return (
<CallOutBanner
title="Call out banner"
description="Description worth testing"
illustration={<Illustration size="small" name="Money" />}
actions={
<Button type="secondary" size="small" iconRight={<NewWindow />}>
Find a Room
</Button>
}
>
<Text>Some children</Text>
</CallOutBanner>
<div className="gap-md p-md flex flex-col">
<CallOutBanner
title="Call out banner"
description="Description worth testing"
illustration={<Illustration size="small" name="Money" />}
actions={
<Button type="secondary" size="small" iconRight={<NewWindow />}>
Find a Room
</Button>
}
>
<Text>Some children</Text>
</CallOutBanner>
<CallOutBanner
title="Actionable"
description="Description worth testing"
actions={
<Button type="secondary" size="small" iconRight={<NewWindow />}>
Find a Room
</Button>
}
onClick={() => {}}
>
<Text>Some children</Text>
</CallOutBanner>
</div>
);
}
13 changes: 12 additions & 1 deletion packages/orbit-components/src/CallOutBanner/CallOutBanner.ct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ import * as React from "react";
import { test, expect } from "@playwright/experimental-ct-react";

import CallOutBannerStory from "./CallOutBanner.ct-story";
import RenderInRtl from "../utils/rtl/RenderInRtl";

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

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

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

await expect(component).toHaveScreenshot();
});
});
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 @@ -12,6 +12,7 @@ describe("CallOutBanner", () => {
render(
<CallOutBanner
dataTest="test"
id="ID"
title="title"
description="description"
tabIndex={0}
Expand All @@ -22,6 +23,7 @@ describe("CallOutBanner", () => {
);
const banner = screen.getByTestId("test");
expect(banner).toHaveAttribute("tabindex", "0");
expect(banner).toHaveAttribute("id", "ID");
expect(banner.textContent).toMatch("title");
expect(banner.textContent).toMatch("description");
expect(screen.getByTestId("illustration"));
Expand Down
65 changes: 12 additions & 53 deletions packages/orbit-components/src/CallOutBanner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,13 @@
"use client";

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

import mq from "../utils/mediaQuery";
import defaultTheme from "../defaultTheme";
import Heading from "../Heading";
import Stack from "../Stack";
import Text from "../Text";
import type { Props } from "./types";

const StyledCallOutBanner = styled.div<{ onClick?: Props["onClick"] }>`
${({ theme, onClick }) => css`
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
background: ${theme.orbit.paletteWhite};
border-radius: ${theme.orbit.borderRadiusSmall};
padding: ${theme.orbit.spaceMedium};
${onClick
? css`
box-shadow: ${theme.orbit.boxShadowAction};
transition: box-shadow ${theme.orbit.durationFast} ease-in-out;
cursor: pointer;
:active,
:hover {
box-shadow: ${theme.orbit.boxShadowActionActive};
outline: none;
}
border: 1px solid transparent;
`
: css`
border: 1px solid ${theme.orbit.paletteCloudNormal};
`};
${mq.largeMobile(css`
flex-direction: row;
padding: ${theme.orbit.spaceLarge};
`)};
`};
`;

StyledCallOutBanner.defaultProps = {
theme: defaultTheme,
};

const StyledIllustration = styled.div`
padding-bottom: ${({ theme }) => theme.orbit.spaceMedium};
${mq.largeMobile(css`
padding-right: ${({ theme }) => theme.orbit.spaceLarge};
padding-bottom: 0;
`)};
`;

StyledIllustration.defaultProps = {
theme: defaultTheme,
};

const CallOutBanner = ({
children,
illustration,
Expand All @@ -68,13 +19,21 @@ const CallOutBanner = ({
dataTest,
id,
}: Props) => (
<StyledCallOutBanner
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
<div
className={cx(
"orbit-call-out-banner bg-white-normal rounded-small p-md lm:flex-row lm:p-lg flex flex-col items-start justify-start border border-solid text-start",
onClick
? "shadow-action duration-fast hover:shadow-action-active active:shadow-action-active cursor-pointer border-transparent transition-shadow ease-in-out hover:outline-none active:outline-none"
: "border-cloud-normal",
)}
role="button"
onClick={onClick}
tabIndex={(onClick || Number(tabIndex)) && (Number(tabIndex) || 0)}
data-test={dataTest}
id={id}
>
{illustration && <StyledIllustration>{illustration}</StyledIllustration>}
{illustration && <div className="pb-md lm:pe-lg lm:pb-0">{illustration}</div>}
<Stack spacing="medium">
<Stack spacing="XSmall">
<Stack spacing="XXSmall">
Expand All @@ -85,7 +44,7 @@ const CallOutBanner = ({
</Stack>
{actions}
</Stack>
</StyledCallOutBanner>
</div>
);

export default CallOutBanner;
Loading