question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adapt plugin-theme to support the new scale setting

See original GitHub issue

Problem description

We’ve added improved support for very small (and large) patterns to our roadmap. Think patterns for dolls/giants.

The problem is that while the patterns themselves are made-to-measure, some things don’t scale:

  • Stroke-width
  • Arrow sizes (also based on stroke width)
  • Font sizes
  • Snippets like buttons and scalebox and whatnot

Here’s an example that illustrates the problem: Screenshot 2022-01-11 at 17-15-36 aaron

What is it that you would like to see happen?

In our frontend, we handle this with CSS variables. Alas, you cannot set CSS variables in SVG (or if you can, then I haven’t figured out how). So for stand-along SVG files this is not a solution.

So, we should adapt our plugin-theme package to take this variable on board. Specifically, rather than add a bunch of static CSS, it should generate the CSS dynamically, and multiply font sizes, stroke widths and so on with the settings.scale value (which defaults to 1).

Currently, the plugin imports the CSS, then adds it to the pattern (there’s also a prebuild step that turns SASS into CSS but we don’t really use SASS so it should not be a problem to remove it).

Instead, we should have a method that generates the CSS and takes the scale factor as input.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
nicholasdowercommented, Jan 21, 2022

No. You should close it 😃 I’d do it, but it’s your issue so you’ve earned closing it 😉

Woohoo!

1reaction
joostdecockcommented, Jan 11, 2022

A bit more info now that I have some more time:

Then, it’s a matter of taking the CSS and adapting stroke-widths, text-size and so on based on the scale. Quick example:

import {version, name} from '../package.json'

// Helper method to avoid having too many digits after the comma
const round = value => Math.round(value * 1e2) / 1e2

const svg = (scale=1) => `
stroke-xs {
  stroke-width: ${round(0.1*scale)};
}
stroke-sm {
  stroke-width: ${round(0.2*scale)};
}
stroke-lg {
  stroke-width: ${round(0.6*scale)};
}
/* and so on... */
`

export default {
  name: name,
  version: version,
  hooks: {
    preRender: svg => {
      // Don't add style twice, because a pattern van get rendered multiple times
      if (svg.attributes.get('freesewing:plugin-theme') === false) {
        svg.style += css(svg.pattern.settings.scale)
        // More stuff here
      }
    }
  }

This is from the top of my head, but I hope it makes some sense 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

WordPress Plugin/Theme status - Online Documentation
This table contains information about WordPress plugin status and WordPress settings. A support staff member may need some of it if you ask...
Read more >
Plugins & Themes - PeerTube documentation
Write a plugin/theme. Steps: Find a name for your plugin or your theme (must not have spaces, it can only contain lowercase letters...
Read more >
BuddyBoss Tutorials
Setting up custom menus. Go to Appearance > Menus. Create a new menu and add all desires pages into that menu. Drag and...
Read more >
Testing and Feedback for the Fluid Typography Feature
The new feature gives theme authors two new keys to add in their theme.json files: settings.typography.fluid can be set to true to enable...
Read more >
Scale windows in Logic Pro - Apple Support
Adjust the size of an individual plug-in window. In Logic Pro, do one of the following: Drag the lower-right corner of the plug-in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found