Skip to content

Commit 62dae1c

Browse files
committed
Helper function for formatting css grid strings.
1 parent 7cadc1b commit 62dae1c

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/components/ScaffoldViewer.jsx

+10-15
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import fastaParser from "./../helpers/fasta";
44
import computeLabelWidth from "../helpers/computeLabelWidth";
55
import BaseAlignment from "./BaseAlignment.jsx";
66
import SiteAxis from "./SiteAxis.jsx";
7-
import Placeholder from "./Placeholder.jsx";
87
import SequenceAxis from "./SequenceAxis.jsx";
98
import Scaffold from "./Scaffold.jsx";
109
import ScrollBroadcaster from "./../helpers/ScrollBroadcaster";
10+
import css_grid_format from "../helpers/format";
1111
import { nucleotide_color, nucleotide_text_color } from "./../helpers/colors";
1212

1313
class ScaffoldViewer extends Component {
@@ -18,14 +18,8 @@ class ScaffoldViewer extends Component {
1818
}
1919
setScrollingEvents(props) {
2020
if (props.fasta) {
21-
const {
22-
width,
23-
height,
24-
axis_height,
25-
alignment_width,
26-
alignment_height
27-
} = props;
28-
const { full_pixel_width, full_pixel_height, label_width } = this;
21+
const { alignment_width, alignment_height } = props;
22+
const { full_pixel_width, full_pixel_height } = this;
2923
this.scroll_broadcaster = new ScrollBroadcaster({
3024
width: full_pixel_width,
3125
height: full_pixel_height,
@@ -48,7 +42,7 @@ class ScaffoldViewer extends Component {
4842
}
4943
initialize(props) {
5044
if (props.fasta) {
51-
const { fasta, site_size, width, height, axis_height } = props;
45+
const { fasta, site_size } = props;
5246
this.sequence_data = fastaParser(fasta);
5347
const { sequence_data } = this;
5448
const { label_padding } = this.props;
@@ -64,13 +58,14 @@ class ScaffoldViewer extends Component {
6458
return <div style={container_style} id="alignmentjs-main-div" />;
6559
}
6660
const { alignment_width, alignment_height, scaffold_width } = this.props,
67-
gridTemplateColumns = `${
68-
this.label_width
69-
}px ${alignment_width}px ${scaffold_width}px`,
7061
container_style = {
7162
display: "grid",
72-
gridTemplateColumns: gridTemplateColumns,
73-
gridTemplateRows: `20px 20px ${alignment_height}px`
63+
gridTemplateColumns: css_grid_format([
64+
this.label_width,
65+
alignment_width,
66+
scaffold_width
67+
]),
68+
gridTemplateRows: css_grid_format([20, 20, alignment_height])
7469
},
7570
reference_sequence_data = this.sequence_data.slice(0, 1),
7671
remaining_sequence_data = this.sequence_data.slice(1);

src/helpers/format.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default function(dimensions) {
2+
if (!dimensions) return null;
3+
return dimensions.join("px ") + "px";
4+
}

0 commit comments

Comments
 (0)