import * as React from "react"; import styled from "styled-components"; import css, { SystemStyleObject } from "@styled-system/css"; import { CommonStyleProps, commonStyle } from "./system/unions"; import { sequence } from "./util"; export type ContinuousProgressBarProps = CommonStyleProps & { percentage?: number; }; type SegmentProps = { active: boolean; }; const segmentStyle = ({ active }: SegmentProps) => css({ flexGrow: 1, backgroundColor: active ? "blue" : "transparent", content: "' '", height: "100%", borderRight: "1px solid", borderRightColor: "white", } as SystemStyleObject); const Segment = styled.div>(segmentStyle); const backgroundStyle = () => css({ display: "flex", width: "100%", height: 1, backgroundColor: "lightGray", borderRadius: 3, overflow: "hidden", "& :last-child": { borderRightColor: "transparent", }, } as SystemStyleObject); const Background = styled.div>( backgroundStyle, ...commonStyle ); export type SegmentedProgressBarProps = { segments?: number; current?: number; }; export const SegmentedProgressBar = ({ segments = 1, current = 0, ...props }: SegmentedProgressBarProps) => { return ( {sequence(segments).map((_, index: number) => ( ))} ); }; Background.displayName = "Background"; Segment.displayName = "Segment"; SegmentedProgressBar.displayName = "SegmentedProgressBar";