-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove ramda from render (#1834)
- Loading branch information
Showing
72 changed files
with
405 additions
and
1,055 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@react-pdf/render': major | ||
--- | ||
|
||
refactor: remove ramda from render package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import * as R from 'ramda'; | ||
|
||
const setDestination = (ctx, node) => { | ||
if (node.props?.id) { | ||
ctx.addNamedDestination(node.props.id, 'XYZ', null, node.box.top, null); | ||
} | ||
}; | ||
|
||
return node; | ||
} | ||
|
||
export default R.curryN(2, setDestination); | ||
export default setDestination; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,29 @@ | ||
import * as R from 'ramda'; | ||
|
||
import save from '../operations/save'; | ||
import restore from '../operations/restore'; | ||
import clipNode from '../operations/clipNode'; | ||
import parseColor from '../utils/parseColor'; | ||
import isNil from '../../../fns/isNil'; | ||
|
||
const drawBackground = (ctx, node) => { | ||
if (node.box && node.style.backgroundColor) { | ||
const { top, left, width, height } = node.box; | ||
const color = parseColor(node.style.backgroundColor); | ||
const nodeOpacity = R.isNil(node.style?.opacity) ? 1 : node.style.opacity; | ||
const opacity = Math.min(color.opacity, nodeOpacity); | ||
|
||
ctx | ||
.fillOpacity(opacity) | ||
.fillColor(color.value) | ||
.rect(left, top, width, height) | ||
.fill(); | ||
} | ||
|
||
return node; | ||
const { top, left, width, height } = node.box; | ||
const color = parseColor(node.style.backgroundColor); | ||
const nodeOpacity = isNil(node.style?.opacity) ? 1 : node.style.opacity; | ||
const opacity = Math.min(color.opacity, nodeOpacity); | ||
|
||
ctx | ||
.fillOpacity(opacity) | ||
.fillColor(color.value) | ||
.rect(left, top, width, height) | ||
.fill(); | ||
}; | ||
|
||
const renderBackground = (ctx, node) => { | ||
const hasBackground = !!node.box && !!node.style?.backgroundColor; | ||
|
||
if (hasBackground) { | ||
save(ctx, node); | ||
ctx.save(); | ||
clipNode(ctx, node); | ||
drawBackground(ctx, node); | ||
restore(ctx, node); | ||
ctx.restore(); | ||
} | ||
|
||
return node; | ||
}; | ||
|
||
export default R.curryN(2, renderBackground); | ||
export default renderBackground; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
import * as R from 'ramda'; | ||
|
||
import { drawEllipse } from './renderEllipse'; | ||
|
||
const getProp = (p, v) => R.path(['props', p], v); | ||
|
||
const renderCircle = (ctx, node) => { | ||
const cx = getProp('cx', node); | ||
const cy = getProp('cy', node); | ||
const r = getProp('r', node); | ||
const cx = node.props?.cx; | ||
const cy = node.props?.cy; | ||
const r = node.props?.r; | ||
|
||
drawEllipse(ctx, cx, cy, r, r); | ||
|
||
return node; | ||
}; | ||
|
||
export default R.curryN(2, renderCircle); | ||
export default renderCircle; |
Oops, something went wrong.