Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
soohoonc committed Jun 8, 2024
1 parent 4034cd5 commit d8de879
Show file tree
Hide file tree
Showing 24 changed files with 327 additions and 289 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"./src/wasm/Cargo.toml",
"./src/wasm/Cargo.toml"
]
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

this is my website

thanks for coming
thanks for coming
19 changes: 0 additions & 19 deletions assets/fs/user/soohoon/about

This file was deleted.

5 changes: 0 additions & 5 deletions assets/fs/user/soohoon/credits

This file was deleted.

33 changes: 0 additions & 33 deletions assets/fs/user/soohoon/help

This file was deleted.

5 changes: 0 additions & 5 deletions assets/fs/user/soohoon/license

This file was deleted.

5 changes: 0 additions & 5 deletions assets/fs/user/soohoon/source

This file was deleted.

84 changes: 0 additions & 84 deletions assets/fs/user/soohoon/timeline

This file was deleted.

10 changes: 4 additions & 6 deletions rust-project.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"roots": [
{
"crateRoots": [
"./src/wasm/src/lib.rs"
],
"isWorkspaceMember": true
}
{
"crateRoots": ["./src/wasm/src/lib.rs"],
"isWorkspaceMember": true
}
],
"source": "discover"
}
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'soohoonchoi',
description: "soohoonchoi",
description: 'soohoonchoi',
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
Expand Down
24 changes: 14 additions & 10 deletions src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ type ShellContext = {
prompt: string;
};

const initialShell = {
} as Shell;
const initialShell = {} as Shell;

const initialShellContext = {
execute: (command: string) => null,
Expand All @@ -33,7 +32,7 @@ export function useShell() {
}

export function ShellProvider({ children }: { children: React.ReactNode }) {
console.log('Welcome to my website!')
console.log('Welcome to my website!');
const [shell, setShell] = React.useState<Shell>(initialShell);
const [prompt, setPrompt] = React.useState<string>('');
const execute = (command: string) => {
Expand All @@ -42,13 +41,14 @@ export function ShellProvider({ children }: { children: React.ReactNode }) {
return;
}
const result = JSON.parse(shell.run(command));
console.log('execute', result);
setPrompt(`${result.user}@${result.host} ${result.path} $`);
return parse(result.result) as React.ReactNode | null;
}
return parse(result.result) as React.ReactNode | null;
};
React.useEffect(() => {
async function init() {
const shell = await getShell();
const result = JSON.parse(shell.run('hello'))
const result = JSON.parse(shell.run('hello'));
console.log(result.result);
setPrompt(`${result.user}@${result.host} ${result.path} $`);
setShell(shell);
Expand All @@ -57,10 +57,14 @@ export function ShellProvider({ children }: { children: React.ReactNode }) {
}, []);

return (
<ShellContext.Provider value={{
prompt,
execute
}}>{children}</ShellContext.Provider>
<ShellContext.Provider
value={{
prompt,
execute,
}}
>
{children}
</ShellContext.Provider>
);
}

Expand Down
9 changes: 6 additions & 3 deletions src/components/terminal-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const TerminalContent = () => {
hour12: false,
});
return `${formattedDate}, ${formattedTime}`;
}
};
const [currentTime, setCurrentTime] = useState(getTime());

useEffect(() => {
Expand All @@ -35,7 +35,10 @@ export const TerminalContent = () => {
{showWelcome && (
<>
<p suppressHydrationWarning>
<a href="https://soohoonchoi.com" className="link">soohoonchoi</a> ({currentTime})<br />
<a href='https://soohoonchoi.com' className='link'>
soohoonchoi
</a>{' '}
({currentTime})<br />
Type &quot;help&quot;, &quot;credits&quot; or &quot;license&quot; for more.
</p>
</>
Expand All @@ -48,4 +51,4 @@ export const TerminalContent = () => {
))}
</>
);
};
};
13 changes: 3 additions & 10 deletions src/components/terminal-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@ import React from 'react';
import { useTerminalState, useShell } from '@/app/providers';

export const TerminalInput = React.forwardRef(({}, ref) => {
const {
setShowWelcome,
inputs,
setInputs,
outputs,
setOutputs,
inputIndex,
setInputIndex,
} = useTerminalState();
const { setShowWelcome, inputs, setInputs, outputs, setOutputs, inputIndex, setInputIndex } =
useTerminalState();
const [input, setInput] = React.useState<string>('');
const inputRef = React.useRef<HTMLInputElement>(null);
const { execute, prompt } = useShell();
Expand Down Expand Up @@ -70,7 +63,7 @@ export const TerminalInput = React.forwardRef(({}, ref) => {

return (
<div className='bg-transparent outline-none resize-none break-all'>
{prompt ? (<span className='mr-[1ch]'>{prompt}</span>) : null}
{prompt ? <span className='mr-[1ch]'>{prompt}</span> : null}
<span
contentEditable
ref={inputRef}
Expand Down
Loading

0 comments on commit d8de879

Please sign in to comment.