Skip to content

Commit

Permalink
fix: Minor naming and comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EvHaus committed Jan 30, 2025
1 parent 7011229 commit d18bc20
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ const renderTextElement = ({
};

// Converts a web-based SVG element to a react-pdf SVG element
const webSvgToPdfSvg = (children: React.ReactElement, chartStyle?: Style) => {
export const convertHTMLToPDF = (
children: React.ReactElement,
chartStyle?: Style,
) => {
const svgString = renderToStaticMarkup(children);

if (!svgString?.length) {
Expand Down Expand Up @@ -358,7 +361,7 @@ const webSvgToPdfSvg = (children: React.ReactElement, chartStyle?: Style) => {
* @example
* <ReactPDFChart>
* <LineChart data={data} height={300} width={500}>
* <XAxis dataKey="name" />
* <XAxis dataKey="name" />
* <YAxis />
* <CartesianGrid stroke="#eee" strokeDasharray="5" />
* <Line type="monotone" dataKey="uv" stroke="#8884d8" />
Expand All @@ -367,7 +370,7 @@ const webSvgToPdfSvg = (children: React.ReactElement, chartStyle?: Style) => {
* </ReactPDFChart>
*/
const ReactPDFChart = ({ children, chartStyle, debug, style }: PropsType) => {
let component = webSvgToPdfSvg(children, chartStyle);
let component = convertHTMLToPDF(children, chartStyle);

// This should never happen, but it's here for type safety
if (!component || typeof component === 'string') return <>{component}</>;
Expand Down

0 comments on commit d18bc20

Please sign in to comment.