-
Notifications
You must be signed in to change notification settings - Fork 83
Add Clear button for non required args #7775
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
Changes from all commits
be925d4
42cb1e8
843107b
96b2734
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 |
---|---|---|
|
@@ -18,7 +18,11 @@ | |
function CommandBarHeaderFooter({ | ||
children, | ||
stepBack, | ||
}: React.PropsWithChildren<object> & { stepBack: () => void }) { | ||
clear, | ||
}: React.PropsWithChildren<object> & { | ||
stepBack: () => void | ||
clear?: () => void | ||
}) { | ||
const commandBarState = useCommandBarState() | ||
const { | ||
context: { selectedCommand, currentArgument, argumentsToSubmit }, | ||
|
@@ -38,6 +42,10 @@ | |
}, [selectedCommand]) | ||
const isReviewing = commandBarState.matches('Review') | ||
const [showShortcuts, setShowShortcuts] = useState(false) | ||
const isCurrentArgRequired = | ||
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. Nice, I support this, this was the only thing I was curious about. Good thinking 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. Dope! Thank you. Added the pw test steps, this is ready to go now |
||
typeof currentArgument?.required === 'function' | ||
? currentArgument.required(commandBarState.context) | ||
: currentArgument?.required | ||
|
||
useHotkeys( | ||
'alt', | ||
|
@@ -221,8 +229,10 @@ | |
</div> | ||
<CommandBarDivider /> | ||
{children} | ||
<div className="px-4 pb-2 flex justify-between items-center gap-2"> | ||
<div className="px-4 pb-2 flex items-center gap-2"> | ||
<StepBackButton stepBack={stepBack} /> | ||
{!isCurrentArgRequired && clear && <ClearButton clear={clear} />} | ||
<div className="flex-grow"></div> | ||
{isReviewing ? ( | ||
<ReviewingButton | ||
bgClassName={ | ||
|
@@ -334,4 +344,30 @@ | |
) | ||
} | ||
|
||
function ClearButton({ | ||
bgClassName, | ||
iconClassName, | ||
clear, | ||
}: ButtonProps & { clear: () => void }) { | ||
return ( | ||
<ActionButton | ||
Element="button" | ||
type="button" | ||
form="arg-form" | ||
className={`w-fit !p-0 rounded-sm hover:brightness-110 hover:shadow focus:outline-current bg-chalkboard-20/50 dark:bg-chalkboard-80/50 border-chalkboard-20 dark:border-chalkboard-80 ${bgClassName}`} | ||
tabIndex={0} | ||
data-testid="command-bar-clear-non-required-button" | ||
iconStart={{ | ||
icon: 'trash', | ||
bgClassName: `p-1 rounded-sm bg-chalkboard-20/50 dark:bg-chalkboard-80/50 ${bgClassName}`, | ||
iconClassName: `${iconClassName}`, | ||
}} | ||
onClick={clear} | ||
> | ||
<span className={`pr-2 ${iconClassName}`}>Clear</span> | ||
Check warning on line 367 in src/components/CommandBar/CommandBarHeaderFooter.tsx
|
||
<Tooltip position="bottom">Clear</Tooltip> | ||
Check warning on line 368 in src/components/CommandBar/CommandBarHeaderFooter.tsx
|
||
</ActionButton> | ||
) | ||
} | ||
|
||
export default CommandBarHeaderFooter |
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.
@pierremtb I think you've done this above and the
TODO
can be removed.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.
https://github.com/KittyCAD/modeling-app/pull/7814/files you're right ty!