-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: implement 7 UI fixes for editor interface (#2488) #2489
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
Open
devin-ai-integration
wants to merge
9
commits into
main
Choose a base branch
from
devin/1752884104-editor-ui-sanding-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+95
−66
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
da0f24c
fix: implement 7 UI fixes for editor interface
devin-ai-integration[bot] f105a5d
feat: add custom increments to padding/margin sliders and fix flexbox…
devin-ai-integration[bot] b07006e
fix: use consolidated CSS properties for better Tailwind class genera…
devin-ai-integration[bot] 8c96e6c
Fixed arrow in the wrong spot
drfarrell 1e24a9c
fix: resolve slider sync and tooltip arrow issues
devin-ai-integration[bot] 1453c98
fix: improve slider synchronization with immediate state updates
devin-ai-integration[bot] 2fbbbe7
fix: resolve slider synchronization and race condition issues
devin-ai-integration[bot] 1989282
fix: remove debouncing for instant slider synchronization
devin-ai-integration[bot] d88850b
fix: resolve CI failure and slider jumping behavior
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,14 +15,29 @@ interface InputRangeProps { | |
unit?: string; | ||
onChange?: (value: number) => void; | ||
onUnitChange?: (unit: string) => void; | ||
customIncrements?: number[]; | ||
useTailwindClasses?: boolean; | ||
} | ||
|
||
export const STANDARD_INCREMENTS = [0, 0.25, 0.5, 0.75, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; | ||
|
||
const TAILWIND_RADIUS_MAP: Record<number, string> = { | ||
2: 'rounded-xs', | ||
4: 'rounded-sm', | ||
6: 'rounded-md', | ||
8: 'rounded-lg', | ||
12: 'rounded-xl', | ||
16: 'rounded-2xl', | ||
}; | ||
|
||
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. InputRange now supports customIncrements and snapping, which is good. Note that the useTailwindClasses prop is accepted but TAILWIND_RADIUS_MAP isn’t used; if the intent is to map certain values to Tailwind classes, additional logic is needed. |
||
export const InputRange = ({ | ||
value, | ||
icon, | ||
unit = 'px', | ||
onChange, | ||
onUnitChange, | ||
customIncrements, | ||
useTailwindClasses = false, | ||
}: InputRangeProps) => { | ||
const [localValue, setLocalValue] = useState(String(value)); | ||
const rangeRef = useRef<HTMLInputElement>(null); | ||
|
@@ -88,11 +103,21 @@ export const InputRange = ({ | |
} | ||
}; | ||
|
||
const findClosestIncrement = (targetValue: number): number => { | ||
if (!customIncrements) return targetValue; | ||
|
||
return customIncrements.reduce((closest, current) => { | ||
return Math.abs(current - targetValue) < Math.abs(closest - targetValue) ? current : closest; | ||
}); | ||
}; | ||
|
||
const handleMouseMove = (e: MouseEvent) => { | ||
if (isDragging && rangeRef.current) { | ||
const rect = rangeRef.current.getBoundingClientRect(); | ||
const percentage = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)); | ||
const newValue = Math.round(percentage * 500); | ||
const maxValue = customIncrements ? Math.max(...customIncrements) : 500; | ||
const rawValue = percentage * maxValue; | ||
const newValue = customIncrements ? findClosestIncrement(rawValue) : Math.round(rawValue); | ||
setLocalValue(String(newValue)); | ||
debouncedOnChange(newValue); | ||
} | ||
|
@@ -104,17 +129,21 @@ export const InputRange = ({ | |
document.removeEventListener('mouseup', handleMouseUp); | ||
}; | ||
|
||
const maxValue = customIncrements ? Math.max(...customIncrements) : 500; | ||
const currentValue = customIncrements ? findClosestIncrement(Number(localValue)) : Number(localValue); | ||
|
||
return ( | ||
<div className="flex items-center gap-2"> | ||
<div className="flex-1 flex items-center gap-2"> | ||
<input | ||
ref={rangeRef} | ||
type="range" | ||
min="0" | ||
max="500" | ||
value={Number(localValue)} | ||
max={maxValue} | ||
value={currentValue} | ||
onChange={(e) => { | ||
const newValue = Number(e.target.value); | ||
const rawValue = Number(e.target.value); | ||
const newValue = customIncrements ? findClosestIncrement(rawValue) : rawValue; | ||
setLocalValue(String(newValue)); | ||
debouncedOnChange(newValue); | ||
}} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
TAILWIND_RADIUS_MAP is defined but not used; implement mapping logic when useTailwindClasses is true.