|
6 | 6 | smallDataset, |
7 | 7 | largeValues, |
8 | 8 | negativeGrowth, |
9 | | - salesByProduct, |
| 9 | + dataWithImageColor, |
10 | 10 | } from './sample-data'; |
11 | 11 | import type { Meta, StoryObj } from '@storybook/react'; |
12 | 12 |
|
@@ -379,18 +379,38 @@ export const NumberFormatting: Story = { |
379 | 379 | }, |
380 | 380 | }; |
381 | 381 |
|
| 382 | +const CustomLabelComponent = ( { label, imageColor, style = {} } ) => ( |
| 383 | + <div |
| 384 | + style={ { |
| 385 | + display: 'flex', |
| 386 | + alignItems: 'center', |
| 387 | + gap: '8px', |
| 388 | + ...style, |
| 389 | + } } |
| 390 | + > |
| 391 | + <img |
| 392 | + src={ `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50'><rect width='50' height='50' fill='${ encodeURIComponent( |
| 393 | + imageColor |
| 394 | + ) }'/></svg>` } |
| 395 | + alt="icon" |
| 396 | + style={ { |
| 397 | + width: '28px', |
| 398 | + height: '28px', |
| 399 | + verticalAlign: 'middle', |
| 400 | + borderRadius: '4px', |
| 401 | + } } |
| 402 | + /> |
| 403 | + <span style={ { fontSize: '13px' } }>{ label }</span> |
| 404 | + </div> |
| 405 | +); |
| 406 | + |
382 | 407 | export const CustomLabel: Story = { |
383 | 408 | args: { |
384 | | - data: smallDataset.map( entry => ( { |
| 409 | + data: dataWithImageColor.map( entry => ( { |
385 | 410 | ...entry, |
386 | | - label: ( |
387 | | - <span style={ { fontSize: '24px', padding: '8px 16px', color: '#EEEEEE' } }> |
388 | | - { entry.label } |
389 | | - </span> |
390 | | - ), |
| 411 | + label: <CustomLabelComponent label={ entry.label } imageColor={ entry.imageColor } />, |
391 | 412 | } ) ), |
392 | 413 | withComparison: false, |
393 | | - withOverlayLabel: true, |
394 | 414 | loading: false, |
395 | 415 | }, |
396 | 416 | }; |
@@ -457,31 +477,16 @@ export const WooCommerceTheme: Story = { |
457 | 477 | ], |
458 | 478 | }; |
459 | 479 |
|
460 | | -export const WooAnalyticsSalesByProduct: Story = { |
| 480 | +export const OverlayLabelWithImage: Story = { |
461 | 481 | args: { |
462 | | - data: salesByProduct.map( entry => ( { |
| 482 | + data: dataWithImageColor.map( entry => ( { |
463 | 483 | ...entry, |
464 | 484 | label: ( |
465 | | - <div |
466 | | - style={ { |
467 | | - display: 'flex', |
468 | | - alignItems: 'center', |
469 | | - gap: '8px', |
470 | | - padding: '6px', |
471 | | - } } |
472 | | - > |
473 | | - <img |
474 | | - src={ `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50'><rect width='50' height='50' fill='${ entry.imageColor }'/></svg>` } |
475 | | - alt="icon" |
476 | | - style={ { |
477 | | - width: '28px', |
478 | | - height: '28px', |
479 | | - verticalAlign: 'middle', |
480 | | - borderRadius: '4px', |
481 | | - } } |
482 | | - /> |
483 | | - <span style={ { fontSize: '13px' } }>{ entry.label }</span> |
484 | | - </div> |
| 485 | + <CustomLabelComponent |
| 486 | + label={ entry.label } |
| 487 | + imageColor={ entry.imageColor } |
| 488 | + style={ { padding: '6px' } } |
| 489 | + /> |
485 | 490 | ), |
486 | 491 | } ) ), |
487 | 492 | primaryColor: '#C8CFF6', |
|
0 commit comments