Code Monkey home page Code Monkey logo

Comments (5)

scriptex avatar scriptex commented on May 21, 2024 1

I see, okay!
Let me find some time for this and I will implement it.

from svg-symbol-sprite.

Scriptura avatar Scriptura commented on May 21, 2024 1

Hello,

Thank you for making all these changes.

If you allow me, a note of optimization:
If we type the command -a '' -s '' we get <svg style="">, so white spaces and an empty attribute for styles. That's why I came up with something like this:

<${['svg', NAMESPACE, STYLE].join(' ')}>

which we could now translate, following your naming conventions, and taking up all of line 51, by:

const getSpriteContent = (contents: string[]) => `<${['svg', ATTRS, STYLE].join(' ').replace('style=""', '')}">${contents.join('')}</svg>`;

Greetings from France to Bulgaria!

from svg-symbol-sprite.

scriptex avatar scriptex commented on May 21, 2024

Hi, @Scriptura, thank you for your kind words and the time you took to summarize your feature requests.
I have released a new version (1.2.2) which fixes the wrong URL to the documentation on my website, thanks for noticing this :)
Regarding the rest of the suggestions, I am planning on adding them as all of them make sense but I don't have the time to do this right now.
Have you considered opening a PR for this?
If not, it might take a while...

from svg-symbol-sprite.

Scriptura avatar Scriptura commented on May 21, 2024

Ideally I would do something like this (but I'm too amateur to test...), change only for styles and namespaces, no deactivation of SVGO:

//const SVG_PROPS = 'xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true"';
//const SVG_STYLE = 'style="width: 0; height: 0; position: absolute;"';
const DEFAULT_CONFIG = join(__dirname, '..', 'config', 'svgo.config.js');

/* ... */

cli.option('-i, --input [input]', 'Specifies input dir (current dir by default)', '.')
	.option('-o, --output [output]', 'Specifies output file ("./sprite.svg" by default)', 'sprite.svg')
	.option('-v, --viewbox [viewbox]', 'Specifies viewBox attribute (parsed by default)', '')
	.option('-p, --prefix [prefix]', 'Specifies prefix for id attribute ("icon-" by default)', 'icon-')
	.option('-c, --config [config]', 'Absolute path to the SVGO config file', './config/svgo.config.js')
	.option('-n, --namespace [namespace]', 'Namespaces and aria attribute for the SVG sprite', 'xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true"')
	.option('-s, --style [style]', 'Inline styles for the SVG sprite', 'style="width: 0; height: 0; position: absolute;"')
	.parse(process.argv);

const { input: INPUT, output: OUTPUT, viewbox: VIEWBOX, prefix: PREFIX, config: CONFIG, namespace: NAMESPACE, style: STYLE } = cli.opts();

/* ... */

const getSpriteContent = (contents: string[]) => `<${['svg', NAMESPACE, STYLE].join(' ')}>${contents.join('')}</svg>`;

Which would allow us to do this in the package.json:
"svg-symbol-sprite -n '' -s ''"

Not only am I not able to make a PR, but I can't test these modifications... to be seen...

from svg-symbol-sprite.

scriptex avatar scriptex commented on May 21, 2024

Hi again, @Scriptura.

I've published a new version on NPM (1.3.0) and on Github which tackles everything you mentioned in this issue.

  1. You can use -p or --props to set custom SVG props or just pass -p "" to remove any SVG props.
  2. You can use -s or --style to set custom inline style for the SVG or just pass -s "" to remove any inline style.
  3. You can also disable the SVGO files optimization using the -c or --config flag by passing false to it: -c false.

Thanks for your really important input and I hope you like how the package works now :)

from svg-symbol-sprite.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.