How to use the @brainly/html-sketchapp.nodeToSketchLayers function in @brainly/html-sketchapp

To help you get started, we’ve selected a few @brainly/html-sketchapp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / fast-dna / packages / fast-sketch-library / src / aSketchPage.ts View on Github external
function convertNodeToSketchLayers(node: Element): any[] {
    const layers: Base[] = nodeToSketchLayers(node);

    return layers.map((layer: Base) => {
        if (!(layer instanceof Text) && node.classList && node.classList.length) {
            const classes: string = Array.from(node.classList).join(" ");

            // Trim unique class ids created by JSS
            const trimmed: string = classes.replace(/[-0-9]+/g, "");
            layer.setName(trimmed.replace(/[^A-Za-z0-9_]/g, " "));
        }

        return layer;
    });
}
github brainly / html-sketchapp-style-guide / src / styleguide2asketch.js View on Github external
.map(node => {
          const layers = nodeToSketchLayers(node);

          return layers.map(layer => {

            // fix font name so the name matches locally installed font
            if (layer instanceof Text && layer._style._fontFamily === 'ProximaNova') {
              layer._style._fontFamily = 'Proxima Nova';
            }

            if (layer instanceof SVG && node.classList.contains('sg-icon__svg') && symbol._name.startsWith('Icon/')) {
              layer.setHasClippingMask(true);
            }

            // eslint-disable-next-line max-len
            if (symbol._name.startsWith('Button/') && layer instanceof SVG || symbol._name.startsWith('Label/') && layer instanceof SVG) {
              const type = node.children[0].id;
              const size = node.clientHeight;
github brainly / html-sketchapp-style-guide / src / styleguide2asketch.js View on Github external
.forEach(node => {
      const styleName = node.title;
      const layers = nodeToSketchLayers(node.firstChild);

      layers
        .filter(layer => layer instanceof Text)
        .forEach(layer => {
          // fix font name so the name matches localy installed font
          if (layer._style._fontFamily === 'ProximaNova') {
            layer._style._fontFamily = 'Proxima Nova';
          }

          layer.setName(styleName);
          doc.addTextStyle(layer);
        });
    });