Repository navigation
Added sidebar to Post Analytics Beta - #23086
Conversation
ref https://linear.app/ghost/issue/PROD-659/add-sidebar-to-ember-and-react-apps-allowing-tabs-to-work-across-both - So far the link between the Overview (Ember) and Web (React) views of Post Analytics has been through a simple button in the page header. We changed this to include a sidebar in both the Ember and the React version with tabs to simulate a longer term concept and design.
|
""" WalkthroughThis set of changes focuses on restructuring and refining the layout and styling of the Post Analytics page across both the application and admin interfaces. In the main app, the PostAnalytics view and its content component are updated to adopt a grid layout, introduce a sidebar, and apply consistent typography and spacing. The Sidebar component, previously commented out, is now enabled. Breadcrumb and heading elements receive updated line height and margin classes for improved alignment. In the Ghost admin interface, the analytics template is reorganized to wrap content in a new container and move the "Web stats" link from the header to a sidebar navigation item, with conditional rendering based on user permissions and feature flags. Additionally, a comprehensive set of new CSS rules is introduced, scoped to the Traffic Analytics feature, to style the new layout and sidebar, including responsive adjustments for smaller screens. Possibly related PRs
Suggested labels
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
apps/posts/src/views/PostAnalytics/PostAnalytics.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-react-hooks". (The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "/apps/posts".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-react-hooks" was referenced from the config file in "apps/posts/.eslintrc.cjs". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🪛 Biome (1.9.4)apps/posts/src/views/PostAnalytics/PostAnalytics.tsx[error] 87-87: Change to an optional chain. Unsafe fix: Change to an optional chain. (lint/complexity/useOptionalChain) [error] 89-89: Change to an optional chain. Unsafe fix: Change to an optional chain. (lint/complexity/useOptionalChain) 🔇 Additional comments (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
ghost/admin/public/assets/icons/stats-overview.svgis excluded by!**/*.svgghost/admin/public/assets/icons/stats-web.svgis excluded by!**/*.svg
📒 Files selected for processing (4)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx(1 hunks)apps/posts/src/views/PostAnalytics/components/PostAnalyticsContent.tsx(1 hunks)ghost/admin/app/components/posts/analytics.hbs(2 hunks)ghost/admin/app/styles/layouts/content.css(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/posts/src/views/PostAnalytics/components/PostAnalyticsContent.tsx (1)
apps/shade/src/lib/utils.ts (1)
cn(7-9)
🪛 Biome (1.9.4)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx
[error] 87-87: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 89-89: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Unit tests (Node 22.13.1)
- GitHub Check: Unit tests (Node 20.11.1)
- GitHub Check: Unit tests (Node 18.12.1)
- GitHub Check: Lint
- GitHub Check: Admin tests - Chrome
🔇 Additional comments (11)
ghost/admin/app/styles/layouts/content.css (4)
2227-2241: The new grid layout properly accommodates the sidebar element.The CSS structure follows a good pattern by scoping the Traffic Analytics beta styles under the
.feature-trafficAnalyticsclass. The grid layout using fixed column widths is appropriate for the sidebar implementation, providing a consistent sidebar width while allowing the main content to be fluid.
2252-2282: Well-implemented interactive states for sidebar navigation.The sidebar styling includes all necessary states (default, active, hover) with appropriate visual hierarchy through color and font weight. The border-left approach for separating the sidebar from content is a clean design pattern.
2283-2327: Elegant tab state indicators with clear visual feedback.The tab styling uses a subtle but effective approach with the
:beforepseudo-element for the underline indicator on hover and selected states. This provides good visual feedback while maintaining a clean aesthetic.
2395-2419: Comprehensive responsive breakpoints handle different screen sizes.The media queries at 1320px and 1200px breakpoints properly adjust grid columns, font sizes, and spacing to maintain usability on smaller screens. The adjustments are well thought out and preserve the functionality of the interface.
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx (2)
63-63: ViewHeader class adjustment improves vertical alignment.Removing the
before:hiddenclass allows the header to render correctly with the new sidebar layout.
68-83: Consistent line height in breadcrumb improves visual alignment.Adding
leading-[24px]to all breadcrumb elements creates consistent vertical alignment throughout the navigation path.apps/posts/src/views/PostAnalytics/components/PostAnalyticsContent.tsx (2)
1-3: Properly enabled the Sidebar component.Uncommenting the Sidebar import is necessary for the new layout to work correctly.
7-12: Effective switch from flex to grid layout with sidebar integration.The layout change from flex column to a grid layout with responsive column widths is well implemented. The grid template columns use appropriate widths that match the CSS in the main stylesheet, with a responsive adjustment for extra-large screens.
The commented-out previous implementation helps maintain context for future development.
ghost/admin/app/components/posts/analytics.hbs (3)
1-1: Conditional feature flag usage is appropriate for the feature rollout.The conditional application of the
feature-trafficAnalyticsclass based on user permissions, configuration, and feature flag is a good approach for gradually rolling out this feature.
93-94: New content wrapper provides proper structure for sidebar layout.The addition of the
gh-post-analytics-contentdiv creates the necessary container for implementing the grid layout that holds both the main content and sidebar.
269-278: Well-implemented sidebar with conditional rendering.The sidebar implementation with navigation items includes proper active state on the current view and conditional rendering based on user permissions and feature flags.
| <H1 className='min-h-[35px] indent-0 leading-[1.2em]'> | ||
| {post && post.title} | ||
| </H1> |
There was a problem hiding this comment.
The heading uses optional chain pattern inconsistently.
While the code is functional, static analysis suggests using optional chaining for the post object to prevent potential runtime errors.
Apply this diff to fix the potential null/undefined reference:
- <H1 className='min-h-[35px] indent-0 leading-[1.2em]'>
- {post && post.title}
+ <H1 className='min-h-[35px] indent-0 leading-[1.2em]'>
+ {post?.title}
</H1>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <H1 className='min-h-[35px] indent-0 leading-[1.2em]'> | |
| {post && post.title} | |
| </H1> | |
| <H1 className='min-h-[35px] indent-0 leading-[1.2em]'> | |
| {post?.title} | |
| </H1> |
🧰 Tools
🪛 Biome (1.9.4)
[error] 87-87: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
| {typedPost && typedPost.published_at && ( | ||
| <div className='mt-1 text-sm text-grey-600'> | ||
| <div className='text-grey-600 flex h-9 items-center justify-start text-sm leading-[1.65em]'> | ||
| Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')} | ||
| </div> | ||
| )} |
There was a problem hiding this comment.
Improve date container styling and fix optional chaining.
The styling changes using flex layout with specific height values creates better vertical alignment and consistency. However, there's a potential null/undefined reference with typedPost.
Apply this diff to fix the potential null/undefined reference:
- {typedPost && typedPost.published_at && (
+ {typedPost?.published_at && (
<div className='text-grey-600 flex h-9 items-center justify-start text-sm leading-[1.65em]'>
Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')}
</div>
)}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {typedPost && typedPost.published_at && ( | |
| <div className='mt-1 text-sm text-grey-600'> | |
| <div className='text-grey-600 flex h-9 items-center justify-start text-sm leading-[1.65em]'> | |
| Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')} | |
| </div> | |
| )} | |
| {typedPost?.published_at && ( | |
| <div className='text-grey-600 flex h-9 items-center justify-start text-sm leading-[1.65em]'> | |
| Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')} | |
| </div> | |
| )} |
🧰 Tools
🪛 Biome (1.9.4)
[error] 89-89: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
ref https://linear.app/ghost/issue/PROD-659/add-sidebar-to-ember-and-react-apps-allowing-tabs-to-work-across-both