-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Extracted the component preview toggle
The preview toggle is re-implemented based on the toggle mode component so that it can be re-used in the preview panel and the content edit form. The component is moved to its own component file to declutter and make it more clear where each component is implemented. The ComponentPreview is cleaned up to make use of the new component, and the same applies for the Content edit form.
- Loading branch information
1 parent
7e3e106
commit 30cbdfe
Showing
3 changed files
with
39 additions
and
49 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {FormattedMessage} from 'react-intl'; | ||
|
||
import ModeToggle from '@/components/ModeToggle'; | ||
|
||
export type PreviewState = 'rich' | 'JSON'; | ||
|
||
export interface PreviewModeToggleProps { | ||
previewMode: PreviewState; | ||
setPreviewMode: (mode: PreviewState) => void; | ||
} | ||
|
||
const PreviewModeToggle: React.FC<PreviewModeToggleProps> = ({previewMode, setPreviewMode}) => ( | ||
<ModeToggle<PreviewState> | ||
name="previewMode" | ||
currentMode={previewMode} | ||
onToggle={mode => setPreviewMode(mode)} | ||
modes={[ | ||
{ | ||
value: 'rich', | ||
label: ( | ||
<FormattedMessage description="Component 'Rich' preview mode" defaultMessage="Form" /> | ||
), | ||
}, | ||
{ | ||
value: 'JSON', | ||
label: ( | ||
<FormattedMessage description="Component 'JSON' preview mode" defaultMessage="JSON" /> | ||
), | ||
}, | ||
]} | ||
/> | ||
); | ||
|
||
export default PreviewModeToggle; |
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