-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
151 additions
and
87 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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Markdown from 'react-markdown' | ||
import { Box } from '@fower/react' | ||
import { useCurrentCommand } from '~/hooks/useCurrentCommand' | ||
import { useDetail } from '~/hooks/useItems' | ||
|
||
interface CommandAppProps { | ||
// detail: string | ||
} | ||
export function CommandApp({}: CommandAppProps) { | ||
const { currentCommand } = useCurrentCommand() | ||
const { detail } = useDetail() | ||
console.log('======currentCommand:', currentCommand) | ||
|
||
return ( | ||
<Box> | ||
{detail && ( | ||
<Box p4> | ||
<Markdown>{detail}</Markdown> | ||
</Box> | ||
)} | ||
</Box> | ||
) | ||
} |
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,15 @@ | ||
import { atom, useAtom } from 'jotai' | ||
|
||
type Position = 'ROOT' | 'COMMAND_APP' | ||
|
||
export const positionAtom = atom<Position>('ROOT') | ||
|
||
export function useCommandPosition() { | ||
const [position, setPosition] = useAtom(positionAtom) | ||
return { | ||
isRoot: position === 'ROOT', | ||
isCommandApp: position === 'COMMAND_APP', | ||
position, | ||
setPosition, | ||
} | ||
} |
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,9 @@ | ||
import { atom, useAtom } from 'jotai' | ||
import { ListItem } from 'penx' | ||
|
||
export const currentCommandAtom = atom<ListItem>(null as any as ListItem) | ||
|
||
export function useCurrentCommand() { | ||
const [currentCommand, setCurrentCommand] = useAtom(currentCommandAtom) | ||
return { currentCommand, setCurrentCommand } | ||
} |