Skip to content

Commit

Permalink
feat(tooltip): move Chip style to theme (#589)
Browse files Browse the repository at this point in the history
* add theme property to chip component
* update theme typescript
  • Loading branch information
Et3rnal1 authored and plouc committed Jun 11, 2019
1 parent 9037d05 commit 343e38c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/core/index.d.ts
Expand Up @@ -68,6 +68,7 @@ declare module '@nivo/core' {
tooltip: Partial<{
container: Partial<React.CSSProperties>
basic: Partial<React.CSSProperties>
chip: Partial<React.CSSProperties>
table: Partial<React.CSSProperties>
tableCell: Partial<React.CSSProperties>
}>
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/theming/defaultTheme.js
Expand Up @@ -67,6 +67,9 @@ export const defaultTheme = {
display: 'flex',
alignItems: 'center',
},
chip: {
marginRight: 7,
},
table: {},
tableCell: {
padding: '3px 5px',
Expand Down
4 changes: 1 addition & 3 deletions packages/tooltip/src/components/BasicTooltip.js
Expand Up @@ -11,8 +11,6 @@ import PropTypes from 'prop-types'
import { useTheme, useValueFormatter } from '@nivo/core'
import Chip from './Chip'

const chipStyle = { marginRight: 7 }

const BasicTooltip = memo(({ id, value: _value, format, enableChip, color, renderContent }) => {
const theme = useTheme()
const formatValue = useValueFormatter(format)
Expand All @@ -27,7 +25,7 @@ const BasicTooltip = memo(({ id, value: _value, format, enableChip, color, rende
}
content = (
<div style={theme.tooltip.basic}>
{enableChip && <Chip color={color} style={chipStyle} />}
{enableChip && <Chip color={color} style={theme.tooltip.chip} />}
{value !== undefined ? (
<span>
{id}: <strong>{isNaN(value) ? String(value) : value}</strong>
Expand Down

0 comments on commit 343e38c

Please sign in to comment.