-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Editor sanding #2996
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
Draft
drfarrell
wants to merge
7
commits into
main
Choose a base branch
from
editor-sanding
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.
Draft
Editor sanding #2996
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
34e835b
Project breadcrumb + loading text
drfarrell e7398d5
Improve AI scroll arrow styling + Loading messages
drfarrell e42007d
Styling, remove mobile frame + select branch on start
drfarrell de61fa7
Padding / margin / border multi-side
drfarrell fd7c1b2
merge main
Kitenite d40eece
merge main
Kitenite 6ef4dd0
merge main
Kitenite 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,31 @@ export const Margin = observer(() => { | |
|
|
||
| const [activeTab, setActiveTab] = useState<MarginTab>(areAllMarginsEqual ? MarginTab.ALL : MarginTab.INDIVIDUAL); | ||
|
|
||
| // Track if user is actively interacting with the input | ||
|
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. Similar to the border component, the margin component duplicates isUserInteracting logic. Consider refactoring this into a shared hook. |
||
| const [isUserInteracting, setIsUserInteracting] = useState(false); | ||
|
|
||
| // Determine if we should show "Mixed" in the input when on "All sides" tab | ||
| const shouldShowMixed = activeTab === MarginTab.ALL && !areAllMarginsEqual && !isUserInteracting; | ||
|
|
||
| // Custom onChange handler that tracks user interaction | ||
| const handleMarginChange = (value: number) => { | ||
| setIsUserInteracting(true); | ||
| handleBoxChange('margin', value.toString()); | ||
| }; | ||
|
|
||
| // Reset interaction state when switching tabs or closing dropdown | ||
| const handleTabChange = (tab: MarginTab) => { | ||
| setActiveTab(tab); | ||
| setIsUserInteracting(false); | ||
| }; | ||
|
|
||
| const handleOpenChange = (open: boolean) => { | ||
| onOpenChange(open); | ||
| if (!open) { | ||
| setIsUserInteracting(false); | ||
| } | ||
| }; | ||
|
|
||
| const getMarginIcon = () => { | ||
| const margins = { | ||
| top: boxState.marginTop.num ?? 0, | ||
|
|
@@ -148,7 +173,7 @@ export const Margin = observer(() => { | |
| const marginValue = getMarginDisplay(); | ||
|
|
||
| return ( | ||
| <DropdownMenu open={isOpen} onOpenChange={onOpenChange} modal={false}> | ||
| <DropdownMenu open={isOpen} onOpenChange={handleOpenChange} modal={false}> | ||
| <HoverOnlyTooltip content="Margin" side="bottom" className="mt-1" hideArrow disabled={isOpen}> | ||
| <DropdownMenuTrigger asChild> | ||
| <ToolbarButton | ||
|
|
@@ -168,16 +193,16 @@ export const Margin = observer(() => { | |
| > | ||
| <div className="mb-3 flex items-center gap-2"> | ||
| <button | ||
| onClick={() => setActiveTab(MarginTab.ALL)} | ||
| onClick={() => handleTabChange(MarginTab.ALL)} | ||
| className={`flex-1 cursor-pointer rounded-md px-4 py-1.5 text-sm transition-colors ${activeTab === MarginTab.ALL | ||
| ? "bg-background-active/50 text-foreground-primary" | ||
| : "text-muted-foreground hover:bg-background-tertiary/20 hover:text-foreground-hover" | ||
| }`} | ||
| > | ||
| {areAllMarginsEqual ? "All sides" : "Mixed"} | ||
| All sides | ||
| </button> | ||
| <button | ||
| onClick={() => setActiveTab(MarginTab.INDIVIDUAL)} | ||
| onClick={() => handleTabChange(MarginTab.INDIVIDUAL)} | ||
| className={`flex-1 cursor-pointer rounded-md px-4 py-1.5 text-sm transition-colors ${activeTab === MarginTab.INDIVIDUAL | ||
| ? "bg-background-active/50 text-foreground-primary" | ||
| : "text-muted-foreground hover:bg-background-tertiary/20 hover:text-foreground-hover" | ||
|
|
@@ -188,10 +213,11 @@ export const Margin = observer(() => { | |
| </div> | ||
| {activeTab === MarginTab.ALL ? ( | ||
| <InputRange | ||
| value={boxState.margin.num ?? 0} | ||
| onChange={(value) => handleBoxChange('margin', value.toString())} | ||
| value={shouldShowMixed ? 0 : (boxState.margin.num ?? 0)} | ||
| onChange={handleMarginChange} | ||
| unit={boxState.margin.unit} | ||
| onUnitChange={(unit) => handleUnitChange('margin', unit)} | ||
| displayValue={shouldShowMixed ? 'Mixed' : undefined} | ||
| /> | ||
| ) : ( | ||
| <SpacingInputs | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
This is the start of the multi-side / all side dropdown adjustment