Skip to content

Commit 19a0d75

Browse files
committed
added clipping with svg in css module
1 parent 59ea3bb commit 19a0d75

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/modules/styles/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import u from '../../utils'
2+
13
const props = ['opacity', 'blend', 'radius', 'border', 'padding', 'background', 'color', 'clip', 'shadow']
24
const upper = (s) => s.charAt(0).toUpperCase() + s.slice(1)
35

@@ -10,7 +12,18 @@ const applyRawProps = (el, config) => {
1012
}
1113

1214
const styles = function (element, mod, config) {
15+
if (config.contextType !== 'block') return
1316
applyRawProps(element, mod)
17+
18+
if (mod.svgClip) {
19+
const svg = u.div(mod.svgClip)
20+
const cpath = svg ? svg.querySelector('clipPath') : null
21+
const cid = cpath ? cpath.getAttribute('id') : null
22+
if (cid) {
23+
element.append(svg)
24+
element.style.setProperty('--blockClip', `url(#${cid})`)
25+
}
26+
}
1427
}
1528

1629
styles.runBefore = true

0 commit comments

Comments
 (0)