Skip to content

Commit

Permalink
[grid] add styles and restProps support
Browse files Browse the repository at this point in the history
  • Loading branch information
hshoff committed Jul 18, 2017
1 parent d8cc3e3 commit f4cdb72
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 52 deletions.
47 changes: 26 additions & 21 deletions packages/vx-grid/src/grids/Columns.js
Expand Up @@ -14,34 +14,39 @@ export default function Columns({
strokeDasharray,
className,
numTicks = 10,
lineStyle,
...restProps
}) {
return (
<Group
className={cx('vx-columns', className)}
top={top}
left={left}
>
{scale.ticks && scale.ticks(numTicks).map((d,i) => {
const x = scale(d);
const fromPoint = new Point({
x,
y: 0,
});
const toPoint = new Point({
x,
y: height,
});
return (
<Line
key={`column-line-${d}-${i}`}
from={fromPoint}
to={toPoint}
stroke={stroke}
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
/>
);
})}
{scale.ticks &&
scale.ticks(numTicks).map((d, i) => {
const x = scale(d);
const fromPoint = new Point({
x,
y: 0,
});
const toPoint = new Point({
x,
y: height,
});
return (
<Line
key={`column-line-${d}-${i}`}
from={fromPoint}
to={toPoint}
stroke={stroke}
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
style={lineStyle}
{...restProps}
/>
);
})}
</Group>
);
}
10 changes: 5 additions & 5 deletions packages/vx-grid/src/grids/Grid.js
Expand Up @@ -17,13 +17,11 @@ export default function Grid({
strokeDasharray,
numTicksRows,
numTicksColumns,
rowLineStyle,
columnLineStyle,
}) {
return (
<Group
className={cx('vx-grid', className)}
top={top}
left={left}
>
<Group className={cx('vx-grid', className)} top={top} left={left}>
<Rows
className={className}
scale={yScale}
Expand All @@ -32,6 +30,7 @@ export default function Grid({
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
numTicks={numTicksRows}
style={rowLineStyle}
/>
<Columns
className={className}
Expand All @@ -41,6 +40,7 @@ export default function Grid({
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
numTicks={numTicksColumns}
style={columnLineStyle}
/>
</Group>
);
Expand Down
53 changes: 27 additions & 26 deletions packages/vx-grid/src/grids/Rows.js
Expand Up @@ -14,34 +14,35 @@ export default function Rows({
strokeDasharray,
className,
numTicks = 10,
lineStyle,
...restProps
}) {
return (
<Group
className={cx('vx-rows', className)}
top={top}
left={left}
>
{scale.ticks && scale.ticks(numTicks).map((d,i) => {
const y = scale(d);
const fromPoint = new Point({
x: 0,
y
});
const toPoint = new Point({
x: width,
y
});
return (
<Line
key={`row-line-${d}-${i}`}
from={fromPoint}
to={toPoint}
stroke={stroke}
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
/>
);
})}
<Group className={cx('vx-rows', className)} top={top} left={left}>
{scale.ticks &&
scale.ticks(numTicks).map((d, i) => {
const y = scale(d);
const fromPoint = new Point({
x: 0,
y,
});
const toPoint = new Point({
x: width,
y,
});
return (
<Line
key={`row-line-${d}-${i}`}
from={fromPoint}
to={toPoint}
stroke={stroke}
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
style={lineStyle}
{...restProps}
/>
);
})}
</Group>
);
}

0 comments on commit f4cdb72

Please sign in to comment.