-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from WTFAcademy/dev
Dev
- Loading branch information
Showing
20 changed files
with
353 additions
and
316 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"solive-core": patch | ||
--- | ||
|
||
refactor log output |
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
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,59 +1,66 @@ | ||
import ReactJson from "react-json-view"; | ||
import { useEffect, useRef } from 'react'; | ||
|
||
import NavBar from "../NavBar"; | ||
import {useEditor} from "../../editor/contexts/editorContext"; | ||
import {generateConsoleMessageToShow} from "../../types/console"; | ||
import {useConsole} from "../../editor/contexts/consoleContext"; | ||
import {useEffect, useRef} from "react"; | ||
import ReactJson from 'react-json-view'; | ||
|
||
import NavBar from '../NavBar'; | ||
import { useEditor } from '../../editor/contexts/editorContext'; | ||
import { generateConsoleMessageToShow } from '../../types/console'; | ||
import { useConsole } from '../../editor/contexts/consoleContext'; | ||
|
||
const NAVS = [ | ||
{label: "Console", id: "console"}, | ||
{label: "", id: "empty"}, | ||
{ label: 'Console', id: 'console' }, | ||
{ label: '', id: 'empty' }, | ||
]; | ||
|
||
type TProps = { | ||
onDeleteClick?: () => void; | ||
} | ||
|
||
const Console = (props: TProps) => { | ||
function Console(props: TProps) { | ||
const { | ||
onDeleteClick, | ||
} = props; | ||
const { id } = useEditor(); | ||
const {consoles} = useConsole(); | ||
const consoleRef = useRef<HTMLDivElement>(null) | ||
const { consoles } = useConsole(); | ||
const consoleRef = useRef<HTMLDivElement>(null); | ||
|
||
const consoleMessages = consoles || []; | ||
|
||
const handleDeleteClick = () => props.onDeleteClick && props.onDeleteClick(); | ||
const handleDeleteClick = () => onDeleteClick && onDeleteClick(); | ||
|
||
useEffect(() => { | ||
consoleRef.current?.scrollTo(0, consoleRef.current.scrollHeight) | ||
}, [consoleMessages]) | ||
consoleRef.current?.scrollTo(0, consoleRef.current.scrollHeight); | ||
}, [consoleMessages]); | ||
|
||
return ( | ||
<div key={id + "_console"} className="h-full flex flex-col flex-1 bg-primary-700 pt-2 rounded-b-[12px]"> | ||
<div key={`${id}_console`} className="h-full flex flex-col flex-1 bg-primary-700 pt-2 rounded-b-[12px]"> | ||
<NavBar globalId={id} navs={NAVS} onDeleteClick={handleDeleteClick} /> | ||
<div ref={consoleRef} className="flex-auto mb-4 text-primary-100 p-2 text-[12px] overflow-scroll"> | ||
{consoleMessages.map((item, index) => { | ||
let data | ||
let data; | ||
try { | ||
data = JSON.parse(item.message) | ||
data = JSON.parse(item.message); | ||
} catch (e) { /* empty */ } | ||
if (data instanceof Object) { | ||
return ( | ||
<div key={index} className={`flex ${item.type === 'error' ? 'text-red-500' : 'text-white'}`}> | ||
<span>[{new Date(item.timestamp).toLocaleTimeString()}]:</span> | ||
<ReactJson src={data} theme="ocean" collapsed style={{backgroundColor: 'transparent'}} /> | ||
</div> | ||
) | ||
} else | ||
return ( | ||
<div key={index} className={`${item.type === 'error' ? 'text-red-500' : 'text-white'}`}> | ||
{generateConsoleMessageToShow(item).toString()} | ||
<span> | ||
[ | ||
{new Date(item.timestamp).toLocaleTimeString()} | ||
]: | ||
</span> | ||
<ReactJson src={data} theme="ocean" collapsed style={{ backgroundColor: 'transparent' }} /> | ||
</div> | ||
) | ||
); | ||
} return ( | ||
<div key={index} className={`whitespace-pre-line ${item.type === 'error' ? 'text-red-500' : 'text-white'}`}> | ||
{generateConsoleMessageToShow(item)} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
) | ||
); | ||
} | ||
|
||
export default Console; |
Oops, something went wrong.
2c9ad12
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.
Successfully deployed to the following URLs:
solive-demo – ./
solive-demo-git-main-wtfacademy.vercel.app
solive-demo-wtfacademy.vercel.app
solive-demo.vercel.app
demo.solive.wtf
2c9ad12
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.
Successfully deployed to the following URLs:
solive-doc – ./
solive-doc-wtfacademy.vercel.app
solive-doc-git-main-wtfacademy.vercel.app
solive-doc.vercel.app
solive.wtf
www.solive.wtf