-
Notifications
You must be signed in to change notification settings - Fork 221
feat: update styling of layout and element pane #393
Changes from 23 commits
ca2c1d9
b0cc943
551ec59
71d38c9
744f262
76ac1ae
71c298d
42284b6
c6c52ff
4f6f148
686f264
643d538
8904d0a
5500cbf
4fe6cbf
9c223fc
57208e6
dbe48a1
c7de980
dd1a6c4
f6212c4
4b084dd
9f9f31d
3b79de9
40a6397
05dd8a2
ed39ced
70d4708
d8f8408
0a20c6e
c42f0e2
a192919
344f2cb
a3b2dc8
0da7a7c
e5ea5f0
81a7e2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
import Button, { Order } from '../../lsg/patterns/button'; | ||
import AddButton from '../../lsg/patterns/add-button'; | ||
import { ChromeContainer } from '../chrome/chrome-container'; | ||
import { colors } from '../../lsg/patterns/colors'; | ||
import Copy, { Size as CopySize } from '../../lsg/patterns/copy'; | ||
import { remote } from 'electron'; | ||
import { ElementList } from '../../component/container/element-list'; | ||
import ElementPane from '../../lsg/patterns/panes/element-pane'; | ||
import * as FileExtraUtils from 'fs-extra'; | ||
import globalStyles from '../../lsg/patterns/global-styles'; | ||
import { Headline } from '../../lsg/patterns/headline'; | ||
import { IconName, IconRegistry } from '../../lsg/patterns/icons'; | ||
import Layout, { MainArea, SideBar } from '../../lsg/patterns/layout'; | ||
import Link from '../../lsg/patterns/link'; | ||
import { createMenu } from '../../electron/menu'; | ||
import * as MobX from 'mobx'; | ||
import { observer } from 'mobx-react'; | ||
import * as PathUtils from 'path'; | ||
import { PatternListContainer } from '../../component/container/pattern-list'; | ||
import { PatternListContainer } from './pattern-list'; | ||
import PatternsPane from '../../lsg/patterns/panes/patterns-pane'; | ||
import { PreviewPaneWrapper } from '../../component/container/preview-pane-wrapper'; | ||
import * as ProcessUtils from 'process'; | ||
import { PropertyList } from './property-list'; | ||
import PropertyPane from '../../lsg/patterns/panes/property-pane'; | ||
import * as React from 'react'; | ||
import Space, { Size as SpaceSize } from '../../lsg/patterns/space'; | ||
import SplashScreen from '../../lsg/patterns/splash-screen'; | ||
import { Store } from '../../store/store'; | ||
import { SplashScreen } from './splash-screen'; | ||
import { RightPane, Store } from '../../store/store'; | ||
|
||
globalStyles(); | ||
|
||
|
@@ -36,32 +31,22 @@ export class App extends React.Component { | |
private static PROPERTIES_LIST_ID = 'propertieslist'; | ||
|
||
@MobX.observable protected activeTab: string = App.PATTERN_LIST_ID; | ||
|
||
private ctrlDown: boolean = false; | ||
private shiftDown: boolean = false; | ||
|
||
public constructor(props: {}) { | ||
super(props); | ||
this.handleTabNaviagtionClick = this.handleTabNaviagtionClick.bind(this); | ||
this.handleMainWindowClick = this.handleMainWindowClick.bind(this); | ||
this.handleCreateNewSpaceClick = this.handleCreateNewSpaceClick.bind(this); | ||
this.handleOpenSpaceClick = this.handleOpenSpaceClick.bind(this); | ||
} | ||
|
||
public componentDidMount(): void { | ||
createMenu(); | ||
this.redirectUndoRedo(); | ||
} | ||
|
||
private getDevTools(): React.StatelessComponent | null { | ||
try { | ||
const DevToolsExports = require('mobx-react-devtools'); | ||
return DevToolsExports ? DevToolsExports.default : undefined; | ||
} catch (error) { | ||
return null; | ||
} | ||
} | ||
|
||
protected handleCreateNewSpaceClick(): void { | ||
// TODO: Should move to store | ||
protected createNewSpace(): void { | ||
let appPath: string = remote.app.getAppPath().replace('.asar', '.asar.unpacked'); | ||
if (appPath.indexOf('node_modules') >= 0) { | ||
appPath = ProcessUtils.cwd(); | ||
|
@@ -82,18 +67,20 @@ export class App extends React.Component { | |
); | ||
} | ||
|
||
private getDevTools(): React.StatelessComponent | null { | ||
try { | ||
const DevToolsExports = require('mobx-react-devtools'); | ||
return DevToolsExports ? DevToolsExports.default : undefined; | ||
} catch (error) { | ||
return null; | ||
} | ||
} | ||
|
||
private handleMainWindowClick(): void { | ||
Store.getInstance().setElementFocussed(false); | ||
createMenu(); | ||
} | ||
|
||
protected handleOpenSpaceClick(): void { | ||
remote.dialog.showOpenDialog({ properties: ['openDirectory'] }, filePaths => { | ||
store.openStyleguide(filePaths[0]); | ||
store.openFirstPage(); | ||
}); | ||
} | ||
|
||
protected handleTabNaviagtionClick(evt: React.MouseEvent<HTMLElement>, id: string): void { | ||
this.activeTab = id; | ||
} | ||
|
@@ -106,6 +93,14 @@ export class App extends React.Component { | |
return this.activeTab === App.PROPERTIES_LIST_ID; | ||
} | ||
|
||
// TODO: Should move to store | ||
protected openSpace(): void { | ||
remote.dialog.showOpenDialog({ properties: ['openDirectory'] }, filePaths => { | ||
store.openStyleguide(filePaths[0]); | ||
store.openFirstPage(); | ||
}); | ||
} | ||
|
||
private redirectUndoRedo(): void { | ||
document.body.onkeydown = event => { | ||
if (event.keyCode === 16) { | ||
|
@@ -145,54 +140,51 @@ export class App extends React.Component { | |
const DevTools = this.getDevTools(); | ||
|
||
return ( | ||
<Layout directionVertical handleClick={this.handleMainWindowClick}> | ||
<Layout directionVertical onClick={this.handleMainWindowClick}> | ||
<ChromeContainer /> | ||
|
||
<MainArea> | ||
{project && [ | ||
<SideBar key="left" directionVertical hasPaddings> | ||
<ElementPane> | ||
<ElementList /> | ||
</ElementPane> | ||
<PatternsPane> | ||
<PatternListContainer /> | ||
</PatternsPane> | ||
</SideBar>, | ||
<PreviewPaneWrapper key="center" previewFrame={previewFramePath} />, | ||
<SideBar key="right" directionVertical hasPaddings> | ||
<PropertyPane> | ||
<PropertyList /> | ||
</PropertyPane> | ||
</SideBar> | ||
]} | ||
|
||
{!project && ( | ||
<SplashScreen> | ||
<Space sizeBottom={SpaceSize.L}> | ||
<Headline textColor={colors.grey20} order={2}> | ||
Getting started with Alva | ||
</Headline> | ||
</Space> | ||
<Space sizeBottom={SpaceSize.XXXL}> | ||
<Copy size={CopySize.M} textColor={colors.grey20}> | ||
You can open an existing Alva space or create a new one based on our | ||
designkit including some basic components to kickstart your project. | ||
</Copy> | ||
</Space> | ||
<Space sizeBottom={SpaceSize.S}> | ||
<Button handleClick={this.handleCreateNewSpaceClick} order={Order.Primary}> | ||
Create new Alva space | ||
</Button> | ||
</Space> | ||
<Link color={colors.grey50} onClick={this.handleOpenSpaceClick}> | ||
<Copy size={CopySize.S}>or open existing Alva space</Copy> | ||
</Link> | ||
</SplashScreen> | ||
{project ? ( | ||
<React.Fragment> | ||
<SideBar | ||
key="left" | ||
directionVertical | ||
onClick={() => store.setSelectedElement()} | ||
> | ||
<ElementPane> | ||
<ElementList /> | ||
<AddButton | ||
active={store.getRightPane() === RightPane.Patterns} | ||
label="Add Elements" | ||
onClick={e => { | ||
e.stopPropagation(); | ||
store.setRightPane(RightPane.Patterns); | ||
store.setSelectedElement(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite get how the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As interacting with the left layers changes the right property pane, the idea was to add a button that shows the pattern view. And the short cut for not having to directly click on the button left bottom would be to click on the unused area in the element view (so it unselects the element). Then you always see on the right side what you want to do (like inspect on macOS does). I’d love to test this in a kind of usertest, if we find out it doesn’t work – let’s change it. |
||
}} | ||
/> | ||
</ElementPane> | ||
</SideBar> | ||
<PreviewPaneWrapper key="center" previewFrame={previewFramePath} /> | ||
<SideBar key="right" directionVertical hasPaddings> | ||
{store.getRightPane() === RightPane.Properties && ( | ||
<PropertyPane> | ||
<PropertyList /> | ||
</PropertyPane> | ||
)} | ||
{store.getRightPane() === RightPane.Patterns && ( | ||
<PatternsPane> | ||
<PatternListContainer /> | ||
</PatternsPane> | ||
)} | ||
</SideBar> | ||
</React.Fragment> | ||
) : ( | ||
<SplashScreen | ||
onPrimaryButtonClick={() => this.createNewSpace()} | ||
onSecondaryButtonClick={() => this.openSpace()} | ||
/> | ||
)} | ||
</MainArea> | ||
|
||
<IconRegistry names={IconName} /> | ||
|
||
{DevTools ? <DevTools /> : null} | ||
</Layout> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be invisible / disabled if the right sidebar displays
RightPane.Patterns
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought an active state would be cooler, to not disturb the user because the button is sometimes not there. But let’s test that as well (see below)!