Skip to content

Commit

Permalink
add different types of typewriter
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Jun 26, 2023
1 parent cf48c25 commit 70bbf05
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/plugins/openaigpt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class OpenAIGpt extends Plugin {
})).json()

console.log(result)
this.call('terminal', 'log', { type: 'typewriterlog', value: result.choices[0].message.content })
this.call('terminal', 'log', { type: 'typewritersuccess', value: result.choices[0].message.content })
return result.data
}
}
12 changes: 11 additions & 1 deletion libs/remix-ui/terminal/src/lib/reducers/terminalReducer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CLEAR_CONSOLE, CMD_HISTORY, EMPTY_BLOCK, ERROR, HTML, INFO, KNOWN_TRANSACTION, LISTEN_ON_NETWORK, LOG, TYPEWRITERLOG, NEW_TRANSACTION, SCRIPT, UNKNOWN_TRANSACTION, WARN } from '../types/terminalTypes'
import { CLEAR_CONSOLE, CMD_HISTORY, EMPTY_BLOCK, ERROR, HTML, INFO, KNOWN_TRANSACTION, LISTEN_ON_NETWORK, LOG, TYPEWRITERLOG, TYPEWRITERWARNING, TYPEWRITERSUCCESS, NEW_TRANSACTION, SCRIPT, UNKNOWN_TRANSACTION, WARN } from '../types/terminalTypes'

export const initialState = {
journalBlocks: [
Expand Down Expand Up @@ -156,6 +156,16 @@ export const registerScriptRunnerReducer = (state, action) => {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, typewriter: true, style: 'text-log', provider: action.payload.provider })
}
case TYPEWRITERWARNING:
return {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, typewriter: true, style: 'text-warning', provider: action.payload.provider })
}
case TYPEWRITERSUCCESS:
return {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, typewriter: true, style: 'text-success', provider: action.payload.provider })
}
case INFO:
return {
...state,
Expand Down
2 changes: 2 additions & 0 deletions libs/remix-ui/terminal/src/lib/types/terminalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const NEW_CALL = 'newCall'
export const HTML = 'html'
export const LOG = 'log'
export const TYPEWRITERLOG = 'typewriterlog'
export const TYPEWRITERWARNING = 'typewriterwarning'
export const TYPEWRITERSUCCESS = 'typewritersuccess'
export const INFO = 'info'
export const WARN = 'warn'
export const ERROR = 'error'
Expand Down

0 comments on commit 70bbf05

Please sign in to comment.