-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add object names to favorites #8593
base: main
Are you sure you want to change the base?
Changes from 1 commit
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { ProcessedFavorite } from '@/favorites/utils/sortFavorites'; | ||
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage'; | ||
import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper'; | ||
import { NavigationDrawerItemBreadcrumb } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItemBreadcrumb'; | ||
|
@@ -38,6 +39,8 @@ export type NavigationDrawerItemProps = { | |
keyboard?: string[]; | ||
rightOptions?: ReactNode; | ||
isDraggable?: boolean; | ||
isFavorite?: boolean; | ||
objectName?: string | undefined; | ||
}; | ||
|
||
type StyledItemProps = Pick< | ||
|
@@ -129,6 +132,25 @@ const StyledItemLabel = styled.span` | |
white-space: nowrap; | ||
`; | ||
|
||
const StyledItemLabelWithObjectName = styled.span` | ||
color: ${({ theme }) => theme.font.color.light}; | ||
font-weight: ${({ theme }) => theme.font.weight.regular}; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
`; | ||
type CreateLabelWithObjectNameProps = ProcessedFavorite; | ||
|
||
export const CreateLabelWithObjectName = ( | ||
favorite: CreateLabelWithObjectNameProps, | ||
) => { | ||
return ( | ||
favorite.labelIdentifier + | ||
' . ' + | ||
String(favorite.objectNameSingular?.charAt(0).toUpperCase()) + | ||
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. logic: Inconsistent separator - using ' . ' (space-dot-space) here but ' · ' (space-middot-space) in the component render. Should use the same separator consistently. |
||
favorite.objectNameSingular?.slice(1) | ||
); | ||
}; | ||
|
||
const StyledItemCount = styled.span` | ||
align-items: center; | ||
background-color: ${({ theme }) => theme.color.blue}; | ||
|
@@ -199,6 +221,8 @@ export const NavigationDrawerItem = ({ | |
subItemState, | ||
rightOptions, | ||
isDraggable, | ||
isFavorite, | ||
objectName, | ||
}: NavigationDrawerItemProps) => { | ||
const theme = useTheme(); | ||
const isMobile = useIsMobile(); | ||
|
@@ -254,6 +278,12 @@ export const NavigationDrawerItem = ({ | |
|
||
<NavigationDrawerAnimatedCollapseWrapper> | ||
<StyledItemLabel>{label}</StyledItemLabel> | ||
{isFavorite && objectName && ( | ||
<StyledItemLabelWithObjectName> | ||
{' '} | ||
· {objectName.charAt(0).toUpperCase() + objectName.slice(1)} | ||
</StyledItemLabelWithObjectName> | ||
)} | ||
</NavigationDrawerAnimatedCollapseWrapper> | ||
|
||
<StyledSpacer /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ export const NavigationDrawerSubItem = ({ | |
subItemState, | ||
rightOptions, | ||
isDraggable, | ||
objectName, | ||
}: NavigationDrawerSubItemProps) => { | ||
return ( | ||
<NavigationDrawerItem | ||
|
@@ -36,6 +37,8 @@ export const NavigationDrawerSubItem = ({ | |
keyboard={keyboard} | ||
rightOptions={rightOptions} | ||
isDraggable={isDraggable} | ||
isFavorite | ||
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. logic: Setting isFavorite to true by default may be too restrictive - consider making this configurable via props like the other properties |
||
objectName={objectName} | ||
/> | ||
); | ||
}; |
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.
logic: Missing overflow property and max-width constraint needed for text-overflow: ellipsis to work. Add overflow: hidden and max-width.