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

Stepper fixes: font, margins, and visible outline #735

Merged
merged 3 commits into from
Oct 26, 2023
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
5 changes: 5 additions & 0 deletions .changeset/hot-adults-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@easypost/easy-ui": minor
---

fix Stepper: Stepper should have a single font style and support a visible outline
4 changes: 3 additions & 1 deletion easy-ui-react/src/Stepper/Step.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
border-left-width: design-token("shape.border_width.1");
border-left-style: solid;
border-color: component-token("step", "color-separator");
margin-left: design-token("space.1");
margin-left: calc(
#{design-token("space.1")} - #{design-token("space.0.125")}
);
}
45 changes: 22 additions & 23 deletions easy-ui-react/src/Stepper/StepButton.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use "../styles/common" as *;
@use "../styles/unstyled";

.containerHorizontal {
@include component-token("step-button", "max-height", 56px);
Expand Down Expand Up @@ -73,13 +74,25 @@
);
}

.statusComplete,
.statusIncomplete {
@include font-style("body1");
.StepButton {
@include font-style("subtitle1");
@include unstyled.button;
display: flex;
align-items: center;
gap: design-token("space.1");
outline: none;
cursor: pointer;

&:disabled {
cursor: not-allowed;
}
}

.focusVisible {
@include native-focus-ring;
}

.statusComplete {
@include component-token("step-button", "orientation-vertical-margin", -2px);
color: component-token("step-button", "color-complete");
}

Expand All @@ -88,28 +101,11 @@
}

.statusActive {
@include font-style("subtitle1");
color: component-token("step-button", "color-active");
}

.StepButton {
padding: 0;
border: 0;
margin: 0;
background: none;
outline: none;
display: flex;
align-items: center;
gap: design-token("space.1");
cursor: pointer;

&:disabled {
cursor: not-allowed;
}
}

.orientationVertical {
margin-left: component-token("step-button", "orientation-margin");
margin-left: calc(-1 * #{design-token("space.0.25")});
}

.indicatorHorizontal {
Expand All @@ -120,6 +116,10 @@
@include component-token("step-button", "indicator-size", 16px);
}

.indicatorContainer {
padding: design-token("space.0.25");
}

.indicatorActive {
background-color: component-token("step-button", "active-background");
}
Expand All @@ -130,7 +130,6 @@

.indicatorIncomplete {
border: 1px solid component-token("step-button", "incomplete-border");
margin: calc(#{design-token("space.0.5")} - 1px) design-token("space.0");
}

.indicator {
Expand Down
22 changes: 13 additions & 9 deletions easy-ui-react/src/Stepper/StepButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactNode } from "react";
import CheckCircle from "@easypost/easy-ui-icons/CheckCircle";
import { AriaButtonProps } from "react-aria";
import { AriaButtonProps, useFocusRing, mergeProps } from "react-aria";
import { useInternalStepperContext } from "./StepperContext";
import { UnstyledButton } from "../UnstyledButton";
import { classNames, variationName } from "../utilities/css";
Expand Down Expand Up @@ -34,6 +34,7 @@ export type StepButtonProps = AriaButtonProps & {
export function StepButton(props: StepButtonProps) {
const { status, isDisabled, children, onPress, ...restProps } = props;
const { color, orientation } = useInternalStepperContext();
const { isFocusVisible, focusProps } = useFocusRing();

return (
<div
Expand All @@ -43,14 +44,15 @@ export function StepButton(props: StepButtonProps) {
)}
>
<UnstyledButton
{...restProps}
{...mergeProps(focusProps, restProps)}
onPress={onPress}
isDisabled={isDisabled}
className={classNames(
styles.StepButton,
styles[variationName("status", status)],
styles[variationName("color", color)],
styles[variationName("orientation", orientation)],
isFocusVisible && styles.focusVisible,
)}
>
{status === "complete" ? (
Expand All @@ -59,13 +61,15 @@ export function StepButton(props: StepButtonProps) {
size={orientation === "horizontal" ? "md" : "sm"}
/>
) : (
<div
className={classNames(
styles.indicator,
styles[variationName("indicator", orientation)],
styles[variationName("indicator", status)],
)}
/>
<div className={classNames(styles.indicatorContainer)}>
<div
className={classNames(
styles.indicator,
styles[variationName("indicator", orientation)],
styles[variationName("indicator", status)],
)}
/>
</div>
)}
<span
className={classNames(styles[variationName("text", orientation)])}
Expand Down