-
Notifications
You must be signed in to change notification settings - Fork 112
fix: mobile drawer #170
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
fix: mobile drawer #170
Conversation
Reviewer's GuideRefactors workspace list items to be reusable outside dropdown menus and adjusts the mobile drawer/top bar layout so the workspace drawer behaves correctly on mobile, including top offset handling and responsive widths. Sequence diagram for mobile workspace selection via drawersequenceDiagram
actor MobileUser
participant MobileTopBar
participant MobileDrawer
participant MobileFolder
participant MobileWorkspaces
participant WorkspaceList
participant WorkspaceItem
MobileUser->>MobileTopBar: tapFolderButton()
MobileTopBar->>MobileDrawer: toggleDrawer(true)
MobileDrawer-->>MobileUser: displayWorkspaceDrawer(topOffset)
MobileDrawer->>MobileFolder: render()
MobileFolder->>MobileWorkspaces: render()
MobileWorkspaces->>WorkspaceList: render(useDropdownItem=false)
WorkspaceList->>WorkspaceItem: renderAsButton()
MobileUser->>WorkspaceItem: tapWorkspaceButton()
WorkspaceItem->>WorkspaceItem: handleSelect()
alt sameWorkspace
WorkspaceItem-->>MobileUser: noChange()
else differentWorkspace
WorkspaceItem->>MobileWorkspaces: onChange(selectedId)
MobileWorkspaces->>WorkspaceList: updateCurrentWorkspace()
MobileWorkspaces->>MobileDrawer: onClose()
MobileDrawer-->>MobileUser: hideWorkspaceDrawer()
end
Class diagram for updated workspace components and mobile drawerclassDiagram
class WorkspaceItem {
+boolean showActions
+Workspace workspace
+string currentWorkspaceId
+string changeLoading
+function onChange(selectedId)
+function onUpdate(workspace)
+function onDelete(workspace)
+function onLeave(workspace)
+boolean useDropdownItem
+handleSelect()
}
class WorkspaceList {
+string currentWorkspaceId
+string changeLoading
+Workspace[] defaultWorkspaces
+boolean showActions
+function onChange(selectedId)
+function onUpdate(workspace)
+function onDelete(workspace)
+function onLeave(workspace)
+boolean useDropdownItem
}
class CurrentWorkspace {
+UserWorkspaceInfo userWorkspaceInfo
+Workspace selectedWorkspace
+function onChangeWorkspace(selectedId)
+AvatarSize avatarSize
+boolean changeLoading
}
class MobileWorkspaces {
+boolean changeLoading
+function onClose()
+handleChange(selectedId)
}
class MobileDrawer {
+ReactNode children
+ReactElement triggerNode
+DrawerAnchor anchor
+number swipeAreaWidth
+number swipeAreaHeight
+number maxHeight
+boolean showPuller
+number topOffset
+function onOpen()
+function onClose()
+boolean open
+toggleDrawer(open)
+paperStyle
}
class MobileTopBar {
+UIVariant variant
+boolean openFolder
+boolean openMore
+number folderDrawerWidth
+handleOpenFolder()
+handleCloseFolder()
+handleOpenMore()
+handleCloseMore()
}
class MobileFolder {
+function onClose()
}
class Avatar {
+AvatarShape shape
+AvatarSize size
}
class AvatarSize {
<<enumeration>>
xs
sm
md
xl
}
WorkspaceList *-- WorkspaceItem
MobileWorkspaces *-- WorkspaceList
MobileFolder *-- MobileWorkspaces
MobileTopBar *-- MobileDrawer
MobileDrawer *-- MobileFolder
CurrentWorkspace *-- Avatar
WorkspaceItem *-- Avatar
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- In MobileTopBar,
folderDrawerWidthis computed once fromwindow.innerWidthwithout listening to resize/orientation changes, so consider adding a resize listener or using a hook to recalculate the drawer width when the viewport size changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In MobileTopBar, `folderDrawerWidth` is computed once from `window.innerWidth` without listening to resize/orientation changes, so consider adding a resize listener or using a hook to recalculate the drawer width when the viewport size changes.
## Individual Comments
### Comment 1
<location> `src/components/_shared/mobile-topbar/MobileTopBar.tsx:25` </location>
<code_context>
const isMobile = getPlatform().isMobile;
</code_context>
<issue_to_address>
**suggestion (code-quality):** Prefer object destructuring when accessing and using properties. ([`use-object-destructuring`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/TypeScript/Default-Rules/use-object-destructuring))
```suggestion
const {isMobile} = getPlatform();
```
<br/><details><summary>Explanation</summary>Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.
From the [Airbnb Javascript Style Guide](https://airbnb.io/javascript/#destructuring--object)
</details>
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| function MobileTopBar({ variant }: { variant?: UIVariant }) { | ||
| const [openFolder, setOpenFolder] = React.useState(false); | ||
| const [openMore, setOpenMore] = React.useState(false); | ||
| const isMobile = getPlatform().isMobile; |
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.
suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring)
| const isMobile = getPlatform().isMobile; | |
| const {isMobile} = getPlatform(); |
Explanation
Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.From the Airbnb Javascript Style Guide
Description
Checklist
General
Testing
Feature-Specific
Summary by Sourcery
Adjust mobile workspace drawer layout and behavior for better usability on small screens and side-anchored drawers.
Bug Fixes:
Enhancements: