Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable inline styles #1882

Merged
merged 12 commits into from
Jun 23, 2021
Prev Previous commit
Next Next commit
Update documentation to include two examples
  • Loading branch information
Becca Bailey committed Jun 18, 2021
commit 0a7c3819b99f03215d63aa37322a0b257a499040
38 changes: 37 additions & 1 deletion docs/src/content/common-props/common-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,39 @@ ReactDOM.render(<App/>, mountNode);

The `disableInlineStyles` prop allows Victory components to work better with CSS classes or styled-components. By default, Victory provides inline styles to chart components, which will override any conflicting CSS styles. This flag will remove the inline styles, making it easier to provide custom styling for components via CSS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this documentation, we should draw a distinction in the difference in behavior when providing the disableInlineStyles prop to a component like VictoryBar (i.e. inline styles are removed for both data and label components) vs supplying the prop to a component like Bar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


If this prop is passed to a chart type (e.g. `VictoryBar`), it will apply to all data and label components for that chart.

```playground_norender

const StyledBar = styled(Bar)`
fill: purple;
`

const StyledLabel = styled(VictoryLabel)`
tspan {
fill: magenta;
font-family: Papyrus, fantasy;
}
`

function CustomStyledBarChart() {
return (
<VictoryChart>
<VictoryBar
disableInlineStyles
labels={[1, 2, 3, 4]}
dataComponent={<StyledBar />}
labelComponent={<StyledLabel />}
/>
</VictoryChart>
)
}

ReactDOM.render(<CustomStyledBarChart/>, mountNode);
```

It can also be passed to individual data or label components to disable styles on a more granular level.

```playground_norender

const StyledBar = styled(Bar)`
Expand All @@ -241,7 +274,10 @@ const StyledBar = styled(Bar)`
function CustomStyledBarChart() {
return (
<VictoryChart>
<VictoryBar dataComponent={<StyledBar disableInlineStyles />} />
<VictoryBar
labels={[1, 2, 3, 4]}
dataComponent={<StyledBar disableInlineStyles />}
/>
</VictoryChart>
)
}
Expand Down