chore: Port FreeSewing.dev to docusaurus
The replaces the NextJS site powering FreeSewing.dev with a Docusaurus setup. It's part of my efforts to simplify FreeSewing's setup so we can focus on our core value proposition.
This commit is contained in:
parent
497633d1d3
commit
ab3204f9f1
692 changed files with 11037 additions and 20674 deletions
25
sites/dev/docs/reference/api/attributes/add/readme.mdx
Normal file
25
sites/dev/docs/reference/api/attributes/add/readme.mdx
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: Attributes.add()
|
||||
---
|
||||
|
||||
The `Attributes.add()` method adds `value` to the attribute identified by
|
||||
`key`.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Attributes attributes.add(string key, string value)
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'classA')
|
||||
.add('class', 'classB')
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
Adding multiple values to the same key will result in them being joined together
|
||||
(with a space) when rendering.
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
title: Attributes.asPropsIfPrefixIs()
|
||||
---
|
||||
|
||||
The `Attributes.asPropsIfPrefixIs()` method will return attribute values as a
|
||||
props object (a plain JavaScript object) but only for those keys who start with
|
||||
`prefix`.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Object attributes.asPropsIfPrefixIs(string prefix)
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'various')
|
||||
.add('stroke', 'red')
|
||||
.add('stroke-width', 2)
|
||||
|
||||
const props = attr.asPropsIfPrefixIs('stroke')
|
||||
/* Props holds:
|
||||
{
|
||||
stroke: 'red',
|
||||
stroke-width: 2
|
||||
}
|
||||
*/
|
||||
```
|
|
@ -0,0 +1,87 @@
|
|||
---
|
||||
title: Attributes.asRenderProps()
|
||||
---
|
||||
|
||||
The `Attributes.asRenderProps()` method will return the data stored in the
|
||||
attributes as a serializable JavaScript object. This method is typically
|
||||
note invoked directly but rather called under the hood as a result of
|
||||
calling [`Pattern.getRenderProps()`](/reference/api/pattern/getrenderprops).
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Object attributes.asRenderProps()
|
||||
```
|
||||
|
||||
## Returned object properties
|
||||
|
||||
This returns JavaScript object has the following properties:
|
||||
|
||||
| Name | Description |
|
||||
| ----:| ----------- |
|
||||
| `list`| A plain object representation of all attributes |
|
||||
| `forSvg`| All attributes rendered as a string for inclusion in an SVG (or HTML) tag |
|
||||
| `forCss`| All attributes rendered as a string for inclusion in CSS |
|
||||
| `circle`| An array of circles radii to render (set as the `data-circle` attribute) |
|
||||
| `circleProps`| A plain object representation of all circle-specific attributes (set as the `data-circle-*` attribute) |
|
||||
| `text`| An array of texts to render (set as the `data-text` attribute) |
|
||||
| `textProps`| A plain object representation of all text-specific attributes (set as the `data-text-*` attribute) |
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'various')
|
||||
.add('stroke', 'red')
|
||||
.add('stroke-width', 2)
|
||||
.add('data-circle', 20)
|
||||
.add('data-circle-class', 'lining')
|
||||
.add('data-text', 'test')
|
||||
.add('data-text-dx', 3)
|
||||
|
||||
const json = JSON.stringify(
|
||||
attr.asRenderProps(), null ,2
|
||||
)
|
||||
|
||||
/* json holds:
|
||||
{
|
||||
"list": {
|
||||
"class": [
|
||||
"various"
|
||||
],
|
||||
"stroke": [
|
||||
"red"
|
||||
],
|
||||
"stroke-width": [
|
||||
2
|
||||
],
|
||||
"data-circle": [
|
||||
20
|
||||
],
|
||||
"data-circle-class": [
|
||||
"lining"
|
||||
],
|
||||
"data-text": [
|
||||
"test"
|
||||
],
|
||||
"data-text-dx": [
|
||||
3
|
||||
]
|
||||
},
|
||||
"forSvg": " class=\"various\" stroke=\"red\" stroke-width=\"2\" data-circle=\"20\" data-circle-class=\"lining\" data-text=\"test\" data-text-dx=\"3\"",
|
||||
"forCss": " class:various; stroke:red; stroke-width:2; data-circle:20; data-circle-class:lining; data-text:test; data-text-dx:3;",
|
||||
"circle": [
|
||||
20
|
||||
],
|
||||
"circleProps": {
|
||||
"className": "lining"
|
||||
},
|
||||
"text": [
|
||||
"test"
|
||||
],
|
||||
"textProps": {
|
||||
"dx": "3"
|
||||
}
|
||||
}
|
||||
*/
|
||||
```
|
23
sites/dev/docs/reference/api/attributes/clone/readme.mdx
Normal file
23
sites/dev/docs/reference/api/attributes/clone/readme.mdx
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
title: Attributes.clone()
|
||||
---
|
||||
|
||||
The `Attributes.clone()` method returns a new Attributes object that is a deep
|
||||
copy of this one.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Attributes attributes.clone()
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'classA')
|
||||
.add('class', 'classB')
|
||||
|
||||
const cloned = attr.clone()
|
||||
```
|
||||
|
25
sites/dev/docs/reference/api/attributes/get/readme.mdx
Normal file
25
sites/dev/docs/reference/api/attributes/get/readme.mdx
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: Attributes.get()
|
||||
---
|
||||
|
||||
The `Attributes.get()` method will return the value of attribute stored under
|
||||
`key`, or `false` if it's not set.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
string attributes.get(string key)
|
||||
```
|
||||
|
||||
If key has multiple values, they will be joined together in a string, separated by spaces.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'classA')
|
||||
.add('class', 'classB')
|
||||
|
||||
const class = attr.get('class')
|
||||
// class now holds: "classA classB"
|
||||
```
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
title: Attributes.getAsArray()
|
||||
---
|
||||
|
||||
The `Attributes.getAsArray()` method will return an array with the value of
|
||||
attribute stored under `key`, or `false` if it's not set.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
array attributes.getAsArray(string key)
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'classA')
|
||||
.add('class', 'classB')
|
||||
|
||||
const class = attr.getAsArray('class')
|
||||
// class now holds: [ "classA", "classB" ]
|
||||
```
|
35
sites/dev/docs/reference/api/attributes/readme.mdx
Normal file
35
sites/dev/docs/reference/api/attributes/readme.mdx
Normal file
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
title: Attributes
|
||||
---
|
||||
|
||||
An Attributes object holds attributes for a variety of other objects.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Attributes new Attributes()
|
||||
```
|
||||
|
||||
The Attributes constructor takes no arguments.
|
||||
|
||||
## Properties
|
||||
|
||||
An Attributes object comes with the following property:
|
||||
|
||||
- `list` : Holds the internal object in which attributes are stored
|
||||
|
||||
## Methods
|
||||
An Attributes object exposes the following methods:
|
||||
|
||||
<ReadMore />
|
||||
|
||||
## Notes
|
||||
|
||||
Attributes are attached to [`Point`](/reference/api/point),
|
||||
[`Path`](/reference/api/path), and [`Snippet`](/reference/api/snippet) objects,
|
||||
as well as the internal [`Svg`](/reference/api/svg) object.
|
||||
|
||||
All of these have an instantiated Attributes object in their `attributes`
|
||||
property, as well as a number of (chainable) helper methods to manipulate the
|
||||
attributes. You will typically use these higher-level method and thus are
|
||||
unlikely to interact with an Attributes object directly.
|
23
sites/dev/docs/reference/api/attributes/remove/readme.mdx
Normal file
23
sites/dev/docs/reference/api/attributes/remove/readme.mdx
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
title: Attributes.remove()
|
||||
---
|
||||
|
||||
The `Attributes.remove()` method removes the attribute values under key and
|
||||
returns the Attributes object.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Attributes attributes.remove(string key)
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'classA')
|
||||
.add('class', 'classB')
|
||||
.remove('class')
|
||||
|
||||
// attr holds no data
|
||||
```
|
23
sites/dev/docs/reference/api/attributes/render/readme.mdx
Normal file
23
sites/dev/docs/reference/api/attributes/render/readme.mdx
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
title: Attributes.render()
|
||||
---
|
||||
|
||||
The `Attributes.render()` method will render attributes as a string suitable
|
||||
for inclusion in an SVG tag.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
string attributes.render()
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.set('id', 'example')
|
||||
.add('class', 'classA')
|
||||
.add('class', 'classb')
|
||||
|
||||
const paragraph = `<p ${attr.render()}>Hello</p>`
|
||||
```
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
title: Attributes.renderAsCss()
|
||||
---
|
||||
|
||||
The `Attributes.renderAsCss()` method will render attributes as a string
|
||||
suitable for inclusion in a CSS definition.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
string attributes.renderAsCss()
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('stroke', 'red')
|
||||
.add('stroke-width', 2)
|
||||
.add('stroke-dasharray', '3 1')
|
||||
|
||||
const css = `
|
||||
path {
|
||||
${attr.renderAsCss()}
|
||||
}
|
||||
`
|
||||
```
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
title: Attributes.renderIfPrefixIs()
|
||||
---
|
||||
|
||||
The `Attributes.renderIfPrefixIs()` method will render attributes as a string
|
||||
suitable for inclusion in an SVG tag, but only those attribute keys who start
|
||||
with `prefix`.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
string attributes.renderIfPrefixIs(string prefix)
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'various')
|
||||
.add('stroke', 'red')
|
||||
.add('stroke-width', 2)
|
||||
|
||||
const line = `<path ${attr.renderIfPrefixIs('stroke')} d="M 0,0 L 100.0" />`
|
||||
```
|
29
sites/dev/docs/reference/api/attributes/set/readme.mdx
Normal file
29
sites/dev/docs/reference/api/attributes/set/readme.mdx
Normal file
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
title: Attributes.set()
|
||||
---
|
||||
|
||||
The `Attributes.set()` method sets the attribute identified by `key` to value
|
||||
`value`.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Attributes attributes.set(string key, string value)
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'classA')
|
||||
.add('class', 'classB')
|
||||
|
||||
const class = attr.get('class')
|
||||
// class now holds: "classA classB"
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
This will overwrite any value that's currently set on the attribute identified
|
||||
by `key`.
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
title: Attributes.setIfUnset()
|
||||
---
|
||||
|
||||
The `Attributes.setIfUnset()` method sets the attribute identified by `key` to
|
||||
value `value` but only if it's currently unset (`undefined`).
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Attributes attributes.setIfUnset(string key, string value)
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.setIfUnset('class', 'classA')
|
||||
.setIfUnset('class', 'classB')
|
||||
|
||||
const class = attr.get('class')
|
||||
// class now holds: "classA"
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
This will never overwrite any value and thus is a safe way to set attributes
|
Loading…
Add table
Add a link
Reference in a new issue