Skip to content

Commit

Permalink
feat: add webcontent no select placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Mar 8, 2023
1 parent 13fc093 commit cce31b0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/renderer/assets/web-page.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 40 additions & 1 deletion src/renderer/components/WebContent.tsx
@@ -1,5 +1,8 @@
import React, { useEffect, useRef } from 'react';
import styled from 'styled-components';
import { useTreeStore, WebsiteTreeNode } from '../store/tree';
import webpageSvg from '../assets/web-page.svg';
import { AddWebsiteBtn } from './AddWebsiteBtn';

const WebviewRender: React.FC<{ node: WebsiteTreeNode }> = React.memo(
(props) => {
Expand Down Expand Up @@ -64,11 +67,47 @@ const WebviewRender: React.FC<{ node: WebsiteTreeNode }> = React.memo(
);
WebviewRender.displayName = 'WebviewRender';

const WebPlaceholderRoot = styled.div`
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
flex-direction: column;
img {
width: 120px;
}
`;

const WebPlaceholder: React.FC = React.memo(() => {
useEffect(() => {
window.electron.ipcRenderer.sendMessage('hide-all-webview');
}, []);

return (
<WebPlaceholderRoot>
<div>
<img src={webpageSvg} />
</div>
<div>Please Select Any Page on Left</div>
<div>
<small>OR</small>
</div>
<div>
<AddWebsiteBtn />
</div>
</WebPlaceholderRoot>
);
});
WebPlaceholder.displayName = 'WebPlaceholder';

export const WebContent: React.FC = React.memo(() => {
const selectedNode = useTreeStore((state) => state.selectedNode);

if (!selectedNode) {
return <div>Please Select Node</div>;
return <WebPlaceholder />;
}

return <WebviewRender node={selectedNode} />;
Expand Down

0 comments on commit cce31b0

Please sign in to comment.