-
-
Notifications
You must be signed in to change notification settings - Fork 743
Side help panel #1488
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
Merged
Merged
Side help panel #1488
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a555a0d
WIP adding a side help panel to the tasks page
samejr 358d2b7
Optionally display the shortcut before the trailing icon in the button
samejr 0579493
Updated the close icon
samejr c920bcb
WIP adding a new side help panel
samejr dc78ddd
WIP adding content to the side help panel
samejr a10edcf
WIP new side help panel content
samejr ac9bc69
Removed images as not needed any more
samejr bc57cbe
Added content to the side help menu
samejr f896644
Help panel open/closed state stored as cookie
samejr 686197a
Removed the icons from the docs and examples links
samejr 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export function SideMenuRightClosedIcon({ className }: { className?: string }) { | ||
return ( | ||
<svg | ||
className={className} | ||
width="20" | ||
height="20" | ||
viewBox="0 0 20 20" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<rect x="12" y="4" width="1" height="12" fill="currentColor" /> | ||
<rect x="2.5" y="3.5" width="15" height="13" rx="2.5" stroke="currentColor" /> | ||
</svg> | ||
); | ||
} |
177 changes: 177 additions & 0 deletions
177
apps/webapp/app/components/primitives/AnimatingArrow.tsx
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 |
---|---|---|
@@ -0,0 +1,177 @@ | ||
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/20/solid"; | ||
import { cn } from "~/utils/cn"; | ||
|
||
const variants = { | ||
small: { | ||
size: "size-[1rem]", | ||
arrowHeadRight: "group-hover:translate-x-[3px]", | ||
arrowLineRight: "h-[1.5px] w-[7px] translate-x-1 top-[calc(50%-0.5px)]", | ||
arrowHeadLeft: "group-hover:translate-x-[3px]", | ||
arrowLineLeft: "h-[1.5px] w-[7px] translate-x-1 top-[calc(50%-0.5px)]", | ||
arrowHeadTopRight: | ||
"-translate-x-0 transition group-hover:translate-x-[3px] group-hover:translate-y-[-3px]", | ||
}, | ||
medium: { | ||
size: "size-[1.1rem]", | ||
arrowHeadRight: "group-hover:translate-x-[3px]", | ||
arrowLineRight: "h-[1.5px] w-[9px] translate-x-1 top-[calc(50%-1px)]", | ||
arrowHeadLeft: "group-hover:translate-x-[-3px]", | ||
arrowLineLeft: "h-[1.5px] w-[9px] translate-x-1 top-[calc(50%-1px)]", | ||
arrowHeadTopRight: | ||
"-translate-x-0 transition group-hover:translate-x-[3px] group-hover:translate-y-[-3px]", | ||
}, | ||
large: { | ||
size: "size-6", | ||
arrowHeadRight: "group-hover:translate-x-1", | ||
arrowLineRight: "h-[2.3px] w-[12px] translate-x-[6px] top-[calc(50%-1px)]", | ||
arrowHeadLeft: "group-hover:translate-x-1", | ||
arrowLineLeft: "h-[2.3px] w-[12px] translate-x-[6px] top-[calc(50%-1px)]", | ||
arrowHeadTopRight: | ||
"-translate-x-0 transition group-hover:translate-x-[3px] group-hover:translate-y-[-3px]", | ||
}, | ||
"extra-large": { | ||
size: "size-8", | ||
arrowHeadRight: "group-hover:translate-x-1", | ||
arrowLineRight: "h-[3px] w-[16px] translate-x-[8px] top-[calc(50%-1.5px)]", | ||
arrowHeadLeft: "group-hover:translate-x-1", | ||
arrowLineLeft: "h-[3px] w-[16px] translate-x-[8px] top-[calc(50%-1.5px)]", | ||
arrowHeadTopRight: | ||
"-translate-x-0 transition group-hover:translate-x-[3px] group-hover:translate-y-[-3px]", | ||
}, | ||
}; | ||
|
||
export const themes = { | ||
dark: { | ||
textStyle: "text-background-bright", | ||
arrowLine: "bg-background-bright", | ||
}, | ||
dimmed: { | ||
textStyle: "text-text-dimmed", | ||
arrowLine: "bg-text-dimmed", | ||
}, | ||
bright: { | ||
textStyle: "text-text-bright", | ||
arrowLine: "bg-text-bright", | ||
}, | ||
primary: { | ||
textStyle: "text-text-dimmed group-hover:text-primary", | ||
arrowLine: "bg-text-dimmed group-hover:bg-primary", | ||
}, | ||
blue: { | ||
textStyle: "text-text-dimmed group-hover:text-blue-500", | ||
arrowLine: "bg-text-dimmed group-hover:bg-blue-500", | ||
}, | ||
rose: { | ||
textStyle: "text-text-dimmed group-hover:text-rose-500", | ||
arrowLine: "bg-text-dimmed group-hover:bg-rose-500", | ||
}, | ||
amber: { | ||
textStyle: "text-text-dimmed group-hover:text-amber-500", | ||
arrowLine: "bg-text-dimmed group-hover:bg-amber-500", | ||
}, | ||
apple: { | ||
textStyle: "text-text-dimmed group-hover:text-apple-500", | ||
arrowLine: "bg-text-dimmed group-hover:bg-apple-500", | ||
}, | ||
lavender: { | ||
textStyle: "text-text-dimmed group-hover:text-lavender-500", | ||
arrowLine: "bg-text-dimmed group-hover:bg-lavender-500", | ||
}, | ||
}; | ||
|
||
type Variants = keyof typeof variants; | ||
type Theme = keyof typeof themes; | ||
|
||
type AnimatingArrowProps = { | ||
className?: string; | ||
variant?: Variants; | ||
theme?: Theme; | ||
direction?: "right" | "left" | "topRight"; | ||
}; | ||
|
||
export function AnimatingArrow({ | ||
className, | ||
variant = "medium", | ||
theme = "dimmed", | ||
direction = "right", | ||
}: AnimatingArrowProps) { | ||
const variantStyles = variants[variant]; | ||
const themeStyles = themes[theme]; | ||
|
||
return ( | ||
<span className={cn("relative -mr-1 ml-1 flex", variantStyles.size, className)}> | ||
{direction === "topRight" && ( | ||
<> | ||
<svg | ||
className={cn( | ||
"absolute top-[5px] transition duration-200 ease-in-out", | ||
themeStyles.textStyle | ||
)} | ||
width="9" | ||
height="8" | ||
viewBox="0 0 9 8" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path d="M1.5 7L7.5 1" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" /> | ||
</svg> | ||
|
||
<svg | ||
className={cn( | ||
"absolute top-[5px] transition duration-300 ease-in-out", | ||
themeStyles.textStyle, | ||
variantStyles.arrowHeadTopRight | ||
)} | ||
width="9" | ||
height="8" | ||
viewBox="0 0 9 8" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path d="M1 1H7.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" /> | ||
<path d="M7.5 7L7.5 1" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" /> | ||
<path d="M1 7.5L7.5 1" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" /> | ||
</svg> | ||
</> | ||
)} | ||
{direction === "right" && ( | ||
<> | ||
<span | ||
className={cn( | ||
"absolute rounded-full opacity-0 transition duration-300 ease-in-out group-hover:opacity-100", | ||
variantStyles.arrowLineRight, | ||
themeStyles.arrowLine | ||
)} | ||
/> | ||
<ChevronRightIcon | ||
className={cn( | ||
"absolute -translate-x-0.5 transition duration-300 ease-in-out", | ||
variantStyles.arrowHeadRight, | ||
variantStyles.size, | ||
themeStyles.textStyle | ||
)} | ||
/> | ||
</> | ||
)} | ||
{direction === "left" && ( | ||
<> | ||
<span | ||
className={cn( | ||
"absolute rounded-full opacity-0 transition duration-300 ease-in-out group-hover:opacity-100", | ||
variantStyles.arrowLineLeft, | ||
themeStyles.arrowLine | ||
)} | ||
/> | ||
<ChevronLeftIcon | ||
className={cn( | ||
"absolute translate-x-0.5 transition duration-300 ease-in-out", | ||
variantStyles.arrowHeadLeft, | ||
variantStyles.size, | ||
themeStyles.textStyle | ||
)} | ||
/> | ||
</> | ||
)} | ||
</span> | ||
); | ||
} | ||
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 |
---|---|---|
|
@@ -174,6 +174,7 @@ export type ButtonContentPropsType = { | |
className?: string; | ||
shortcut?: ShortcutDefinition; | ||
variant: keyof typeof variant; | ||
shortcutPosition?: "before-trailing-icon" | "after-trailing-icon"; | ||
}; | ||
|
||
export function ButtonContent(props: ButtonContentPropsType) { | ||
|
@@ -237,6 +238,14 @@ export function ButtonContent(props: ButtonContentPropsType) { | |
<>{text}</> | ||
))} | ||
|
||
{shortcut && props.shortcutPosition === "before-trailing-icon" && ( | ||
<ShortcutKey | ||
className={cn(shortcutClassName)} | ||
shortcut={shortcut} | ||
variant={variation.shortcutVariant ?? "medium"} | ||
/> | ||
)} | ||
|
||
{TrailingIcon && | ||
(typeof TrailingIcon === "string" ? ( | ||
<NamedIcon | ||
|
@@ -258,13 +267,15 @@ export function ButtonContent(props: ButtonContentPropsType) { | |
)} | ||
/> | ||
))} | ||
{shortcut && ( | ||
<ShortcutKey | ||
className={cn(shortcutClassName)} | ||
shortcut={shortcut} | ||
variant={variation.shortcutVariant ?? "medium"} | ||
/> | ||
)} | ||
|
||
{shortcut && | ||
(!props.shortcutPosition || props.shortcutPosition === "after-trailing-icon") && ( | ||
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. It would be better to assign a default to |
||
<ShortcutKey | ||
className={cn(shortcutClassName)} | ||
shortcut={shortcut} | ||
variant={variation.shortcutVariant ?? "medium"} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
|
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.
🛠️ Refactor suggestion
Add accessibility improvements and optimize SVGs.
The component implementation could be enhanced with:
Apply these improvements:
Also consider wrapping the component in an error boundary: