-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(18794): add two-directional feature to toggle component #94
feat(18794): add two-directional feature to toggle component #94
Conversation
WalkthroughThe recent updates introduce a new SVG icon component Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
♻️ PR Preview 559c05f has been successfully destroyed since this PR has been closed. 🤖 By surge-preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range comments (2)
packages/ui-kit/src/Toggler/index.tsx (1)
Line range hint
8-32
: Consider using a self-closing tag for thetoggle
div.30a31 > <div className={s.toggle} />For elements without children, like the
toggle
div, using self-closing tags can improve the readability and cleanliness of the code.Tools
Biome
[error] 31-31: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
packages/ui-kit/src/Toggler/Toggler.fixture.tsx (1)
Line range hint
19-31
: Refactor the state update logic for clarity.23c23 < setState((state) => ((state[e.target.id] = e.target.checked), { ...state })); --- > setState((prevState) => ({ ...prevState, [e.target.id]: e.target.checked }));The current state update logic uses the comma operator, which can be confusing and obscure side effects. It's better to use a more straightforward approach for updating the state.
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (5)
- packages/default-icons/src/figma-icons/FavAdded16.tsx (1 hunks)
- packages/default-icons/src/figma-icons/index.ts (1 hunks)
- packages/ui-kit/src/Toggler/Toggler.fixture.tsx (2 hunks)
- packages/ui-kit/src/Toggler/index.tsx (2 hunks)
- packages/ui-kit/src/Toggler/style.module.css (1 hunks)
Additional context used
Biome
packages/default-icons/src/figma-icons/FavAdded16.tsx
[error] 4-4: Alternative text title element cannot be empty (lint/a11y/noSvgWithoutTitle)
For accessibility purposes, SVGs should have an alternative text, provided via title element. If the svg element has role="img", you should add the aria-label or aria-labelledby attribute.
packages/ui-kit/src/Toggler/index.tsx
[error] 31-31: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
packages/ui-kit/src/Toggler/Toggler.fixture.tsx
[error] 23-23: The assignment should not be in an expression. (lint/suspicious/noAssignInExpressions)
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.
[error] 23-23: The comma operator is disallowed. (lint/style/noCommaOperator)
Its use is often confusing and obscures side effects.
Additional comments not posted (5)
packages/default-icons/src/figma-icons/FavAdded16.tsx (1)
14-16
: Good use ofmemo
for performance optimization.packages/ui-kit/src/Toggler/index.tsx (1)
18-32
: Well-implemented newleftLabel
property.Tools
Biome
[error] 31-31: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
packages/ui-kit/src/Toggler/Toggler.fixture.tsx (1)
Line range hint
19-31
: Good addition of thepayment
state variable.packages/ui-kit/src/Toggler/style.module.css (1)
60-75
: The new.twoLabels
class is well-defined and enhances the component styling.packages/default-icons/src/figma-icons/index.ts (1)
183-183
: Export ofFavAdded16
correctly follows existing module patterns.
Please rename the PR according to Conventional Commits naming + give it more informative name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (4)
- packages/ui-kit/src/Toggler/Toggler.fixture.style.module.css (1 hunks)
- packages/ui-kit/src/Toggler/Toggler.fixture.tsx (3 hunks)
- packages/ui-kit/src/Toggler/index.tsx (2 hunks)
- packages/ui-kit/src/Toggler/style.module.css (1 hunks)
Additional context used
Biome
packages/ui-kit/src/Toggler/index.tsx
[error] 42-42: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
packages/ui-kit/src/Toggler/Toggler.fixture.tsx
[error] 29-29: The assignment should not be in an expression. (lint/suspicious/noAssignInExpressions)
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.
[error] 29-29: The comma operator is disallowed. (lint/style/noCommaOperator)
Its use is often confusing and obscures side effects.
Additional comments not posted (3)
packages/ui-kit/src/Toggler/index.tsx (1)
8-13
: The addition ofleftLabel
and related class handling enhances the component's flexibility. EnsureclassName
prop is appropriately used whenleftLabel
is rendered.packages/ui-kit/src/Toggler/style.module.css (1)
60-65
: The new.twoDirectional
class provides specific styling for toggles with dual directions. Ensure consistency in design when applying these styles across different components.packages/ui-kit/src/Toggler/Toggler.fixture.tsx (1)
20-26
: The addition ofpayment
state and associated classes enhances the interactive capabilities of this fixture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (2)
- packages/ui-kit/src/Toggler/Toggler.fixture.tsx (2 hunks)
- packages/ui-kit/src/Toggler/index.tsx (2 hunks)
Additional context used
Biome
packages/ui-kit/src/Toggler/index.tsx
[error] 42-42: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
Additional comments not posted (3)
packages/ui-kit/src/Toggler/index.tsx (1)
8-13
: Consider renamingoffValueLabel
to reflect its purpose more clearly, such asnegativeLabel
oroffLabel
.
: This is a repeat of a previous comment by albaranau.packages/ui-kit/src/Toggler/Toggler.fixture.tsx (2)
20-28
: The state management and event handling in theonChange
function are implemented correctly. However, consider renamingisAnnualPayment
to a more descriptive name likeannualPaymentMode
for clarity.
: This is a repeat of a previous comment by albaranau.
36-46
: The implementation of theToggler
component for theisAnnualPayment
toggle is correct. Ensure that the CSS classes used (s.label
,s.active
) are well-defined in the associated CSS module to maintain style consistency.
<label | ||
className={cn( | ||
s.root, | ||
{ [s.checked]: on, [s.disabled]: native.disabled, [s.twoDirectional]: offValueLabel }, | ||
className, | ||
)} | ||
> | ||
<input id={id} className={s.hidden} type="checkbox" {...native} checked={on} /> | ||
{offValueLabel && ( | ||
<div className={cn(s.label, classes?.label, { [classes?.activeLabel || '']: !on })}>{offValueLabel}</div> | ||
)} | ||
<div className={s.toggle}></div> | ||
<div className={s.label}>{label}</div> | ||
<div className={cn(s.label, classes?.label, { [classes?.activeLabel || '']: on })}>{label}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the <div className={s.toggle}></div>
is self-closing to adhere to JSX best practices.
- <div className={s.toggle}></div>
+ <div className={s.toggle} />
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<label | |
className={cn( | |
s.root, | |
{ [s.checked]: on, [s.disabled]: native.disabled, [s.twoDirectional]: offValueLabel }, | |
className, | |
)} | |
> | |
<input id={id} className={s.hidden} type="checkbox" {...native} checked={on} /> | |
{offValueLabel && ( | |
<div className={cn(s.label, classes?.label, { [classes?.activeLabel || '']: !on })}>{offValueLabel}</div> | |
)} | |
<div className={s.toggle}></div> | |
<div className={s.label}>{label}</div> | |
<div className={cn(s.label, classes?.label, { [classes?.activeLabel || '']: on })}>{label}</div> | |
<label | |
className={cn( | |
s.root, | |
{ [s.checked]: on, [s.disabled]: native.disabled, [s.twoDirectional]: offValueLabel }, | |
className, | |
)} | |
> | |
<input id={id} className={s.hidden} type="checkbox" {...native} checked={on} /> | |
{offValueLabel && ( | |
<div className={cn(s.label, classes?.label, { [classes?.activeLabel || '']: !on })}>{offValueLabel}</div> | |
)} | |
<div className={s.toggle} /> | |
<div className={cn(s.label, classes?.label, { [classes?.activeLabel || '']: on })}>{label}</div> |
Tools
Biome
[error] 42-42: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)
Unsafe fix: Use a SelfClosingElement instead
https://kontur.fibery.io/Tasks/Team/Insights-6/Tasks-by-User-Stories-current-and-next-sprint-3939#Task/Improve-ui-kit-for-pricing-page-needs-18794
Summary by CodeRabbit
New Features
FavAdded16
icon component.Enhancements
Toggler
component to handle payment frequency selection with new labels for "Annually" and "Monthly."Toggler
component for improved label and style customization.Style
.twoDirectional
for enhanced styling of toggle elements.