From 5e4ea120ffdb93134616c4f5677a6338539b0544 Mon Sep 17 00:00:00 2001 From: plouc Date: Fri, 26 Jun 2020 13:34:41 +0900 Subject: [PATCH] feat(treemap): restore pattern and gradient support for TreeMap component --- packages/treemap/src/TreeMap.js | 7 ++- packages/treemap/stories/treemap.stories.js | 47 +++++++++++++++++-- .../gradients/GradientsIllustrations.js | 9 ++-- .../guides/patterns/PatternsIllustrations.js | 11 +++-- website/src/data/components/treemap/meta.yml | 2 + 5 files changed, 62 insertions(+), 14 deletions(-) diff --git a/packages/treemap/src/TreeMap.js b/packages/treemap/src/TreeMap.js index 223274130e..39858ee9c7 100644 --- a/packages/treemap/src/TreeMap.js +++ b/packages/treemap/src/TreeMap.js @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ import React from 'react' -import { SvgWrapper, withContainer, useDimensions } from '@nivo/core' +import { SvgWrapper, withContainer, useDimensions, bindDefs } from '@nivo/core' import { TreeMapDefaultProps, TreeMapPropTypes } from './props' import { useTreeMap } from './hooks' import TreeMapNodes from './TreeMapNodes' @@ -31,6 +31,7 @@ const TreeMap = ({ borderWidth, borderColor, defs, + fill, enableLabel, label, labelTextColor, @@ -81,8 +82,10 @@ const TreeMap = ({ parentLabelTextColor, }) + const boundDefs = bindDefs(defs, nodes, fill) + return ( - + ( +const stories = storiesOf('TreeMap', module) + +stories.add('custom tooltip', () => ( ( @@ -31,3 +33,42 @@ storiesOf('TreeMap', module).add('custom tooltip', () => ( }} /> )) + +stories.add('patterns & gradients', () => ( + ['viz', 'text', 'utils'].includes(node.pathComponents[1]), + id: 'gradient', + }, + { + match: node => ['set', 'generators', 'misc'].includes(node.pathComponents[1]), + id: 'pattern', + }, + ]} + /> +)) diff --git a/website/src/components/guides/gradients/GradientsIllustrations.js b/website/src/components/guides/gradients/GradientsIllustrations.js index 8af47c6218..bab730a558 100644 --- a/website/src/components/guides/gradients/GradientsIllustrations.js +++ b/website/src/components/guides/gradients/GradientsIllustrations.js @@ -80,19 +80,20 @@ const GradientsIllustrations = () => {
{