INNER CODE UNIT · JavaScript

svg

presenta-software/presenta-lib · src/blocks/svg/index.js:4

const svg = function (el, config) {
  const svg = config.code
  if (!svg) return console.log('[block svg]', 'The svg is not present')

  const aspect = config.aspect || null
  const query = config.query || null

  const child = u.div(`<div class="c ${css.svg}">
        <div class="${css.inner}">
            ${svg}
        </div>
    </div>`)
  el.appendChild(child)

  if (aspect) child.querySelector('svg').setAttribute('preserveAspectRatio', aspect)
  if (query) {
    const s = child.querySelector('svg')
    // #rect1:width:100,#rect2:height:20,circle:fill:#ff0000

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…