Skip to content

Commit

Permalink
Simplify component structure
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhabib committed May 10, 2024
1 parent 1b31838 commit ed29c47
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 42 deletions.
6 changes: 0 additions & 6 deletions src/Playroom/Toolbar/Toolbar.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export const buttons = style([
export const panel = style([
sprinkles({
position: 'relative',
display: 'flex',
overflow: 'auto',
pointerEvents: 'auto',
}),
Expand All @@ -101,11 +100,6 @@ export const panel = style([
},
]);

export const preference = sprinkles({
position: 'absolute',
inset: 0,
});

export const transitionStyles = {
enter: style({
opacity: 0,
Expand Down
67 changes: 31 additions & 36 deletions src/Playroom/Toolbar/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,45 +169,40 @@ export default ({ themes: allThemes, widths: allWidths, snippets }: Props) => {
onExited={() => setLastActivePanel(undefined)}
>
<div className={styles.panel} id="custom-id">
<div className={styles.preference}>
{lastActivePanel === 'snippets' && (
<Snippets
snippets={snippets}
onHighlight={(snippet) => {
{lastActivePanel === 'snippets' && (
<Snippets
snippets={snippets}
onHighlight={(snippet) => {
dispatch({
type: 'previewSnippet',
payload: { snippet },
});
}}
onClose={(snippet) => {
if (snippet) {
dispatch({
type: 'previewSnippet',
type: 'persistSnippet',
payload: { snippet },
});
}}
onClose={(snippet) => {
if (snippet) {
dispatch({
type: 'persistSnippet',
payload: { snippet },
});
} else {
dispatch({ type: 'closeToolbar' });
}
}}
/>
)}

{lastActivePanel === 'frames' && (
<FramesPanel
availableWidths={allWidths}
availableThemes={allThemes}
/>
)}

{lastActivePanel === 'preview' && (
<PreviewPanel
themes={allThemes}
visibleThemes={visibleThemes}
/>
)}

{lastActivePanel === 'settings' && <SettingsPanel />}
</div>
} else {
dispatch({ type: 'closeToolbar' });
}
}}
/>
)}

{lastActivePanel === 'frames' && (
<FramesPanel
availableWidths={allWidths}
availableThemes={allThemes}
/>
)}

{lastActivePanel === 'preview' && (
<PreviewPanel themes={allThemes} visibleThemes={visibleThemes} />
)}

{lastActivePanel === 'settings' && <SettingsPanel />}
</div>
</CSSTransition>
</div>
Expand Down

0 comments on commit ed29c47

Please sign in to comment.