-
Notifications
You must be signed in to change notification settings - Fork 0
Feat link out #9
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
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
baa1ed6
feat: open in new tab option
michaelbarone 818e1a2
docs(url-management): update documentation for open in new tab feature
michaelbarone d266e15
fix: top menu button styling
michaelbarone 79d4ffd
docs: added future task
michaelbarone 88ed741
fix: build type issues and removed anys as suggested
michaelbarone 0ea540a
fix: type and build fix
michaelbarone 702bcbf
fix: ensure localhost settings works for external links
michaelbarone 5809263
fix: improved external url icon for top menu bar
michaelbarone 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| import { Url } from "@/app/lib/types"; | ||
| import OpenInNewIcon from "@mui/icons-material/OpenInNew"; | ||
| import { | ||
| Box, | ||
| Button, | ||
| ListItemButton, | ||
| ListItemText, | ||
| Theme, | ||
| Tooltip, | ||
| useMediaQuery, | ||
| } from "@mui/material"; | ||
| import { memo, useMemo } from "react"; | ||
|
|
||
| interface ExternalUrlItemProps { | ||
| url: Url; | ||
| tooltipText: string; | ||
| menuPosition: "top" | "side"; | ||
| theme: Theme; | ||
| } | ||
|
|
||
| const ExternalUrlItem = memo(function ExternalUrlItem({ | ||
| url, | ||
| tooltipText, | ||
| menuPosition, | ||
| theme, | ||
| }: ExternalUrlItemProps) { | ||
| // Simple click handler that opens the URL in a new tab | ||
| const handleClick = () => { | ||
| window.open(url.url, "_blank", "noopener,noreferrer"); | ||
| }; | ||
|
|
||
| // Check if we're on mobile | ||
| const isMobile = useMediaQuery(theme.breakpoints.down("md")); | ||
|
|
||
| // For top menu, use Button-based styling | ||
| if (menuPosition === "top") { | ||
| const styles = useMemo( | ||
| () => ({ | ||
| iconStyles: { | ||
| width: 24, | ||
| height: 24, | ||
| objectFit: "contain" as const, | ||
| marginRight: url.title && url.iconPath ? 1 : 0, | ||
| }, | ||
| boxStyles: { | ||
| position: "relative" as const, | ||
| display: "flex", | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| width: "100%", | ||
| }, | ||
| buttonStyles: { | ||
| height: 50, // Fixed height for consistency | ||
| minHeight: 50, // Ensure minimum height is the same | ||
| minWidth: 50, | ||
| lineHeight: "36px", // Match line height to button height | ||
| px: 0, // Slightly more horizontal padding | ||
| mx: 0.5, | ||
| textTransform: "none", | ||
| borderRadius: 1, | ||
| color: theme.palette.text.primary, | ||
| fontWeight: "normal", | ||
| backgroundColor: "transparent", | ||
| position: "relative", | ||
| overflow: "hidden", | ||
| pb: 0, | ||
| "&:hover": { | ||
| opacity: 0.8, | ||
| }, | ||
| }, | ||
| containerStyles: { | ||
| display: "inline-block", | ||
| position: "relative" as const, | ||
| }, | ||
| externalIconStyles: { | ||
| position: "relative" as const, | ||
| marginLeft: 1, | ||
| fontSize: 14, | ||
| color: theme.palette.text.secondary, | ||
| opacity: 0.7, | ||
| padding: "1px", | ||
| }, | ||
| titleStyles: { | ||
| display: "flex", | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| fontSize: "0.875rem", | ||
| whiteSpace: "nowrap" as const, | ||
| overflow: "hidden" as const, | ||
| textOverflow: "ellipsis" as const, | ||
| maxWidth: 100, | ||
| }, | ||
| }), | ||
| [theme.palette.text.primary, theme.palette.text.secondary, url.title, url.iconPath], | ||
| ); | ||
|
|
||
| return ( | ||
| <Box sx={styles.containerStyles}> | ||
| <Tooltip title={tooltipText} placement="bottom" enterDelay={700}> | ||
| <Button | ||
| onClick={handleClick} | ||
| sx={styles.buttonStyles} | ||
| disableRipple={false} | ||
| aria-label={`${url.title} (opens in new tab)`} | ||
| > | ||
| <Box sx={styles.boxStyles}> | ||
| {url.iconPath ? ( | ||
| <> | ||
| <Box component="img" src={url.iconPath} alt="" sx={styles.iconStyles} /> | ||
| {url.title && <Box sx={styles.titleStyles}>{url.title}</Box>} | ||
| </> | ||
| ) : ( | ||
| <Box sx={styles.titleStyles}>{url.title}</Box> | ||
| )} | ||
| <OpenInNewIcon sx={styles.externalIconStyles} fontSize="small" /> | ||
| </Box> | ||
| </Button> | ||
| </Tooltip> | ||
| </Box> | ||
| ); | ||
| } | ||
|
|
||
| // For side menu, use ListItemButton-based styling to match UrlItem | ||
| return ( | ||
| <ListItemButton | ||
| onClick={handleClick} | ||
| sx={{ | ||
| pl: isMobile ? 3 : 4, | ||
| position: "relative", | ||
| borderRight: 0, | ||
| display: "flex", | ||
| alignItems: "center", | ||
| }} | ||
| > | ||
| {url.iconPath && ( | ||
| <Box | ||
| component="img" | ||
| src={url.iconPath} | ||
| alt="" | ||
| sx={{ | ||
| width: 20, | ||
| height: 20, | ||
| objectFit: "contain", | ||
| mr: 1.5, | ||
| flexShrink: 0, | ||
| }} | ||
| /> | ||
| )} | ||
| <ListItemText | ||
| primary={url.title || url.url} | ||
| secondary={url.url} | ||
| primaryTypographyProps={{ | ||
| fontSize: isMobile ? "0.875rem" : "inherit", // Smaller font on mobile | ||
| }} | ||
| secondaryTypographyProps={{ | ||
| fontSize: isMobile ? "0.75rem" : "inherit", // Smaller font on mobile | ||
| }} | ||
| /> | ||
| <OpenInNewIcon | ||
| sx={{ | ||
| ml: 1, | ||
| fontSize: isMobile ? 12 : 14, // Smaller icon on mobile | ||
| color: theme.palette.text.secondary, | ||
| opacity: 0.7, | ||
| }} | ||
| fontSize="small" | ||
| /> | ||
| </ListItemButton> | ||
| ); | ||
| }); | ||
|
|
||
| export { ExternalUrlItem }; |
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.
Uh oh!
There was an error while loading. Please reload this page.