-
-
Notifications
You must be signed in to change notification settings - Fork 53
Util classname 2 #631
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
Util classname 2 #631
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import React, { useContext } from 'react'; | ||
|
|
||
| import { clsx } from 'clsx'; | ||
| import Floater from '~/core/primitives/Floater'; | ||
| import HoverCardContext from '../contexts/HoverCardContext'; | ||
|
|
||
| const HoverCardArrow = ({ ...props }) => { | ||
| const { floatingContext, arrowRef, rootClass } = useContext(HoverCardContext); | ||
|
|
||
| return <Floater.Arrow className={`${rootClass}-arrow`} {...props} context={floatingContext} ref={arrowRef} />; | ||
| return <Floater.Arrow className={clsx(`${rootClass}-arrow`)} {...props} context={floatingContext} ref={arrowRef} />; | ||
| }; | ||
|
|
||
| export default HoverCardArrow; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||
| import React, { useEffect } from 'react'; | ||||||
| import { ProgressProps, COMPONENT_NAME } from '../Progress'; | ||||||
| import { customClassSwitcher } from '~/core'; | ||||||
|
|
||||||
| import { clsx } from 'clsx'; | ||||||
| interface IndicatorProps | ||||||
| extends Pick< | ||||||
| ProgressProps, | ||||||
|
|
@@ -28,7 +28,7 @@ export default function ProgressIndicator({ | |||||
| return ( | ||||||
| <div | ||||||
| role="progressbar" | ||||||
| className={`${rootClass}-indicator`} | ||||||
| className={clsx(`${rootClass}-indicator`)} | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Simplify the className assignment The current implementation unnecessarily wraps a template literal in -className={clsx(`${rootClass}-indicator`)}
+className={`${rootClass}-indicator`}📝 Committable suggestion
Suggested change
|
||||||
| style={{ transform: `translateX(-${maxValue - value}%)` }} | ||||||
| aria-valuenow={value} | ||||||
| aria-valuemax={maxValue} | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,11 @@ import React, { DetailedHTMLProps, InputHTMLAttributes, PropsWithChildren } from | |
| import { customClassSwitcher } from '~/core'; | ||
| import RadioPrimitive from '~/core/primitives/Radio'; | ||
| const COMPONENT_NAME = 'RadioGroup'; | ||
| import React, { DetailedHTMLProps, InputHTMLAttributes, PropsWithChildren } from 'react'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Duplicate declarations found |
||
| import { clsx } from 'clsx'; | ||
GoldGroove06 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { customClassSwitcher } from '~/core'; | ||
| import RadioPrimitive from '~/core/primitives/Radio'; | ||
| const COMPONENT_NAME = 'RadioGroup'; | ||
|
|
||
| export type RadioGroupProps = { | ||
|
|
||
|
|
@@ -14,7 +19,7 @@ const RadioGroup = ({ children, type = 'radio', className = '', customRootClass | |
| const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME); | ||
|
|
||
| return ( | ||
| <div className={`${rootClass} ${className}`} role='radiogroup'> | ||
| <div className={clsx(rootClass, className)} role='radiogroup'> | ||
| <RadioPrimitive | ||
| type={type} | ||
| {...props}> | ||
|
|
||
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.
🛠️ Refactor suggestion
Remove unnecessary clsx usage
Similar to other files, wrapping a single static variable in
clsxdoesn't provide any benefits here.Consider a more strategic approach to className management
Based on the changes across multiple files, it seems the goal is to improve className management. However,
clsxprovides the most value when:Consider using
clsxonly where these benefits are needed. For example: