File tree Expand file tree Collapse file tree 3 files changed +99
-1
lines changed
Expand file tree Collapse file tree 3 files changed +99
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import FramerateChanger from '../../containers/tw-framerate-changer.jsx';
3232import ChangeUsername from '../../containers/tw-change-username.jsx' ;
3333import CloudVariablesToggler from '../../containers/tw-cloud-toggler.jsx' ;
3434import TWSaveStatus from './tw-save-status.jsx' ;
35+ import TWNews from './tw-news.jsx' ;
3536
3637import { openTipsLibrary , openSettingsModal , openRestorePointModal } from '../../reducers/modals' ;
3738import { setPlayer } from '../../reducers/mode' ;
@@ -482,7 +483,7 @@ class MenuBar extends React.Component {
482483 ) ;
483484 // Show the About button only if we have a handler for it (like in the desktop app)
484485 const aboutButton = this . buildAboutMenu ( this . props . onClickAbout ) ;
485- return (
486+ const menuBar = (
486487 < Box
487488 className = { classNames (
488489 this . props . className ,
@@ -1042,6 +1043,13 @@ class MenuBar extends React.Component {
10421043 { aboutButton }
10431044 </ Box >
10441045 ) ;
1046+
1047+ return (
1048+ < React . Fragment >
1049+ { menuBar }
1050+ < TWNews />
1051+ </ React . Fragment >
1052+ ) ;
10451053 }
10461054}
10471055
Original file line number Diff line number Diff line change 1+ @import "../../css/colors.css" ;
2+
3+ .news {
4+ background : $pen- primary;
5+ dis play: flex;
6+ flex-direction : row;
7+ align-items : center;
8+ justify-content : space-between;
9+ padding : 0.375rem 0 ;
10+ }
11+
12+ .text {
13+ flex-grow : 1 ;
14+ color : white;
15+ text-align : center;
16+ }
17+
18+ .text a {
19+ color : inherit;
20+ }
21+
22+ .close {
23+ margin-right : 0.5rem ;
24+ }
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { APP_NAME } from '../../lib/brand' ;
3+ import { isScratchDesktop } from '../../lib/isScratchDesktop' ;
4+ import CloseButton from '../close-button/close-button.jsx' ;
5+ import styles from './tw-news.css' ;
6+
7+ const LOCAL_STORAGE_KEY = 'tw:closedNews' ;
8+ const NEWS_ID = 'new-compiler' ;
9+
10+ const getIsClosedInLocalStorage = ( ) => {
11+ try {
12+ return localStorage . getItem ( LOCAL_STORAGE_KEY ) === NEWS_ID ;
13+ } catch ( e ) {
14+ return false ;
15+ }
16+ } ;
17+
18+ const markAsClosedInLocalStorage = ( ) => {
19+ try {
20+ localStorage . setItem ( LOCAL_STORAGE_KEY , NEWS_ID ) ;
21+ } catch ( e ) {
22+ // ignore
23+ }
24+ } ;
25+
26+ class TWNews extends React . Component {
27+ constructor ( props ) {
28+ super ( props ) ;
29+ this . state = {
30+ closed : getIsClosedInLocalStorage ( )
31+ } ;
32+ this . handleClose = this . handleClose . bind ( this ) ;
33+ }
34+ handleClose ( ) {
35+ markAsClosedInLocalStorage ( ) ;
36+ this . setState ( {
37+ closed : true
38+ } ) ;
39+ }
40+ render ( ) {
41+ if ( this . state . closed || isScratchDesktop ( ) ) {
42+ return null ;
43+ }
44+ return (
45+ < div className = { styles . news } >
46+ < div className = { styles . text } >
47+ { /* eslint-disable-next-line max-len */ }
48+ { `We rewrote the ${ APP_NAME } compiler to make projects run even faster. Bugs are possible. ` }
49+ < a
50+ href = "https://docs.turbowarp.org/new-compiler"
51+ target = "_blank"
52+ rel = "noreferrer"
53+ >
54+ { 'Learn more.' }
55+ </ a >
56+ </ div >
57+ < CloseButton
58+ className = { styles . close }
59+ onClick = { this . handleClose }
60+ />
61+ </ div >
62+ ) ;
63+ }
64+ }
65+
66+ export default TWNews ;
You can’t perform that action at this time.
0 commit comments