Skip to content

Comments

Refactor: Component Divider#203

Draft
b1ink0 wants to merge 1 commit intodevelopfrom
feat/update-component-divider
Draft

Refactor: Component Divider#203
b1ink0 wants to merge 1 commit intodevelopfrom
feat/update-component-divider

Conversation

@b1ink0
Copy link
Collaborator

@b1ink0 b1ink0 commented Feb 5, 2026

Description

This PR updates Divider component based on Espresso by Frappe design.

Screenshot/Screencast

Screenshot 2025-12-30 at 5 04 19 PM

Checklist

  • I have thoroughly tested this code to the best of my abilities.
  • I have reviewed the code myself before requesting a review.
  • This code is covered by unit tests to verify that it works as intended.
  • The QA of this PR is done by a member of the QA team (to be checked by QA).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Divider component to align with the Espresso by Frappe design system. The refactor removes the previous action-based implementation and introduces a more flexible slot-based approach that allows content to be positioned at start, center, or end positions within the divider.

Changes:

  • Removed the old action prop and DividerAction interface in favor of a more flexible slot render prop
  • Added support for custom padding and className props for better styling control
  • Simplified the implementation with clearer logic for horizontal/vertical orientations and slot positioning
  • Added comprehensive test coverage and Storybook examples demonstrating all features

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/frappe-ui-react/src/components/divider/types.ts Updated type definitions, removing DividerAction interface and action prop, adding slot, padding, and className props
packages/frappe-ui-react/src/components/divider/divider.tsx Complete rewrite of component implementation with simplified slot-based approach and clearer styling logic
packages/frappe-ui-react/src/components/divider/tests/divider.tsx New comprehensive test suite covering all component features including orientations, padding, slot positioning, and flexItem behavior
packages/frappe-ui-react/src/components/divider/divider.stories.tsx New Storybook stories demonstrating all component variants and use cases including Timeline example

Comment on lines +103 to +109
describe("Custom className", () => {
it("applies custom className", () => {
const { container } = render(<Divider className="custom-divider" />);
const hr = container.querySelector("hr");

expect(hr).toHaveClass("custom-divider");
});
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test only verifies className application without a slot. Consider adding a test case that verifies custom className is applied when combined with a slot, since the className is applied to different elements depending on whether a slot is present (the hr element vs the wrapping div).

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
// eslint-disable-next-line @typescript-eslint/no-explicit-any
slot?: (args?: any) => ReactNode;
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slot prop uses a function that accepts args?: any but never passes any arguments when calling it. Consider either removing the parameter from the type definition or documenting what arguments might be passed in the future. Looking at other similar components in the codebase (like autocomplete, textInput), they use the same pattern but actually pass arguments to these render functions.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-explicit-any
slot?: (args?: any) => ReactNode;
slot?: () => ReactNode;

Copilot uses AI. Check for mistakes.
position === "start" ? (isHorizontal ? "w-4" : "h-4") : "flex-1"
)}
/>
<span>{slot?.()}</span>
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slot function is called without any arguments, but the type signature suggests it could accept args?: any. This is inconsistent with the type definition. Either remove the parameter from the type definition, or if arguments are needed in the future, pass them here consistently.

Suggested change
<span>{slot?.()}</span>
<span>{slot?.(undefined)}</span>

Copilot uses AI. Check for mistakes.
Comment on lines +81 to +91
it("applies padding to wrapper with slot", () => {
const { container } = render(
<Divider slot={() => "Text"} padding={20} />
);
const wrapper = container.querySelector("div");

expect(wrapper).toHaveStyle({
paddingTop: "20px",
paddingBottom: "20px",
});
});
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests only verify padding behavior for horizontal dividers with slots (lines 81-91). There's no corresponding test for vertical dividers with slots and padding, which would verify that paddingLeft and paddingRight are applied correctly. Consider adding a test case for vertical orientation with slot and padding to ensure complete coverage of this feature combination.

Copilot uses AI. Check for mistakes.
Comment on lines +94 to +100
describe("Flex item", () => {
it("applies flex item classes when enabled", () => {
const { container } = render(<Divider flexItem />);
const hr = container.querySelector("hr");

expect(hr).toHaveClass("self-stretch", "h-auto");
});
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test only verifies flexItem behavior without a slot. Consider adding a test case that verifies the flexItem behavior when combined with a slot, as the implementation applies flexClasses differently in those two scenarios (to hr vs to the wrapping div).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant