Skip to content

Commit

Permalink
VALIS-2-file-props (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
forresttanaka authored Mar 11, 2020
1 parent c9affdc commit c3b366e
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 57 deletions.
1 change: 1 addition & 0 deletions @types/track/TrackModel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export declare type TrackModel = {
type: string;
name: string;
longname?: string;
heightPx?: number;
expandedHeightPx?: number;
highlightLocation?: string;
Expand Down
20 changes: 10 additions & 10 deletions dist/valis-hpgv.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/valis-hpgv.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/valis-hpgv.react-peer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/valis-hpgv.react-peer.js.map

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions src/styles/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@
border-bottom-right-radius: 0;
}

.hpgv_track-expander {
position: absolute;
right: 0;
left: 0;
bottom: 0;
margin: auto;
width: 16px;
height: 16px;
padding: 4px;
cursor: pointer;
line-height: 0;
}

.hpgv_track-expander > svg {
display: block;
}

/* The following are draw via WebGL, so only the properties CSS used here can be changed */
.hpgv_panel {
--axis: black;
Expand Down
17 changes: 17 additions & 0 deletions src/styles/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@
border-bottom-right-radius: 0;
}

.hpgv_track-expander {
position: absolute;
right: 0;
left: 0;
bottom: 0;
margin: auto;
width: 16px;
height: 16px;
padding: 4px;
cursor: pointer;
line-height: 0;
}

.hpgv_track-expander > svg {
display: block;
}

/* The following are draw via WebGL, so only the properties CSS used here can be changed */
.hpgv_panel {
color: #737d94;
Expand Down
1 change: 1 addition & 0 deletions src/track/TrackModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type TrackModel = {

// display properties
name: string,
longname?: string,
heightPx?: number,
expandedHeightPx?: number,

Expand Down
67 changes: 29 additions & 38 deletions src/ui/TrackViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import React = require("react");
import IconButton from "@material-ui/core/IconButton";
import AddIcon from "@material-ui/icons/Add";
import CloseIcon from "@material-ui/icons/Close";
import ExpandLessIcon from "@material-ui/icons/ExpandLess";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import Animator from "../Animator";
import Object2D from "engine/ui/Object2D";
import Rect from "engine/ui/Rect";
Expand All @@ -31,6 +29,21 @@ import { OpenSansRegular } from "./font";
import { StyleProxy } from "./util/StyleProxy";
import { TrackEvent } from "../track/TrackEvent";


// Icons to collapse and expand track header.
const ExpandLessIcon = () => (
<svg version="1.1" focusable="false" viewBox="0 0 12 7.4">
<path d="M6,0L0,6l1.4,1.4L6,2.8l4.6,4.6L12,6L6,0z"/>
</svg>
);

const ExpandMoreIcon = () => (
<svg version="1.1" focusable="false" viewBox="0 0 12 7.4">
<path d="M10.6,0L6,4.6L1.4,0L0,1.4l6,6l6-6L10.6,0z"/>
</svg>
);


export class TrackViewer extends Object2D {

// layout settings
Expand Down Expand Up @@ -1045,65 +1058,43 @@ export class TrackViewer extends Object2D {
isExpanded: boolean,
style?: React.CSSProperties
}) {
const iconSize = 32;
const margin = 16;
const iconSize = 16;
const margin = 8;

const ArrowElem = props.isExpanded ? ExpandLessIcon : ExpandMoreIcon;

const expandArrow = (<ArrowElem
style={{
marginTop: 8,
marginLeft: margin,
color: 'inherit',
}}
viewBox={`0 0 ${iconSize} ${iconSize}`}
/>);
return <div
className="hpgv_ui-block hpgv_track-header"
style={{
position: 'relative',
width: '100%',
height: '100%',
overflow: 'hidden',
display: 'flex',
alignItems: 'center',
...props.style,
}}
>
<div>{props.isExpanded && props.model.longname ? props.model.longname : props.model.name}</div>
{
props.expandable ? (
<div
role="button"
tabIndex={0}
aria-expanded={props.isExpanded}
onClick={() => {
props.setExpanded(!props.isExpanded);
}}
style={{
cursor: 'pointer',
userSelect: 'none',
width: iconSize,
height: iconSize,
// minWidth: iconSize,
marginRight: margin,
onKeyDown={(e) => {
if (e.keyCode === 13 || e.keyCode === 32) {
props.setExpanded(!props.isExpanded);
e.preventDefault();
}
}}
className="hpgv_track-expander"
>
{expandArrow}
<ArrowElem />
</div>
) : (
<div
style={{
width: iconSize,
height: iconSize,
// minWidth: iconSize,
marginRight: margin,
}}
></div>
)
) : null
}
<div style={{
flexGrow: 1,
marginRight: margin,
}}>
{props.model.name}
</div>
</div>
}

Expand Down

0 comments on commit c3b366e

Please sign in to comment.