-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add React Server Components with shared MarkdownViewer pattern #12
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
Open
ihabadham
wants to merge
20
commits into
main
Choose a base branch
from
rsc-markdown-shared-component
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.
Open
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
913e8f0
feat: add React on Rails Pro with RSC support
ihabadham d23eba9
feat: configure webpack and Rails for RSC bundle generation
ihabadham a3ecc1b
feat: implement RSC markdown page with shared component pattern
ihabadham a88a903
feat: configure Node renderer with GitHub packages
ihabadham db4e465
chore: add gitignore entries for RSC bundles and audit file
ihabadham 0c54276
feat: configure Rails for RSC bundle paths
ihabadham ba16eec
feat: configure node renderer to use ssr-generated bundles
ihabadham 75a416f
feat: configure server webpack bundle for node renderer
ihabadham b5ee8a5
feat: add react-dom/server alias to RSC webpack config
ihabadham f141a1f
fix: add "use client" directives to client components
ihabadham 6ca187b
chore: add foreman to development dependencies
ihabadham 562b8a9
chore: switch RORP from local path to GitHub Packages
ihabadham 37e2df5
chore: remove foreman gem and cleanup gitignore
ihabadham 4a7fa09
feat: add bottom padding to layout
ihabadham 4026991
feat: add complete navigation between all three pages
ihabadham 3464829
refactor: convert RSC component to inline styles
ihabadham 5136a8b
feat: implement shared MarkdownViewer pattern
ihabadham da296d3
docs: add GitHub Packages authentication setup instructions
ihabadham 151cc2c
security: add XSS protection and fix task list selectors
ihabadham fb7a0d8
security: require RENDERER_PASSWORD in production
ihabadham 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,15 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class RscMarkdownPageController < ApplicationController | ||
| include ReactOnRailsPro::Stream | ||
|
|
||
| def index | ||
| @rsc_markdown_page_props = { | ||
| title: "React Server Components Demo", | ||
| author: "Demo System", | ||
| lastModified: Time.current | ||
| } | ||
|
|
||
| stream_view_containing_react_components(template: "rsc_markdown_page/index") | ||
| end | ||
| end |
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
25 changes: 25 additions & 0 deletions
25
app/javascript/src/MarkdownViewer/ror_components/MarkdownViewer.jsx
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,25 @@ | ||
| import React from 'react'; | ||
| import * as style from './MarkdownViewer.module.css'; | ||
|
|
||
| /** | ||
| * Lightweight shared markdown viewer component | ||
| * | ||
| * This component is deliberately lightweight - it only displays pre-processed HTML. | ||
| * No markdown libraries are imported here, keeping the bundle size minimal. | ||
| * | ||
| * Processing happens in the consuming components: | ||
| * - Server component: processes markdown server-side (heavy libs stay on server) | ||
| * - Client component: processes markdown client-side (heavy libs go to client) | ||
| * | ||
| * This pattern ensures the viewer itself has minimal bundle impact. | ||
| */ | ||
| const MarkdownViewer = ({ processedHtml, className }) => { | ||
| return ( | ||
| <div | ||
| className={`${style.markdownContent} ${className || ''}`} | ||
| dangerouslySetInnerHTML={{ __html: processedHtml }} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default MarkdownViewer; | ||
92 changes: 92 additions & 0 deletions
92
app/javascript/src/MarkdownViewer/ror_components/MarkdownViewer.module.css
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,92 @@ | ||
| /* Lightweight markdown content styling for the shared viewer component */ | ||
| .markdownContent { | ||
| line-height: 1.6; | ||
| } | ||
|
|
||
| /* Headings */ | ||
| .markdownContent h1, | ||
| .markdownContent h2, | ||
| .markdownContent h3, | ||
| .markdownContent h4, | ||
| .markdownContent h5, | ||
| .markdownContent h6 { | ||
| color: #2c3e50; | ||
| margin-top: 1.5rem; | ||
| margin-bottom: 0.5rem; | ||
| } | ||
|
|
||
| .markdownContent h1 { | ||
| border-bottom: 2px solid #e67e22; | ||
| padding-bottom: 0.3rem; | ||
| } | ||
|
|
||
| /* Code and pre */ | ||
| .markdownContent code { | ||
| background-color: #f1c40f; | ||
| padding: 2px 4px; | ||
| border-radius: 3px; | ||
| font-size: 0.9em; | ||
| font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; | ||
| } | ||
|
|
||
| .markdownContent pre { | ||
| background-color: #2c3e50; | ||
| color: #ecf0f1; | ||
| padding: 1rem; | ||
| border-radius: 4px; | ||
| overflow-x: auto; | ||
| } | ||
|
|
||
| .markdownContent pre code { | ||
| background: none; | ||
| color: inherit; | ||
| padding: 0; | ||
| } | ||
|
|
||
| /* Tables */ | ||
| .markdownContent table { | ||
| border-collapse: collapse; | ||
| width: 100%; | ||
| margin: 1rem 0; | ||
| } | ||
|
|
||
| .markdownContent th, | ||
| .markdownContent td { | ||
| border: 1px solid #bdc3c7; | ||
| padding: 0.5rem; | ||
| text-align: left; | ||
| } | ||
|
|
||
| .markdownContent th { | ||
| background-color: #ecf0f1; | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| /* Lists */ | ||
| .markdownContent ul li[data-task] { | ||
| list-style: none; | ||
| margin-left: -1rem; | ||
| } | ||
ihabadham marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /* Blockquotes */ | ||
| .markdownContent blockquote { | ||
| border-left: 4px solid #e67e22; | ||
| margin: 1rem 0; | ||
| padding-left: 1rem; | ||
| color: #7f8c8d; | ||
| } | ||
|
|
||
| /* Links */ | ||
| .markdownContent a { | ||
| color: #3498db; | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| .markdownContent a:hover { | ||
| text-decoration: underline; | ||
| } | ||
|
|
||
| /* Paragraphs */ | ||
| .markdownContent p { | ||
| margin-bottom: 1rem; | ||
| } | ||
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.