Comments (5)
I see, okay!
Let me find some time for this and I will implement it.
from svg-symbol-sprite.
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.
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.
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.
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.
- You can use
-p
or--props
to set custom SVG props or just pass-p ""
to remove any SVG props. - You can use
-s
or--style
to set custom inline style for the SVG or just pass-s ""
to remove any inline style. - You can also disable the SVGO files optimization using the
-c
or--config
flag by passingfalse
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)
- Dependency Dashboard
- CVE-2021-44907 (Medium) detected in qs-6.10.2.tgz
- CVE-2021-44906 (Medium) detected in minimist-1.2.5.tgz
- DEFAULT_CONFIG is required HOT 2
- CVE-2021-33587 (High) detected in css-what-4.0.0.tgz
- Remove empty `style` attribute HOT 2
- CVE-2021-35065 (High) detected in glob-parent-5.1.2.tgz
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svg-symbol-sprite.