-
-
Notifications
You must be signed in to change notification settings - Fork 10.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
Adding Posts analytics React app #21878
Open
peterzimon
wants to merge
20
commits into
main
Choose a base branch
from
posts-app
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,760
−215
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ffd2f06
First stab at posts app
peterzimon ac0bcac
Added posts-x to Admin
peterzimon 0556d88
Fixed mini Koenig error
peterzimon dc4bd8d
Added alpha flag for Posts app
peterzimon 7bb0b52
Added basic components to posts app
peterzimon c4f90e6
Added heading component to Shade
peterzimon adbb2cb
Added breadcrumb component
peterzimon b7d58b8
Fixed Page comp. bug
peterzimon d5eeab1
Updated .lint-todo
peterzimon 67b1e6c
Reverted .lint-todo
peterzimon 236bcd5
Added dropdown component in Shade
peterzimon 2638eac
Added dropdown to Post analytics
peterzimon b02da9e
Added Card component to Shade
peterzimon 9a39b8a
Added cards to Post analytics
peterzimon 7ae2df6
Added Tabs component to Shade
peterzimon 5f45641
Updated Tabs button style
peterzimon c9a53a1
Minor copy change
peterzimon 5af0912
Updated Admin linter
peterzimon 08a9b46
Updated snapshot
peterzimon 6d7c852
Fixed missing empty line
peterzimon 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 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 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 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,62 @@ | ||
import {ShadeAppProps} from '@tryghost/shade'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import {TopLevelFrameworkProps} from '../providers/FrameworkProvider'; | ||
|
||
export default function renderShadeApp<Props extends object>( | ||
App: React.ComponentType<Props & { | ||
framework: TopLevelFrameworkProps; | ||
designSystem: ShadeAppProps; | ||
}>, | ||
props: Props | ||
) { | ||
const style = document.createElement('style'); | ||
style.appendChild(document.createTextNode(` | ||
:root { | ||
font-size: 62.5%; | ||
line-height: 1.5; | ||
-ms-text-size-adjust: 100%; | ||
-webkit-text-size-adjust: 100%; | ||
|
||
text-rendering: optimizeLegibility; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-text-size-adjust: 100%; | ||
} | ||
|
||
html, body, #root { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
letter-spacing: unset; | ||
} | ||
`)); | ||
document.head.appendChild(style); | ||
|
||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( | ||
<React.StrictMode> | ||
<App | ||
designSystem={{darkMode: false, fetchKoenigLexical: null}} | ||
framework={{ | ||
externalNavigate: (link) => { | ||
// Use the expectExternalNavigate helper to test this dummy external linking | ||
window.location.href = `/external/${encodeURIComponent(JSON.stringify(link))}`; | ||
}, | ||
ghostVersion: '5.x', | ||
sentryDSN: null, | ||
unsplashConfig: { | ||
Authorization: '', | ||
'Accept-Version': '', | ||
'Content-Type': '', | ||
'App-Pragma': '', | ||
'X-Unsplash-Cache': false | ||
}, | ||
onDelete: () => {}, | ||
onInvalidate: () => {}, | ||
onUpdate: () => {} | ||
}} | ||
{...props} | ||
/> | ||
</React.StrictMode> | ||
); | ||
} |
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import path from 'path'; | ||
import react from '@vitejs/plugin-react'; | ||
import glob from 'glob'; | ||
import {resolve} from 'path'; | ||
|
@@ -10,6 +11,11 @@ export default (function viteConfig() { | |
plugins: [ | ||
react() | ||
], | ||
resolve: { | ||
alias: { | ||
'@': path.resolve(__dirname, './src') | ||
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. I don't see this alias used anywhere, can we revert the changes in this file? |
||
} | ||
}, | ||
preview: { | ||
port: 4174 | ||
}, | ||
|
@@ -20,13 +26,13 @@ export default (function viteConfig() { | |
outDir: 'dist', | ||
lib: { | ||
formats: ['es', 'cjs'], | ||
entry: glob.sync(resolve(__dirname, 'src/**/*.{ts,tsx}')).reduce((entries, path) => { | ||
if (path.endsWith('.d.ts')) { | ||
entry: glob.sync(resolve(__dirname, 'src/**/*.{ts,tsx}')).reduce((entries, libpath) => { | ||
if (libpath.endsWith('.d.ts')) { | ||
return entries; | ||
} | ||
|
||
const outPath = path.replace(resolve(__dirname, 'src') + '/', '').replace(/\.(ts|tsx)$/, ''); | ||
entries[outPath] = path; | ||
const outPath = libpath.replace(resolve(__dirname, 'src') + '/', '').replace(/\.(ts|tsx)$/, ''); | ||
entries[outPath] = libpath; | ||
return entries; | ||
}, {} as Record<string, string>) | ||
}, | ||
|
This file contains 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 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,56 @@ | ||
/* eslint-env node */ | ||
module.exports = { | ||
root: true, | ||
extends: [ | ||
'plugin:ghost/ts', | ||
'plugin:react/recommended', | ||
'plugin:react-hooks/recommended' | ||
], | ||
plugins: [ | ||
'ghost', | ||
'react-refresh', | ||
'tailwindcss' | ||
], | ||
settings: { | ||
react: { | ||
version: 'detect' | ||
} | ||
}, | ||
rules: { | ||
// sort multiple import lines into alphabetical groups | ||
'ghost/sort-imports-es6-autofix/sort-imports-es6': ['error', { | ||
memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple'] | ||
}], | ||
|
||
// TODO: re-enable this (maybe fixed fast refresh?) | ||
'react-refresh/only-export-components': 'off', | ||
|
||
// suppress errors for missing 'import React' in JSX files, as we don't need it | ||
'react/react-in-jsx-scope': 'off', | ||
// ignore prop-types for now | ||
'react/prop-types': 'off', | ||
|
||
// TODO: re-enable these if deemed useful | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
|
||
// custom react rules | ||
'react/jsx-sort-props': ['error', { | ||
reservedFirst: true, | ||
callbacksLast: true, | ||
shorthandLast: true, | ||
locale: 'en' | ||
}], | ||
'react/button-has-type': 'error', | ||
'react/no-array-index-key': 'error', | ||
'react/jsx-key': 'off', | ||
|
||
'tailwindcss/classnames-order': ['error', {config: 'tailwind.config.cjs'}], | ||
'tailwindcss/enforces-negative-arbitrary-values': ['warn', {config: 'tailwind.config.cjs'}], | ||
'tailwindcss/enforces-shorthand': ['warn', {config: 'tailwind.config.cjs'}], | ||
'tailwindcss/migration-from-tailwind-2': ['warn', {config: 'tailwind.config.cjs'}], | ||
'tailwindcss/no-arbitrary-value': 'off', | ||
'tailwindcss/no-custom-classname': 'off', | ||
'tailwindcss/no-contradicting-classname': ['error', {config: 'tailwind.config.cjs'}] | ||
} | ||
}; |
This file contains 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,3 @@ | ||
dist | ||
playwright-report | ||
test-results |
This file contains 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,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Posts</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/standalone.tsx"></script> | ||
</body> | ||
|
||
</html> |
This file contains 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,55 @@ | ||
{ | ||
"name": "@tryghost/posts", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/TryGhost/Ghost/tree/main/apps/posts" | ||
}, | ||
"author": "Ghost Foundation", | ||
"files": [ | ||
"LICENSE", | ||
"README.md", | ||
"dist/" | ||
], | ||
"main": "./dist/posts.umd.cjs", | ||
"module": "./dist/posts.js", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite build --watch", | ||
"dev:start": "vite", | ||
"build": "tsc && vite build", | ||
"lint": "yarn run lint:code && yarn run lint:test", | ||
"lint:code": "eslint --ext .js,.ts,.cjs,.tsx --cache src", | ||
"lint:test": "eslint -c test/.eslintrc.cjs --ext .js,.ts,.cjs,.tsx --cache test", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/react": "14.3.1", | ||
"@tryghost/shade": "0.0.0", | ||
"@tryghost/admin-x-framework": "0.0.0", | ||
"@types/react": "18.3.3", | ||
"@types/react-dom": "18.3.0", | ||
"react": "18.3.1", | ||
"react-dom": "18.3.1" | ||
}, | ||
"nx": { | ||
"targets": { | ||
"dev": { | ||
"dependsOn": [ | ||
"^build" | ||
] | ||
}, | ||
"test:unit": { | ||
"dependsOn": [ | ||
"^build" | ||
] | ||
}, | ||
"test:acceptance": { | ||
"dependsOn": [ | ||
"^build" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains 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,3 @@ | ||
import {adminXPlaywrightConfig} from '@tryghost/admin-x-framework/playwright'; | ||
|
||
export default adminXPlaywrightConfig(); |
This file contains 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 @@ | ||
module.exports = require('@tryghost/shade/postcss.config.cjs'); |
This file contains 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,23 @@ | ||
import PostAnalytics from './pages/PostAnalytics'; | ||
import {FrameworkProvider, TopLevelFrameworkProps} from '@tryghost/admin-x-framework'; | ||
import {RoutingProvider} from '@tryghost/admin-x-framework/routing'; | ||
import {ShadeApp, ShadeAppProps} from '@tryghost/shade'; | ||
|
||
interface AppProps { | ||
framework: TopLevelFrameworkProps; | ||
designSystem: ShadeAppProps; | ||
} | ||
|
||
const App: React.FC<AppProps> = ({framework, designSystem}) => { | ||
return ( | ||
<FrameworkProvider {...framework}> | ||
<RoutingProvider basePath='posts-x'> | ||
<ShadeApp className='posts' {...designSystem}> | ||
<PostAnalytics /> | ||
</ShadeApp> | ||
</RoutingProvider> | ||
</FrameworkProvider> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains 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,26 @@ | ||
import {Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, H1} from '@tryghost/shade'; | ||
|
||
const Header = () => { | ||
return ( | ||
<div className="pt-9"> | ||
<Breadcrumb> | ||
<BreadcrumbList> | ||
<BreadcrumbItem> | ||
<BreadcrumbLink href="/ghost/posts"> | ||
Posts | ||
</BreadcrumbLink> | ||
</BreadcrumbItem> | ||
<BreadcrumbSeparator /> | ||
<BreadcrumbItem> | ||
<BreadcrumbPage> | ||
Analytics | ||
</BreadcrumbPage> | ||
</BreadcrumbItem> | ||
</BreadcrumbList> | ||
</Breadcrumb> | ||
<H1 className='mt-1 max-w-[1024px]'>The Evolution of Basketball: From Pastime to Professional and One of the Most Popular Sports</H1> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Header; |
This file contains 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,17 @@ | ||
import ClickPerformance from './overview/ClickPerformance'; | ||
import Conversions from './overview/Conversions'; | ||
import Feedback from './overview/Feedback'; | ||
import NewsletterPerformance from './overview/NewsletterPerformance'; | ||
|
||
const Overview = () => { | ||
return ( | ||
<div className="grid w-full grid-cols-3 gap-6 py-4"> | ||
<NewsletterPerformance className='col-span-2' /> | ||
<Feedback /> | ||
<ClickPerformance className='col-span-2' /> | ||
<Conversions /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Overview; |
22 changes: 22 additions & 0 deletions
22
apps/posts/src/components/post-analytics/overview/ClickPerformance.tsx
This file contains 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,22 @@ | ||
import * as React from 'react'; | ||
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from '@tryghost/shade'; | ||
|
||
interface ClickPerformanceProps extends React.ComponentProps<typeof Card> {}; | ||
|
||
const ClickPerformance: React.FC<ClickPerformanceProps> = (props) => { | ||
return ( | ||
<Card {...props}> | ||
<CardHeader> | ||
<CardTitle>Click performance</CardTitle> | ||
<CardDescription> | ||
Links in this newsletter | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
Card contents | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default ClickPerformance; |
22 changes: 22 additions & 0 deletions
22
apps/posts/src/components/post-analytics/overview/Conversions.tsx
This file contains 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,22 @@ | ||
import * as React from 'react'; | ||
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from '@tryghost/shade'; | ||
|
||
interface ConversionsProps extends React.ComponentProps<typeof Card> {}; | ||
|
||
const Conversions: React.FC<ConversionsProps> = (props) => { | ||
return ( | ||
<Card {...props}> | ||
<CardHeader> | ||
<CardTitle>Conversions</CardTitle> | ||
<CardDescription> | ||
3 members signed up on this post | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
Card contents | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default Conversions; |
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.
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.
This means that if the shade tests fail the admin-x-framework tests will fail too, is that what you want?
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.
Hm... Maybe not yet. We just added the current design system to it to catch DS bugs, but maybe we can leave Shade out until its first release. Good point.