-
-
Notifications
You must be signed in to change notification settings - Fork 957
Route-Based Code Splitting #1692
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
base: main
Are you sure you want to change the base?
Changes from all commits
4f3b770
8e818b1
af3995b
a6b70b3
2f7a4a7
a088921
dad5e93
2345a62
30ed193
e3ece0f
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 |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import React from 'react'; | ||
| import { ReactComponent as ImageOops } from 'images/img-oops.svg'; | ||
|
|
||
| class PlayErrorBoundary extends React.Component { | ||
| constructor(props) { | ||
| super(props); | ||
| this.state = { hasError: false, error: null, isChunkError: false }; | ||
| } | ||
|
|
||
| static getDerivedStateFromError(error) { | ||
| // Detect chunk load failures (network errors loading lazy chunks) | ||
| const isChunkError = | ||
| error?.name === 'ChunkLoadError' || | ||
| /loading chunk/i.test(error?.message) || | ||
| /failed to fetch dynamically imported module/i.test(error?.message); | ||
|
|
||
| return { hasError: true, error, isChunkError }; | ||
| } | ||
|
|
||
| componentDidCatch(error, errorInfo) { | ||
| console.error(`Error loading play "${this.props.playName}":`, error, errorInfo); | ||
| } | ||
|
|
||
| handleRetry = () => { | ||
| this.setState({ hasError: false, error: null, isChunkError: false }); | ||
| }; | ||
|
|
||
| handleGoBack = () => { | ||
| window.location.href = '/plays'; | ||
| }; | ||
|
|
||
| render() { | ||
| if (this.state.hasError) { | ||
| return ( | ||
| <div className="play-error-boundary" style={styles.container}> | ||
| <ImageOops style={styles.image} /> | ||
| <h2 style={styles.title}> | ||
| {this.state.isChunkError ? 'Failed to load this play' : 'Something went wrong'} | ||
| </h2> | ||
| <p style={styles.message}> | ||
| {this.state.isChunkError | ||
| ? 'There was a network error loading this play. Please check your connection and try again.' | ||
| : `An error occurred while rendering "${this.props.playName || 'this play'}".`} | ||
| </p> | ||
| <div style={styles.actions}> | ||
| {this.state.isChunkError && ( | ||
| <button style={styles.retryButton} onClick={this.handleRetry}> | ||
| Retry | ||
| </button> | ||
| )} | ||
| <button style={styles.backButton} onClick={this.handleGoBack}> | ||
| Back to Plays | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return this.props.children; | ||
| } | ||
| } | ||
|
|
||
| const styles = { | ||
| container: { | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| padding: '3rem 1.5rem', | ||
| textAlign: 'center', | ||
| minHeight: '50vh' | ||
| }, | ||
| image: { | ||
| width: '200px', | ||
| height: 'auto', | ||
| marginBottom: '1.5rem', | ||
| opacity: 0.8 | ||
| }, | ||
| title: { | ||
| fontSize: '1.5rem', | ||
| fontWeight: 600, | ||
| color: '#333', | ||
| margin: '0 0 0.75rem' | ||
| }, | ||
| message: { | ||
| fontSize: '1rem', | ||
| color: '#666', | ||
| maxWidth: '500px', | ||
| lineHeight: 1.5, | ||
| margin: '0 0 1.5rem' | ||
| }, | ||
| actions: { | ||
| display: 'flex', | ||
| gap: '1rem' | ||
| }, | ||
| retryButton: { | ||
| padding: '0.6rem 1.5rem', | ||
| fontSize: '0.95rem', | ||
| fontWeight: 600, | ||
| border: 'none', | ||
| borderRadius: '6px', | ||
| cursor: 'pointer', | ||
| background: '#00f2fe', | ||
| color: '#fff', | ||
| transition: 'opacity 0.2s' | ||
| }, | ||
| backButton: { | ||
| padding: '0.6rem 1.5rem', | ||
| fontSize: '0.95rem', | ||
| fontWeight: 600, | ||
| border: '2px solid #00f2fe', | ||
| borderRadius: '6px', | ||
| cursor: 'pointer', | ||
| background: 'transparent', | ||
| color: '#00f2fe', | ||
| transition: 'opacity 0.2s' | ||
| } | ||
| }; | ||
|
|
||
| export default PlayErrorBoundary; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| import React from 'react'; | ||
| import sanitizeHTML from 'common/utils/sanitizeHTML'; | ||
|
|
||
| const Output = ({ md, text, mdPreviewBox }) => { | ||
| return ( | ||
| <div | ||
| className="md-editor output-div" | ||
| dangerouslySetInnerHTML={{ __html: sanitizeHTML(md.render(text)) }} | ||
| dangerouslySetInnerHTML={{ __html: md.render(text) }} | ||
|
||
| id={mdPreviewBox} | ||
| /> | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import React, { useState, useEffect, useRef } from 'react'; | ||
| import { FaVolumeUp, FaStop } from 'react-icons/fa'; | ||
| import PlayHeader from 'common/playlists/PlayHeader'; | ||
| import sanitizeHTML from 'common/utils/sanitizeHTML'; | ||
| import './styles.css'; | ||
|
|
||
| function TextToSpeech(props) { | ||
|
|
@@ -158,7 +159,10 @@ function TextToSpeech(props) { | |
| <div className="tts-output-box"> | ||
| {convertedText ? ( | ||
| <> | ||
| <p className="tts-output-text">{convertedText}</p> | ||
| <p | ||
| className="tts-output-text" | ||
| dangerouslySetInnerHTML={{ __html: sanitizeHTML(convertedText) }} | ||
| /> | ||
|
Comment on lines
162
to
165
|
||
|
|
||
| <button className="tts-speaker-btn" onClick={handleSpeak}> | ||
| {isSpeaking ? <FaStop size={28} /> : <FaVolumeUp size={28} />} | ||
|
|
||
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 @Suvam-paul145 looks like ai generated, can you fix this i mean we don't need to make it complex, it's just a simple css stuff so make it simple please.