File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { saveAs } from 'file-saver';
33import UserCodeMirror from './UserCodeMirror.jsx' ;
44import Toolbox from './Toolbox.jsx' ;
55import Tabs from './Tabs.jsx' ;
6+ import PageTabs from './PageTabs.jsx' ;
67import { computeCss , computeHtml , computeJs } from '../computes' ;
78import { CssModes , HtmlModes , JsModes , modes } from '../codeModes' ;
89import { getCompleteHtml , loadJS , log } from '../utils' ;
@@ -1083,6 +1084,13 @@ export default class ContentWrap extends Component {
10831084 </ div >
10841085 < div class = "demo-side" id = "js-demo-side" >
10851086 < div className = "h-full flex flex-col" >
1087+ { this . props . currentItem && this . props . currentItem . pages && this . props . currentItem . pages . length > 0 && (
1088+ < PageTabs
1089+ pages = { this . props . currentItem . pages }
1090+ currentPageId = { this . props . currentItem . currentPageId }
1091+ onTabClick = { this . props . onPageSwitch }
1092+ />
1093+ ) }
10861094 < div
10871095 className = "flex-grow"
10881096 style = "overflow-y: auto; -webkit-overflow-scrolling: touch; "
Original file line number Diff line number Diff line change 1+ import React from 'preact' ;
2+
3+ /**
4+ * PageTabs component displays tabs for each page and handles tab switching
5+ *
6+ * @param {Object } props - Component props
7+ * @param {Array } props.pages - Array of page objects
8+ * @param {String } props.currentPageId - ID of the currently active page
9+ * @param {Function } props.onTabClick - Callback function when a tab is clicked
10+ */
11+ export function PageTabs ( { pages, currentPageId, onTabClick } ) {
12+ if ( ! pages || pages . length === 0 ) {
13+ return null ;
14+ }
15+
16+ return (
17+ < div className = "page-tabs bg-black-500 border-b border-black-700 px-2 py-1 flex overflow-x-auto" >
18+ { pages . map ( page => (
19+ < button
20+ key = { page . id }
21+ className = { `px-4 py-2 mx-1 rounded-t-lg text-sm font-medium transition-colors duration-200 ${
22+ page . id === currentPageId
23+ ? 'bg-primary text-white'
24+ : 'bg-black-600 text-gray-400 hover:bg-black-700 hover:text-gray-300'
25+ } `}
26+ onClick = { ( ) => onTabClick ( page . id ) }
27+ >
28+ { page . title || 'Untitled' }
29+ </ button >
30+ ) ) }
31+ </ div >
32+ ) ;
33+ }
34+
35+ export default PageTabs ;
Original file line number Diff line number Diff line change @@ -1679,6 +1679,7 @@ BookLibService.Borrow(id) {
16791679 onEditorFocus = { this . editorFocusHandler . bind ( this ) }
16801680 onSplitUpdate = { this . splitUpdateHandler . bind ( this ) }
16811681 onProFeature = { this . proBtnClickHandler . bind ( this ) }
1682+ onPageSwitch = { this . switchToPage . bind ( this ) }
16821683 keyboardShortcutsBtnClickHandler = { this . handleShortcutsModalOpen . bind (
16831684 this ,
16841685 ) }
You can’t perform that action at this time.
0 commit comments