-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
275 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/orbit-components/src/Timeline/Timeline.ct-story.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import * as React from "react"; | ||
|
||
import SPACINGS_AFTER from "../common/getSpacingToken/consts"; | ||
|
||
import Timeline, { TimelineStep } from "."; | ||
|
||
const DIRECTIONS = ["row", "column"] as const; | ||
const TYPES = ["success", "warning", "critical", "info", undefined] as const; | ||
|
||
export default function TimelineStory() { | ||
return ( | ||
<div className="p-md"> | ||
{Object.values(SPACINGS_AFTER).map(spaceAfter => ( | ||
<Timeline spaceAfter={spaceAfter}> | ||
<TimelineStep label="Only one step" /> | ||
</Timeline> | ||
))} | ||
|
||
{DIRECTIONS.map(direction => ( | ||
<> | ||
<Timeline direction={direction}> | ||
<TimelineStep label="Requested" subLabel="3rd May 14:04" /> | ||
<TimelineStep | ||
label="In progress (this is quite a long sentence just to see how it plays out)" | ||
subLabel="4th May 10:25 (this is quite a long sentence just to see how it plays out)" | ||
/> | ||
<TimelineStep label="Refunded"> | ||
We’ll forward you all refunds from the carrier(s) after we receive it. | ||
</TimelineStep> | ||
</Timeline> | ||
|
||
<Timeline direction={direction}> | ||
<TimelineStep type="success" label="Requested" subLabel="3rd May 14:04"> | ||
We’ve received your request and will assign it to one of our agents. | ||
</TimelineStep> | ||
<TimelineStep active type="warning" label="In progress" subLabel="4th May 10:25"> | ||
We’ll review your request and apply for any available refund from the carrier(s) | ||
</TimelineStep> | ||
<TimelineStep type="critical" label="Waiting for the carrier" subLabel="5th May 14:04"> | ||
We’ll wait for the carrier(s) to send us the refund and contact them again if | ||
necessary. | ||
</TimelineStep> | ||
<TimelineStep type="info" label="Carrier is refunding" subLabel="6th May 14:04"> | ||
The carrier has sent us a refund. There might be more depending on their policy. | ||
</TimelineStep> | ||
<TimelineStep label="Refunded" subLabel="7th May 10:25"> | ||
We’ll forward you all refunds from the carrier(s) after we receive it. | ||
</TimelineStep> | ||
</Timeline> | ||
|
||
<Timeline direction={direction}> | ||
{TYPES.map(type => ( | ||
<TimelineStep type={type} label="Yay" /> | ||
))} | ||
</Timeline> | ||
|
||
<Timeline direction={direction}> | ||
<TimelineStep label="Label only" /> | ||
<TimelineStep label="Label" subLabel="Sublabel" /> | ||
<TimelineStep label="Label">Children</TimelineStep> | ||
<TimelineStep label="Label" subLabel="Sublabel"> | ||
Children | ||
</TimelineStep> | ||
</Timeline> | ||
</> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 TimelineStory from "./Timeline.ct-story"; | ||
import RenderInRtl from "../utils/rtl/RenderInRtl"; | ||
|
||
test.describe("visual Timeline", () => { | ||
test("default", async ({ mount }) => { | ||
const component = await mount(<TimelineStory />); | ||
|
||
await expect(component).toHaveScreenshot(); | ||
}); | ||
|
||
test("rtl", async ({ mount }) => { | ||
const component = await mount( | ||
<RenderInRtl> | ||
<TimelineStory /> | ||
</RenderInRtl>, | ||
); | ||
|
||
await expect(component).toHaveScreenshot(); | ||
}); | ||
}); |
Binary file added
BIN
+235 KB
...Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Desktop-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+218 KB
.../Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Desktop-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+237 KB
...ne/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Large-Desktop-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+220 KB
...ine/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Large-Desktop-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+249 KB
...ine/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Large-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+177 KB
...line/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Large-Mobile-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+229 KB
...ne/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Medium-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+156 KB
...ine/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Medium-Mobile-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+192 KB
...ine/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Small-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+134 KB
...line/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Small-Mobile-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+256 KB
.../Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Tablet-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+176 KB
...c/Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-default-1-Tablet-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+233 KB
...src/Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Desktop-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+219 KB
.../src/Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Desktop-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+235 KB
...meline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Large-Desktop-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+221 KB
...imeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Large-Desktop-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+249 KB
...imeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Large-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+176 KB
...Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Large-Mobile-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+231 KB
...meline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Medium-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+156 KB
...imeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Medium-Mobile-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+190 KB
...imeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Small-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+134 KB
...Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Small-Mobile-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+257 KB
.../src/Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Tablet-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+175 KB
...s/src/Timeline/Timeline.ct.tsx-snapshots/visual-Timeline-rtl-1-Tablet-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions
72
packages/orbit-components/src/Timeline/TimelineStep/components/ProgressLine.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import * as React from "react"; | ||
import cx from "clsx"; | ||
|
||
import type { Type } from "../types"; | ||
import useTheme from "../../../hooks/useTheme"; | ||
import type { Theme } from "../../../defaultTheme"; | ||
|
||
export const getStatusColor = (theme: Theme, type?: Type): string => { | ||
const colors = { | ||
success: theme.orbit.colorTextSuccess, | ||
warning: theme.orbit.colorTextWarning, | ||
critical: theme.orbit.colorTextCritical, | ||
info: theme.orbit.colorTextInfo, | ||
}; | ||
|
||
return type ? colors[type] : theme.orbit.paletteCloudNormalHover; | ||
}; | ||
|
||
interface Props { | ||
desktop?: boolean; | ||
last?: boolean; | ||
nextStatus?: Type; | ||
prevStatus?: Type; | ||
status?: Type; | ||
} | ||
|
||
const ProgressLine = ({ desktop, status, nextStatus, last, prevStatus }: Props) => { | ||
const theme = useTheme(); | ||
|
||
const getBorderStyle = (): React.CSSProperties => { | ||
if (desktop) { | ||
if (status && !nextStatus && !last) { | ||
return { | ||
borderImageSlice: 1, | ||
borderImageSource: `linear-gradient(to right, ${getStatusColor( | ||
theme, | ||
prevStatus, | ||
)}, ${getStatusColor(theme, status)})`, | ||
}; | ||
} | ||
} | ||
|
||
if (status && !nextStatus && !last) { | ||
return { | ||
borderImageSlice: 1, | ||
borderImageSource: `linear-gradient(to bottom, ${getStatusColor( | ||
theme, | ||
prevStatus, | ||
)}, ${getStatusColor(theme, status)})`, | ||
}; | ||
} | ||
|
||
return { | ||
borderColor: getStatusColor(theme, status), | ||
}; | ||
}; | ||
|
||
return ( | ||
<span | ||
className={cx( | ||
"border", | ||
status ? "border-solid" : "border-dashed", | ||
desktop | ||
? "w-1/2" | ||
: "absolute top-[15px] h-[calc(100%+theme(spacing.xxxs))] ltr:left-[11px] rtl:right-[11px]", | ||
)} | ||
style={getBorderStyle()} | ||
/> | ||
); | ||
}; | ||
|
||
export default ProgressLine; |
16 changes: 16 additions & 0 deletions
16
packages/orbit-components/src/Timeline/TimelineStep/components/TextWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from "react"; | ||
import cx from "clsx"; | ||
|
||
type Props = React.PropsWithChildren<{ | ||
active?: boolean; | ||
}>; | ||
|
||
const TextWrapper = ({ active, children }: Props) => { | ||
return ( | ||
<div className={cx("de:min-h-md", active ? "[&>p]:text-ink-dark" : "[&>p]:text-ink-light")}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default TextWrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.