Skip to content

Commit

Permalink
feat: update baseThemes
Browse files Browse the repository at this point in the history
  • Loading branch information
rshen91 committed Jun 2, 2020
1 parent 9bb1e8e commit 36baf2e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
5 changes: 1 addition & 4 deletions api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export interface AxisStyle {

// Warning: (ae-missing-release-tag) "BackgroundStyles" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
// @public
export interface BackgroundStyles {
// (undocumented)
color: string;
Expand Down Expand Up @@ -1277,8 +1277,6 @@ export const Settings: React.FunctionComponent<SettingsSpecProps>;
export interface SettingsSpec extends Spec {
// (undocumented)
animateData: boolean;
// (undocumented)
backgroundColor?: string;
baseTheme?: Theme;
brushAxis?: BrushAxis;
// (undocumented)
Expand Down Expand Up @@ -1413,7 +1411,6 @@ export interface Theme {
areaSeriesStyle: AreaSeriesStyle;
// (undocumented)
axes: AxisConfig;
// (undocumented)
background: BackgroundStyles;
barSeriesStyle: BarSeriesStyle;
bubbleSeriesStyle: BubbleSeriesStyle;
Expand Down
2 changes: 1 addition & 1 deletion src/chart_types/partition_chart/layout/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export const configMetadata = {
},

// other
// backgroundColor: { dflt: '#ffffff', type: 'color' },
backgroundColor: { dflt: '#ffffff', type: 'color' },

This comment has been minimized.

Copy link
@nickofthyme

nickofthyme Jun 3, 2020

Collaborator

Is this used to override the backgroundColor in the theme? Or to pass the theme value to the partition chart?

This comment has been minimized.

Copy link
@rshen91

rshen91 Jun 3, 2020

Author Contributor

@monfera might be able to explain it better but this config and config_types files were used for rendering the partition charts before they were added in storybook. I don't think this impacts anything currently so I just reverted the default.

sectorLineWidth: { dflt: 1, min: 0, max: 4, type: 'number' },
sectorLineStroke: { dflt: 'white', type: 'string' },
};
Expand Down
1 change: 0 additions & 1 deletion src/specs/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ export interface SettingsSpec extends Spec {
* @defaultValue 2
*/
minBrushDelta?: number;
backgroundColor?: string;
}

export type DefaultSettingsProps =
Expand Down
7 changes: 7 additions & 0 deletions src/utils/themes/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ export interface ColorConfig {
vizColors: Color[];
defaultVizColor: Color;
}
/**
* This is used to coordinate adequate contrast of the text in partition and treemap charts.
*/
export interface BackgroundStyles {
color: string;
}
Expand Down Expand Up @@ -200,6 +203,10 @@ export interface Theme {
* value from 1 to 100
*/
markSizeRatio?: number;
/**
* The background allows the consumer to provide a color of the background container of the chart.
* This can then be used to calculate the contrast of the text for partition charts.
*/

This comment has been minimized.

Copy link
@nickofthyme

nickofthyme Jun 3, 2020

Collaborator

👍

background: BackgroundStyles;
}

Expand Down
3 changes: 2 additions & 1 deletion stories/bar/1_basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { boolean } from '@storybook/addon-knobs';
import React from 'react';

import { BarSeries, Chart, ScaleType } from '../../src';
import { BarSeries, Chart, ScaleType, Settings, DARK_THEME, LIGHT_THEME } from '../../src';

export const Example = () => {
const darkmode = boolean('darkmode', false);
Expand All @@ -36,6 +36,7 @@ export const Example = () => {
const specId = toggleSpec ? 'bars1' : 'bars2';
return (
<Chart className={className}>
<Settings baseTheme={darkmode ? DARK_THEME : LIGHT_THEME} />
<BarSeries
id={specId}
name="Simple bar series"
Expand Down
3 changes: 1 addition & 2 deletions stories/bar/3_with_axis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import { Axis, BarSeries, Chart, DARK_THEME, LIGHT_THEME, Position, ScaleType, S
export const Example = () => {
const darkmode = boolean('darkmode', false);
const className = darkmode ? 'story-chart-dark' : 'story-chart';
const defaultTheme = darkmode ? DARK_THEME : LIGHT_THEME;
return (
<Chart className={className}>
<Settings theme={defaultTheme} />
<Settings baseTheme={darkmode ? DARK_THEME : LIGHT_THEME} />
<Axis id="bottom" position={Position.Bottom} title="Bottom axis" showOverlappingTicks={true} />
<Axis id="left2" title="Left axis" position={Position.Left} tickFormat={(d: any) => Number(d).toFixed(2)} />

Expand Down
7 changes: 6 additions & 1 deletion stories/interactions/14_crosshair_time.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export const Example = () => {

return (
<Chart className={className}>
<Settings debug={boolean('debug', false)} tooltip={tooltipProps} theme={defaultTheme} rotation={chartRotation} />
<Settings
debug={boolean('debug', false)}
tooltip={tooltipProps}
baseTheme={defaultTheme}
rotation={chartRotation}
/>
<Axis
id="bottom"
position={Position.Bottom}
Expand Down
4 changes: 2 additions & 2 deletions stories/sunburst/29_custom_stroke.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License. */

import { Chart, Datum, Partition, PartitionLayout, Settings } from '../../src';
import { Chart, Datum, Partition, PartitionLayout, Settings, DARK_THEME } from '../../src';
import { mocks } from '../../src/mocks/hierarchical/index';
import { config } from '../../src/chart_types/partition_chart/layout/config/config';
import React from 'react';
Expand All @@ -31,7 +31,7 @@ export const Example = () => {
};
return (
<Chart className="story-chart-dark">
<Settings theme={partialCustomTheme} />
<Settings baseTheme={DARK_THEME} theme={partialCustomTheme} />
<Partition
id="spec_1"
data={mocks.manyPie}
Expand Down

0 comments on commit 36baf2e

Please sign in to comment.