Skip to content

Commit

Permalink
fix(stepper): improve step display and clean up formatting
Browse files Browse the repository at this point in the history
- Refactor step display to enhance layout and readability
- Add a new no-op constant to built-in events
- Clean up transition validation logic

(Your transition validation is so confusing, it makes find-and-replace look like a clear path)
  • Loading branch information
alonp99 committed Dec 11, 2024
1 parent 3750829 commit c9723b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,16 @@ interface Props {
export const StepperProgress = ({ currentStep, totalSteps }: Props) => {
const { t } = useTranslation();

return <span className="font-inter">{`${t('step')} ${currentStep} / ${totalSteps}`}</span>;
return (
<div className="flex items-center gap-2">
<div className="flex items-center gap-2">
<span className="text-s font-medium text-slate-600">{t('step')}</span>
<div className="flex items-center gap-2">
<span className="text-s font-medium text-blue-500">{currentStep}</span>
<span className="text-s font-medium text-slate-400">/</span>
<span className="text-s font-medium text-slate-600">{totalSteps}</span>
</div>
</div>
</div>
);
};
1 change: 1 addition & 0 deletions packages/workflow-core/src/lib/built-in-event.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const BUILT_IN_EVENT = {
UPDATE_CONTEXT: 'UPDATE_CONTEXT',
DEEP_MERGE_CONTEXT: 'DEEP_MERGE_CONTEXT',
NO_OP: 'NO_OP',
} as const;

export type BuiltInEvent = (typeof BUILT_IN_EVENT)[keyof typeof BUILT_IN_EVENT];
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export const validateTransitionOnEvent = ({

throw Error(`Unexpected transition object: ${JSON.stringify(transition)}`);
};
const targetState = getTargetState();

if (
isObject(transition) &&
Expand All @@ -89,6 +88,8 @@ export const validateTransitionOnEvent = ({
return;
}

const targetState = getTargetState();

if (!stateNames.includes(targetState)) {
throw new Error(`Invalid transition from ${currentState} to ${targetState}`);
}
Expand Down

0 comments on commit c9723b2

Please sign in to comment.