This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
360 additions
and
144 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,58 @@ | ||
import * as MobxReact from 'mobx-react'; | ||
import * as React from 'react'; | ||
import { WithStore } from '../store'; | ||
import * as Types from '../types'; | ||
|
||
export interface AppPaneProps { | ||
pane: Types.AppPane; | ||
force?: boolean; | ||
children: React.ReactNode; | ||
defaultSize?: { width: number | string; height: number | string }; | ||
enable?: { top?: boolean; right?: boolean; bottom?: boolean; left?: boolean }; | ||
minWidth?: number; | ||
minHeight?: number; | ||
} | ||
|
||
const Resizeable = require('re-resizable').default; | ||
|
||
@MobxReact.inject('store') | ||
@MobxReact.observer | ||
export class AppPane extends React.Component<AppPaneProps> { | ||
public render(): JSX.Element | null { | ||
const props = this.props as AppPaneProps & WithStore; | ||
const app = props.store.getApp(); | ||
|
||
if (!props.force && !app.isVisible(props.pane)) { | ||
return null; | ||
} | ||
|
||
const paneSize = props.pane ? app.getPaneSize(props.pane) : undefined; | ||
|
||
const defaultSize = paneSize | ||
? { width: paneSize.width, height: paneSize.height } | ||
: props.defaultSize; | ||
|
||
return ( | ||
<Resizeable | ||
handleStyles={{ right: { zIndex: 1 } }} | ||
defaultSize={defaultSize} | ||
enable={props.enable} | ||
minWidth={props.minWidth} | ||
minHeight={props.minHeight} | ||
onResizeStop={(_, __, el: HTMLElement) => { | ||
if (!props.pane) { | ||
return; | ||
} | ||
|
||
app.setPaneSize({ | ||
pane: props.pane, | ||
width: el.clientWidth, | ||
height: el.clientHeight | ||
}); | ||
}} | ||
> | ||
{this.props.children} | ||
</Resizeable> | ||
); | ||
} | ||
} |
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,21 @@ | ||
import * as MobxReact from 'mobx-react'; | ||
import * as React from 'react'; | ||
import { WithStore } from '../store'; | ||
import * as Types from '../types'; | ||
|
||
export interface AppViewProps { | ||
view: Types.AlvaView; | ||
} | ||
|
||
@MobxReact.inject('store') | ||
@MobxReact.observer | ||
export class AppView extends React.Component<AppViewProps> { | ||
public render(): JSX.Element | null { | ||
const props = this.props as AppViewProps & WithStore; | ||
if (props.store.getApp().getActiveView() !== props.view) { | ||
return null; | ||
} | ||
|
||
return <>{this.props.children}</>; | ||
} | ||
} |
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,124 @@ | ||
import { AppPane } from './app-pane'; | ||
|
||
import * as Sender from '../sender/client'; | ||
import * as Components from '../components'; | ||
import { ConnectPaneContainer } from './connect-pane-container'; | ||
import { ElementList } from './element-list'; | ||
import { MessageType } from '../message'; | ||
import * as MobxReact from 'mobx-react'; | ||
import { PageListContainer } from './page-list/page-list-container'; | ||
import { PatternListContainer } from './pattern-list'; | ||
import { PreviewPaneWrapper } from './preview-pane-wrapper'; | ||
import { PropertyListContainer } from './property-list'; | ||
import { PropertiesSwitch } from './properties-switch'; | ||
import { ProjectSettingsContainer } from './project-settings-container'; | ||
import * as React from 'react'; | ||
import * as Types from '../types'; | ||
import * as uuid from 'uuid'; | ||
import { ViewStore } from '../store'; | ||
|
||
@MobxReact.inject('store') | ||
@MobxReact.observer | ||
export class ViewDetails extends React.Component { | ||
public render(): JSX.Element { | ||
const props = this.props as { store: ViewStore }; | ||
|
||
return ( | ||
<React.Fragment> | ||
<AppPane | ||
pane={Types.AppPane.PagesPane} | ||
defaultSize={{ width: 140, height: '100%' }} | ||
enable={{ right: true }} | ||
minWidth={140} | ||
> | ||
<Components.SideBar | ||
side={Components.LayoutSide.Left} | ||
direction={Components.LayoutDirection.Column} | ||
border={Components.LayoutBorder.Side} | ||
> | ||
<PageListContainer /> | ||
</Components.SideBar> | ||
</AppPane> | ||
<AppPane | ||
pane={Types.AppPane.ElementsPane} | ||
defaultSize={{ width: 240, height: '100%' }} | ||
enable={{ right: true }} | ||
minWidth={240} | ||
> | ||
<Components.SideBar | ||
side={Components.LayoutSide.Left} | ||
direction={Components.LayoutDirection.Column} | ||
border={Components.LayoutBorder.Side} | ||
> | ||
<Components.ElementPane> | ||
<ElementList /> | ||
</Components.ElementPane> | ||
|
||
<AppPane | ||
force | ||
pane={Types.AppPane.PatternsPane} | ||
defaultSize={{ height: 500, width: '100%' }} | ||
enable={{ top: true }} | ||
minHeight={240} | ||
> | ||
<Components.PatternsPane> | ||
<PatternListContainer /> | ||
</Components.PatternsPane> | ||
</AppPane> | ||
</Components.SideBar> | ||
</AppPane> | ||
<div style={{ display: 'flex', flexGrow: 1, flexDirection: 'column' }}> | ||
<PreviewPaneWrapper | ||
isDragging={props.store.getDragging()} | ||
key="center" | ||
previewFrame={`http://localhost:${props.store.getServerPort()}/preview.html`} | ||
/> | ||
<AppPane | ||
pane={Types.AppPane.DevelopmentPane} | ||
defaultSize={{ width: '100%', height: 500 }} | ||
enable={{ top: true }} | ||
minHeight={240} | ||
> | ||
<div style={{ borderTop: `1px solid ${Components.Color.Grey90}` }} /> | ||
</AppPane> | ||
</div> | ||
<AppPane | ||
pane={Types.AppPane.PropertiesPane} | ||
defaultSize={{ width: 240, height: '100%' }} | ||
enable={{ left: true }} | ||
minWidth={240} | ||
> | ||
<Components.SideBar | ||
side={Components.LayoutSide.Right} | ||
direction={Components.LayoutDirection.Column} | ||
border={Components.LayoutBorder.Side} | ||
> | ||
<div style={{ flexShrink: 0, height: 40 }}> | ||
<PropertiesSwitch /> | ||
</div> | ||
{props.store | ||
.getPatternLibraries() | ||
.every(lib => lib.getOrigin() === Types.PatternLibraryOrigin.BuiltIn) && ( | ||
<ConnectPaneContainer | ||
onPrimaryButtonClick={() => props.store.connectPatternLibrary()} | ||
onSecondaryButtonClick={() => | ||
Sender.send({ | ||
type: MessageType.OpenExternalURL, | ||
id: uuid.v4(), | ||
payload: 'http://meetalva.github.io/example/example.alva' | ||
}) | ||
} | ||
/> | ||
)} | ||
<Components.PropertyPane> | ||
{props.store.getApp().getRightSidebarTab() === | ||
Types.RightSidebarTab.Properties && <PropertyListContainer />} | ||
{props.store.getApp().getRightSidebarTab() === | ||
Types.RightSidebarTab.ProjectSettings && <ProjectSettingsContainer />} | ||
</Components.PropertyPane> | ||
</Components.SideBar> | ||
</AppPane> | ||
</React.Fragment> | ||
); | ||
} | ||
} |
Oops, something went wrong.