-
Notifications
You must be signed in to change notification settings - Fork 0
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
27 changed files
with
555 additions
and
168 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
--- | ||
sidebar_position: 6 | ||
sidebar_position: 7 | ||
--- | ||
|
||
# Community | ||
|
||
If you have make and publish applications for use with Radix OS, make sure to reach out through Github so that we can feature your applications here. | ||
|
||
To submit your own application, click the edit link below. | ||
|
||
# Contributing | ||
|
||
Contributions are always welcome, whether it's documentation, feature requests or code. | ||
|
||
To contribute to code, you should first [submit an issue](https://github.com/imp-dance/radix-os/issues/new) (and then optionally create a pull request). | ||
|
||
## Workflow for local development | ||
|
||
After pulling the repository, run `pnpm install` and `pnpm dev` in the root directory. The dev server will import the code directly from the `packages/radix-os` folder so you can edit the package files and have hot reloading for the demo app. |
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,52 @@ | ||
--- | ||
sidebar_position: 5 | ||
--- | ||
|
||
# Components | ||
|
||
Radix OS exports some helper components for use in the operating system. | ||
|
||
## `SaveAsDialog` | ||
|
||
A dialog that lets a user choose a path and filename. | ||
|
||
```typescript | ||
type SaveAsDialogProps = { | ||
open: boolean; | ||
setOpen: (open: boolean) => void; | ||
onPathCreate: (path: string) => Promise<void>; | ||
}; | ||
``` | ||
|
||
![Preview](./save-as-dialog.jpg) | ||
|
||
## `OpenFileDialog` | ||
|
||
A dialog that lets a user open a file | ||
|
||
```typescript | ||
type SaveAsDialogProps = { | ||
open: boolean; | ||
setOpen: (open: boolean) => void; | ||
onFileOpened: (file: FsFile, path: string) => void; | ||
/** Determine if given file should be disabled */ | ||
fileDisabled?: (file: FsFile) => boolean; | ||
}; | ||
``` | ||
|
||
![Preview](./open-file-dialog.jpg) | ||
|
||
## `Explorer` | ||
|
||
The raw underlying version of the Explorer application, without the application window. Used internally in `OpenFileDialog` and `SaveAsDialog`. | ||
|
||
```tsx | ||
type ExplorerProps = { | ||
initialPath?: string; | ||
windowId?: symbol; | ||
onPathChange?: (path: string) => void; | ||
disableFiles?: boolean; | ||
fileDisabled?: (file: FsFile) => boolean; | ||
onRequestOpenFile?: (file: FsFile, path: string) => void; | ||
}; | ||
``` |
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,5 +1,5 @@ | ||
--- | ||
sidebar_position: 5 | ||
sidebar_position: 6 | ||
--- | ||
|
||
# Customization | ||
|
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,5 +1,5 @@ | ||
--- | ||
sidebar_position: 7 | ||
sidebar_position: 8 | ||
--- | ||
|
||
# FAQ | ||
|
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
78 changes: 78 additions & 0 deletions
78
packages/radix-os/src/components/OpenFileDialog/OpenFileDialog.tsx
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,78 @@ | ||
import { Button, Card, Dialog, Flex } from "@radix-ui/themes"; | ||
import { useState } from "react"; | ||
import { useFileSystemQuery } from "../../api/fs/fs-api"; | ||
import { findNodeByPath } from "../../services/fs/tree-helpers"; | ||
import { FsFile } from "../../stores/fs"; | ||
import { Explorer } from "../apps/Explorer/Explorer"; | ||
|
||
export function OpenFileDialog(props: { | ||
open: boolean; | ||
setOpen: (open: boolean) => void; | ||
onFileOpened: (file: FsFile, path: string) => void; | ||
fileDisabled?: (file: FsFile) => boolean; | ||
}) { | ||
const [selectedFile, setSelectedFile] = useState<null | { | ||
file: FsFile; | ||
path: string; | ||
}>(null); | ||
const fsQuery = useFileSystemQuery(""); | ||
const root = fsQuery?.data ?? null; | ||
const [path, setPath] = useState(""); | ||
|
||
const node = root ? findNodeByPath(path, root) : null; | ||
|
||
const isValid = selectedFile !== null; | ||
return ( | ||
<Dialog.Root open={props.open} onOpenChange={props.setOpen}> | ||
<Dialog.Content size="2"> | ||
<Dialog.Title size="3">Open file</Dialog.Title> | ||
<Dialog.Description color="gray" size="1"> | ||
Select file to open | ||
</Dialog.Description> | ||
<Card | ||
style={{ | ||
background: "var(--gray-1)", | ||
minHeight: 250, | ||
display: "grid", | ||
gridTemplateRows: "1fr min-content", | ||
gridTemplateColumns: "1fr", | ||
border: "1px solid var(--gray-3)", | ||
}} | ||
size="1" | ||
my="3" | ||
> | ||
<Explorer | ||
initialPath={path} | ||
onPathChange={setPath} | ||
fileDisabled={props.fileDisabled} | ||
onRequestOpenFile={(file, path) => { | ||
setSelectedFile({ file, path }); | ||
}} | ||
/> | ||
</Card> | ||
<Flex gap="3" mt="4" justify="end"> | ||
<Dialog.Close> | ||
<Button variant="soft" color="gray"> | ||
Cancel | ||
</Button> | ||
</Dialog.Close> | ||
<Dialog.Close> | ||
<Button | ||
variant="solid" | ||
color="green" | ||
onClick={() => { | ||
if (selectedFile) { | ||
const { file, path } = selectedFile; | ||
props.onFileOpened(file, path); | ||
} | ||
}} | ||
disabled={!isValid} | ||
> | ||
Open file | ||
</Button> | ||
</Dialog.Close> | ||
</Flex> | ||
</Dialog.Content> | ||
</Dialog.Root> | ||
); | ||
} |
Oops, something went wrong.