2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-10-02 00:27:09 +02:00
|
|
|
title: plugin-svgattr
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-02 00:27:09 +02:00
|
|
|
Published as [@freesewing/plugin-svgattr][1], this plugin takes an object of
|
2023-01-12 17:08:22 -06:00
|
|
|
key-value pairs and adds them as attributes of the `<svg>` tag
|
2022-12-13 04:39:07 -08:00
|
|
|
of a pattern's SVG document on render.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2022-10-02 00:27:09 +02:00
|
|
|
```sh
|
2021-08-25 16:09:31 +02:00
|
|
|
npm install @freesewing/plugin-svgattr
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2022-10-02 00:27:09 +02:00
|
|
|
Either [add it as a part plugins](/reference/api/part/config/plugins) in your
|
|
|
|
design, or [add it to a pattern instance with
|
|
|
|
Pattern.use()](/reference/api/pattern/use).
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-13 04:39:07 -08:00
|
|
|
To import the plugin for use:
|
|
|
|
```js
|
|
|
|
import { svgAttrPlugin } from '@freesewing/plugin-svgattr'
|
|
|
|
// or
|
|
|
|
import { svgattrPlugin } from '@freesewing/plugin-svgattr'
|
|
|
|
// or
|
|
|
|
import { pluginSvgAttr } from '@freesewing/plugin-svgattr'
|
|
|
|
// or
|
|
|
|
import { pluginSvgattr } from '@freesewing/plugin-svgattr'
|
|
|
|
```
|
2024-09-28 13:13:48 +02:00
|
|
|
:::tip
|
2022-12-13 04:39:07 -08:00
|
|
|
For convenience, this plugin is exported
|
|
|
|
under multiple names with variations of capitalization.
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-13 04:39:07 -08:00
|
|
|
## Notes
|
2022-10-02 00:27:09 +02:00
|
|
|
|
2022-12-13 04:39:07 -08:00
|
|
|
To provide the attributes for the `<svg>` tag, you will need to pass a
|
|
|
|
second argument which holds key-value pairs.
|
|
|
|
It should be an `Object` structured as such:
|
|
|
|
|
|
|
|
```js
|
|
|
|
{
|
|
|
|
key1: 'value1',
|
|
|
|
key2: 'value2',
|
|
|
|
key3: 'value3',
|
|
|
|
// More key-value pairs can follow...
|
|
|
|
}
|
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-02 00:27:09 +02:00
|
|
|
[1]: https://www.npmjs.com/package/@freesewing/plugin-svgattr
|