* docs: migrating existing docs to docosaraus :) * log broken links * lint :p * fix * divide the doc into diff categories * fix * order sidebars and more * fix lint * point to installation * making docs better :) * fix * renaming git * renaming git * fix links * fix * update readme * fix * resolve duplicate url and make /docs as base url * fix * move main docs as well * making docs better * support mdx * update og * fix title * upgrade docusarus to stable version * use draculla theme * fix * make entire sidebar collapsable * live editor for footer wohoo * render excalidraw only on client to fix the prod build * migrate MainMenu to live editor too :) * lint :p * cleanup integration and use live editor and tabs * fix * Add welcome screen doc * Live Collaboration comp docs * Add collaborator example * Add example * add more * remove isCollaborating * Rewrite ref and move to sidebar * change color of links inside pre * add initial data * fix lint * Add styling * fix lint * Add example for customizing styles * fix lint * fix * fix lint * Add link to livecollabtrigger * fix * rewrite UIOptions to sidebar * move initialdata to sidebar * move render props to sidebar and rewrite renderTopRightUI and renderCustomStats * rewrite renderSidebar * update og * update url for testing * fix url * update readme * fix style * tweaks * Add highlight comp to highlight text * Add bash syntax highlight * fix * tweaks * fix * rewrite export utilities * fix restore * rewrite utils * move constants to sidebar * update readme * add copyright * fix links style * Add linkedin * tweaks * rename package to @excalidraw/excalidraw * enable algolia with dummy creds * tweaks to integration doc * tweak WelcomeScreen docs to reflect upcoming API changes * tweak components intro * tweak nomenclature * fix admonition * rename `components` sidebar item and change order of components list * uncollapse package section in sidebar * show level 4 haeadings in TOC * remove algolia * remove unused assets * capitalize C * tweak * rename components to App * rename components -> children-components in the routes * move notable used tools to intro * update MainMenu docs with `onSelect` preventDefault behavior * change sidebar label for children components * use code * tweak README & docs intro * tweak package development doc * make scrollbar gutter stable * tweak api intro * add admonition for export utils * use next * wip * wip * make excalidraw examples use current color theme & prefer system * fix welcomescreen docs * use latest temp release * fix component order * revert wip changes * use next * tweak * increase height to fix welcome screen hint * tweak editor height * update excal version * wrap Excal with forwardRef to fix refs * migrate contributing.md * fix broken links --------- Co-authored-by: dwelle <luzar.david@gmail.com>
141 lines
5.1 KiB
Plaintext
141 lines
5.1 KiB
Plaintext
# WelcomeScreen
|
|
|
|
When the canvas is empty, Excalidraw can show a welcome _splash_ screen with a logo, a few quick action items, and hints explaining what some of the UI buttons do. Once the user picks a tool, or has created an element on the canvas, the welcome screen will disappear.
|
|
|
|
You can enable this behavior by rendering a `WelcomeScreen` component like this:
|
|
|
|
```jsx live
|
|
function App() {
|
|
return (
|
|
<div style={{ height: "46rem" }}>
|
|
<Excalidraw>
|
|
<WelcomeScreen />
|
|
</Excalidraw>
|
|
</div>
|
|
);
|
|
}
|
|
```
|
|
|
|
You can also customize the welcome screen by passing children to the `WelcomeScreen` component. See below.
|
|
|
|
## <WelcomeScreen/>
|
|
|
|
This is the main component. If you render it without any children, we will render the default welcome screen.
|
|
|
|
You can customize which welcome screen subcomponents are rendered by passing them as children.
|
|
|
|
The welcome screen consists of two main groups of subcomponents:
|
|
|
|
1. [WelcomeScreen.Center](#welcomescreencenterlogo).
|
|
2. [WeelcomeScreen.Hints](#welcomescreenhints).
|
|
|
|
<img
|
|
src={require("@site/static/img/welcome-screen-overview.png").default}
|
|
alt="Excalidraw logo: Sketch handrawn like diagrams."
|
|
/>
|
|
|
|
### Center
|
|
|
|
`<WelcomeScreen.Center/>` subcomponent is the center piece of the welcome screen, containing the `logo`, `heading`, and `menu`. All three subcomponents are optional, and you can render whatever you wish into the center component.
|
|
|
|
```jsx live
|
|
function App() {
|
|
return (
|
|
<div style={{ height: "500px" }}>
|
|
<Excalidraw>
|
|
<WelcomeScreen>
|
|
<WelcomeScreen.Center>
|
|
<WelcomeScreen.Center.Logo />
|
|
<WelcomeScreen.Center.Heading>
|
|
Welcome Screen Heading!
|
|
</WelcomeScreen.Center.Heading>
|
|
<WelcomeScreen.Center.Menu>
|
|
<WelcomeScreen.Center.MenuItemLink href="https://github.com/excalidraw/excalidraw">
|
|
Excalidraw GitHub
|
|
</WelcomeScreen.Center.MenuItemLink>
|
|
<WelcomeScreen.Center.MenuItemHelp />
|
|
</WelcomeScreen.Center.Menu>
|
|
</WelcomeScreen.Center>
|
|
</WelcomeScreen>
|
|
</Excalidraw>
|
|
</div>
|
|
);
|
|
}
|
|
```
|
|
|
|
#### Logo
|
|
|
|
Use the `<WelcomeScreen.Center.Logo/>` to render a logo. By default it renders the Excalidraw logo and name. Supply `children` to customize.
|
|
|
|
#### Heading
|
|
|
|
Use the `<WelcomeScreen.Center.Heading/>` to render a heading below the logo. Supply `children` to change the default message.
|
|
|
|
#### Menu
|
|
|
|
`<WelcomeScreen.Center.Menu/>` is a wrapper component for the menu items. You can build your menu using the `<WelcomeScreen.Center.MenuItem>` and `<WelcomeScreen.Center.MenuItemLink>` components, render your own, or render one of the default menu items.
|
|
|
|
The default menu items are:
|
|
|
|
- `<WelcomeScreen.Center.MenuItemHelp/>` - opens the help dialog.
|
|
|
|
- `<WelcomeScreen.Center.MenuItemLoadScene/>` - open the load file dialog.
|
|
|
|
- `<WelcomeScreen.Center.MenuItemLiveCollaborationTrigger/>` - intended to open the live collaboration dialog. Works similarly to [`<LiveCollaborationTrigger>`](/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger) and you must supply `onSelect()` handler to integrate with your collaboration implementation.
|
|
|
|
#### MenuItem
|
|
|
|
The `<WelcomeScreen.Center.MenuItem/>` component can be used to render a menu item.
|
|
|
|
| Prop | Type | Required | Default | Description |
|
|
| --- | --- | --- | --- | --- |
|
|
| `onSelect` | `function` | Yes | | The handler is triggered when the item is selected. |
|
|
| `children` | `React.ReactNode` | Yes | | The content of the menu item |
|
|
| `icon` | `JSX.Element` | No | | The icon used in the menu item |
|
|
| `shortcut` | `string` | No | | The keyboard shortcut (label-only, does not affect behavior) |
|
|
|
|
**WelcomeScreen.Center.MenuItemLink**
|
|
|
|
To render an external link in a menu item, you can use this component.
|
|
|
|
| Prop | Type | Required | Default | Description |
|
|
| --- | --- | --- | --- | --- |
|
|
| `href` | `string` | Yes | | The `href` attribute to be added to the `anchor` element. |
|
|
| `children` | `React.ReactNode` | Yes | | The content of the menu item |
|
|
| `icon` | `JSX.Element` | No | | The icon used in the menu item |
|
|
| `shortcut` | `string` | No | | The keyboard shortcut (label-only, does not affect behavior) |
|
|
|
|
### Hints
|
|
|
|
These `<WelcomeScreen.Hints.*>` subcomponents render the UI hints. Text of each hint can be customized by supplying `children`.
|
|
|
|
```jsx live
|
|
function App() {
|
|
return (
|
|
<div style={{ height: "500px" }}>
|
|
<Excalidraw>
|
|
<WelcomeScreen>
|
|
<WelcomeScreen.Hints.ToolbarHint>
|
|
<p> ToolBar Hints </p>
|
|
</WelcomeScreen.Hints.ToolbarHint>
|
|
<WelcomeScreen.Hints.MenuHint />
|
|
<WelcomeScreen.Hints.HelpHint />
|
|
</WelcomeScreen>
|
|
</Excalidraw>
|
|
</div>
|
|
);
|
|
}
|
|
```
|
|
|
|
#### MenuHint
|
|
|
|
`<WelcomeScreen.Hints.MenuHint>` hint subcomponent for the main menu. Supply `children` to customize the hint text.
|
|
|
|
#### ToolbarHint
|
|
|
|
`<WelcomeScreen.Hints.ToolbarHint>` hint subcomponent for the toolbar. Supply `children` to customize the hint text.
|
|
|
|
#### Help
|
|
|
|
`<WelcomeScreen.Hints.Help>` hint subcomponent for the help dialog. Supply `children` to customize the hint text.
|