Skip to content

Commit

Permalink
#599: Add a placeholder when the base panel view is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Jul 2, 2023
1 parent c02e02e commit bf0746d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [#588](https://github.com/estruyf/vscode-front-matter/issues/588): Added extensibility support to override card fields
- [#591](https://github.com/estruyf/vscode-front-matter/issues/591): Support for date format in the `datetime` field
- [#593](https://github.com/estruyf/vscode-front-matter/issues/593): Add support for date formatting in the preview path
- [#599](https://github.com/estruyf/vscode-front-matter/issues/599): Add a placeholder when the base panel view is empty

### ⚡️ Optimizations

Expand Down
23 changes: 23 additions & 0 deletions src/panelWebView/components/BaseView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ const BaseView: React.FunctionComponent<IBaseViewProps> = ({
return Object.values(FEATURE_FLAG.panel).filter(v => v !== FEATURE_FLAG.panel.globalSettings)
}, [FEATURE_FLAG.panel]);

const isSomethingShown = useMemo(() => {
const panelModeValues = (mode?.features || []).filter(v => v.startsWith('panel.'));

if (panelModeValues.length === 0) {
return true;
}

if (panelModeValues.includes(FEATURE_FLAG.panel.globalSettings) ||
panelModeValues.includes(FEATURE_FLAG.panel.actions) ||
panelModeValues.includes(FEATURE_FLAG.panel.recentlyModified) ||
panelModeValues.includes(FEATURE_FLAG.panel.otherActions)) {
return true;
}
}, [mode?.features]);

return (
<div className="frontmatter">
<div className={`ext_actions`}>
Expand Down Expand Up @@ -103,6 +118,14 @@ const BaseView: React.FunctionComponent<IBaseViewProps> = ({
</FeatureFlag>
</div>

{
!isSomethingShown && (
<div className={`base__empty`}>
Open a file to see more actions
</div>
)
}

<SponsorMsg isBacker={settings?.isBacker} />
</div>
);
Expand Down
14 changes: 14 additions & 0 deletions src/panelWebView/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1098,3 +1098,17 @@ vscode-divider {
}
}
}

/* Empty base view */
.base__empty {
display: flex;
color: var(--vscode-foreground);
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
font-size: 2em;
opacity: 0.8;
text-align: center;
padding: 1rem 1.25rem;
}

0 comments on commit bf0746d

Please sign in to comment.