You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(README): update Panel component description and add download functionality details
- Enhanced the description of the Panel component to include the new download button and its integration with the CodeEditor's functionality.
- Updated the properties table to reflect the addition of the download feature, including the `onDownloadClick` callback and its behavior.
- Added a new section detailing the `downloadContent` method, including examples and supported file extensions for improved documentation clarity.
The Panel component provides a toolbar interface for the CodeEditor with formatting, copying, and custom action buttons. It displays at the top of the CodeEditor and can include a title, action buttons, and custom content.
80
+
The Panel component provides a toolbar interface for the CodeEditor with formatting, copying, download, and custom action buttons. It displays at the top of the CodeEditor and can include a title, action buttons, and custom content. When used within a CodeEditor, the Panel automatically integrates with the editor's functionality - the download button performs actual file downloads with appropriate extensions, undo/redo buttons operate on the editor history, and the format button processes the editor content.
81
81
82
82
#### Example
83
83
@@ -112,22 +112,22 @@ import CloudIcon from '@leafygreen-ui/icon';
|`baseFontSize`_(optional)_| Font size of text in the panel. Controls the typography scale used for the panel title and other text elements. |`14 \| 16`|`14`|
118
-
|`customSecondaryButtons`_(optional)_| Array of custom secondary buttons to display in the secondary menu. Each button can include a label, icon, click handler, href, and aria-label for accessibility. |`Array<SecondaryButtonConfig>`|`undefined`|
119
-
|`darkMode`_(optional)_| Determines if the component appears in dark mode. When not provided, the component will inherit the dark mode state from the LeafyGreen Provider. |`boolean`|`undefined`|
120
-
|`innerContent`_(optional)_| React node to render between the title and the buttons. Can be used to add custom controls to the panel. |`React.ReactNode`|`undefined`|
121
-
|`onCopyClick`_(optional)_| Callback fired when the copy button is clicked. Called after the copy operation is attempted. |`() => void`|`undefined`|
122
-
|`onDownloadClick`_(optional)_| Callback fired when the download button in the secondary menu is clicked. Called after the download operation is attempted. |`() => void`|`undefined`|
123
-
|`onFormatClick`_(optional)_| Callback fired when the format button is clicked. Called after the formatting operation is attempted. |`() => void`|`undefined`|
124
-
|`onRedoClick`_(optional)_| Callback fired when the redo button in the secondary menu is clicked. Called after the redo operation is attempted. |`() => void`|`undefined`|
125
-
|`onUndoClick`_(optional)_| Callback fired when the undo button in the secondary menu is clicked. Called after the undo operation is attempted. |`() => void`|`undefined`|
126
-
|`onViewShortcutsClick`_(optional)_| Callback fired when the view shortcuts button in the secondary menu is clicked. Called after the view shortcuts operation is attempted. |`() => void`|`undefined`|
127
-
|`showCopyButton`_(optional)_| Determines whether to show the copy button in the panel. When enabled, users can copy the editor content to their clipboard. |`boolean`|`undefined`|
128
-
|`showFormatButton`_(optional)_| Determines whether to show the format button in the panel. When enabled and formatting is available for the current language, users can format/prettify their code. |`boolean`|`undefined`|
129
-
|`showSecondaryMenuButton`_(optional)_| Determines whether to show the secondary menu button (ellipsis icon) in the panel. When enabled, displays a menu with additional actions like undo, redo, download, and view shortcuts. |`boolean`|`undefined`|
130
-
|`title`_(optional)_| Title text to display in the panel header. Typically used to show the current language or content description. |`string`|`undefined`|
|`baseFontSize`_(optional)_| Font size of text in the panel. Controls the typography scale used for the panel title and other text elements. |`14 \| 16`|`14`|
118
+
|`customSecondaryButtons`_(optional)_| Array of custom secondary buttons to display in the secondary menu. Each button can include a label, icon, click handler, href, and aria-label for accessibility. |`Array<SecondaryButtonConfig>`|`undefined`|
119
+
|`darkMode`_(optional)_| Determines if the component appears in dark mode. When not provided, the component will inherit the dark mode state from the LeafyGreen Provider. |`boolean`|`undefined`|
120
+
|`innerContent`_(optional)_| React node to render between the title and the buttons. Can be used to add custom controls to the panel. |`React.ReactNode`|`undefined`|
121
+
|`onCopyClick`_(optional)_| Callback fired when the copy button is clicked. Called after the copy operation is attempted. |`() => void`|`undefined`|
122
+
|`onDownloadClick`_(optional)_| Callback fired when the download button in the secondary menu is clicked. Called after the actual file download is triggered. When used within CodeEditor, downloads the editor content automatically.|`() => void`|`undefined`|
123
+
|`onFormatClick`_(optional)_| Callback fired when the format button is clicked. Called after the formatting operation is attempted. |`() => void`|`undefined`|
124
+
|`onRedoClick`_(optional)_| Callback fired when the redo button in the secondary menu is clicked. Called after the redo operation is attempted. |`() => void`|`undefined`|
125
+
|`onUndoClick`_(optional)_| Callback fired when the undo button in the secondary menu is clicked. Called after the undo operation is attempted. |`() => void`|`undefined`|
126
+
|`onViewShortcutsClick`_(optional)_| Callback fired when the view shortcuts button in the secondary menu is clicked. Called after the view shortcuts operation is attempted. |`() => void`|`undefined`|
127
+
|`showCopyButton`_(optional)_| Determines whether to show the copy button in the panel. When enabled, users can copy the editor content to their clipboard. |`boolean`|`undefined`|
128
+
|`showFormatButton`_(optional)_| Determines whether to show the format button in the panel. When enabled and formatting is available for the current language, users can format/prettify their code. |`boolean`|`undefined`|
129
+
|`showSecondaryMenuButton`_(optional)_| Determines whether to show the secondary menu button (ellipsis icon) in the panel. When enabled, displays a menu with additional actions like undo, redo, download, and view shortcuts. |`boolean`|`undefined`|
130
+
|`title`_(optional)_| Title text to display in the panel header. Typically used to show the current language or content description. |`string`|`undefined`|
131
131
132
132
#### `SecondaryButtonConfig`
133
133
@@ -296,6 +296,12 @@ function MyComponent() {
296
296
}
297
297
};
298
298
299
+
const handleDownload = () => {
300
+
if (editorRef.current) {
301
+
editorRef.current.downloadContent('my-script'); // Downloads as 'my-script.js'
0 commit comments