Skip to content

Commit

Permalink
feat(marimekko): expose thickness and dimensions scale
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Nov 16, 2020
1 parent a8437cc commit 914f185
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/marimekko/src/Marimekko.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const InnerMarimekko = <RawDatum,>({
partialMargin
)

const { computedData, bars } = useMarimekko<RawDatum>({
const { computedData, bars, thicknessScale, dimensionsScale } = useMarimekko<RawDatum>({
data,
id,
value,
Expand Down Expand Up @@ -71,6 +71,8 @@ const InnerMarimekko = <RawDatum,>({
const layerContext = useLayerContext<RawDatum>({
data: computedData,
bars,
thicknessScale,
dimensionsScale,
})

return (
Expand Down
10 changes: 9 additions & 1 deletion packages/marimekko/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,28 @@ export const useMarimekko = <RawDatum>({
return {
computedData,
bars,
thicknessScale,
dimensionsScale,
}
}

export const useLayerContext = <RawDatum>({
data,
bars,
thicknessScale,
dimensionsScale,
}: {
data: ComputedDatum<RawDatum>[]
bars: BarDatum<RawDatum>[]
thicknessScale: ScaleLinear<number, number>
dimensionsScale: ScaleLinear<number, number>
}): CustomLayerProps<RawDatum> =>
useMemo(
() => ({
data,
bars,
thicknessScale,
dimensionsScale,
}),
[data, bars]
[data, bars, thicknessScale, dimensionsScale]
)

0 comments on commit 914f185

Please sign in to comment.