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
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: Snippet.asRenderProps()
|
||||
---
|
||||
|
||||
The `Snippet.asRenderProps()` method will return the data stored in the
|
||||
snippet as a serializable JavaScript object. This method is typically
|
||||
not invoked directly but rather called under the hood as a result of
|
||||
calling [`Pattern.getRenderProps()`](/reference/api/pattern/getrenderprops).
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Object snippet.asRenderProps()
|
||||
```
|
||||
|
||||
## Returned object properties
|
||||
|
||||
This returns JavaScript object has the following properties:
|
||||
|
||||
| Name | Description |
|
||||
| ----:| ----------- |
|
||||
| `attributes` | The result of [Path.attributes.asRenderProps()](/reference/api/attributes/asrenderprops) |
|
||||
| `def` | The ID of the snippet's reference in the `defs` section of the SVG (the snippet code) |
|
||||
| `anchor` | The [Point](/reference/api/point) on which the snippet is anchored, or rather its [`Point.asRenderProps()`](/reference/api/point/asrenderprops) result |
|
||||
|
47
sites/dev/docs/reference/api/snippet/attr/readme.mdx
Normal file
47
sites/dev/docs/reference/api/snippet/attr/readme.mdx
Normal file
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
title: Snippet.attr()
|
||||
---
|
||||
|
||||
The `Snippet.attr()` method can be used to add attributes to the Snippet
|
||||
object. It calls `this.attributes.add()` under the hood, and returns the
|
||||
Snippet object.
|
||||
|
||||
If the third parameter is set to `true` it will call `this.attributes.set()`
|
||||
instead, thereby overwriting the value of the attribute.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Snippet snippet.attr(
|
||||
string name,
|
||||
mixed value,
|
||||
bool overwrite = false
|
||||
)
|
||||
```
|
||||
|
||||
:::tipThis method is chainable as it returns the `Snippet` object:::
|
||||
|
||||
## Example
|
||||
|
||||
<Example caption="An example of the Snippet.attr() method">
|
||||
```js
|
||||
({ Point, points, Path, paths, Snippet, snippets, part }) => {
|
||||
|
||||
snippets.logo = new Snippet('logo', new Point(0,0))
|
||||
.attr("data-scale", 0.75)
|
||||
.attr("data-rotate", 180)
|
||||
|
||||
// Prevent clipping
|
||||
paths.diag = new Path()
|
||||
.move(new Point(-25,-10))
|
||||
.move(new Point(25,35))
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
</Example>
|
||||
|
||||
:::note RELATED
|
||||
See [Using Attributes](/howtos/code/attributes)
|
||||
for information about what Attributes can be used with Snippets.
|
||||
:::
|
36
sites/dev/docs/reference/api/snippet/clone/readme.mdx
Normal file
36
sites/dev/docs/reference/api/snippet/clone/readme.mdx
Normal file
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
title: Snippet.clone()
|
||||
---
|
||||
|
||||
The `Snippet.clone()` method returns a new Snippets object that is a deep copy
|
||||
of this one.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Snippet snippet.clone()
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
<Example caption="An example of the Snippet.clone() method">
|
||||
```js
|
||||
({ Point, Path, paths, Snippet, snippets, part }) => {
|
||||
|
||||
snippets.demo = new Snippet("logo", new Point(0,0))
|
||||
.attr("style", "color: #f006")
|
||||
|
||||
snippets.clone = snippets.demo
|
||||
.clone()
|
||||
.attr("data-scale", 0.5)
|
||||
|
||||
// Prevent clipping
|
||||
paths.diag = new Path()
|
||||
.move(new Point(-25,-30))
|
||||
.move(new Point(25,15))
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
</Example>
|
||||
|
54
sites/dev/docs/reference/api/snippet/readme.mdx
Normal file
54
sites/dev/docs/reference/api/snippet/readme.mdx
Normal file
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
title: Snippet
|
||||
---
|
||||
|
||||
A Snippet is a reusable bit of markup for your pattern. Snippets are added to the
|
||||
SVG `defs` section, and rendered with the SVG `use` tag.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Snippet new Snippet(String def, Point anchor);
|
||||
```
|
||||
|
||||
The snippet constructor takes two arguments:
|
||||
|
||||
- `def` : The `xlink:href` id that links to the relevant entry in the SVG `defs` section. This is also the common name of the snippet (`logo`, `notch`, `button`, etc.)
|
||||
- `anchor` : A [`Point`](/reference/api/point) on which to anchor the snippet
|
||||
|
||||
## Properties
|
||||
|
||||
A Snippet object comes with the following properties:
|
||||
|
||||
- `def` : The `xlink:href` id that links to the relevant entry in the SVG `defs` section
|
||||
- `anchor` : A [`Point`](/reference/api/point) on which to anchor the snippet
|
||||
- `attributes` : An [`Attributes`](/reference/api/attributes) instance holding the snippet's attributes
|
||||
|
||||
:::note RELATED
|
||||
See [Using Attributes](/howtos/code/attributes)
|
||||
for information about custom Attributes that can be used with Snippets.
|
||||
:::
|
||||
|
||||
## Example
|
||||
|
||||
<Example caption="Example of the Snippet constructor">
|
||||
```js
|
||||
({ Point, Snippet, snippets, Path, paths, part }) => {
|
||||
|
||||
snippets.logo = new Snippet('logo', new Point(0,0))
|
||||
|
||||
// Prevent clipping
|
||||
paths.diag = new Path()
|
||||
.move(new Point(-25,-40))
|
||||
.move(new Point(25,15))
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
</Example>
|
||||
|
||||
## Methods
|
||||
|
||||
A Snippet object exposes the following methods:
|
||||
|
||||
<ReadMore />
|
38
sites/dev/docs/reference/api/snippet/rotate/readme.mdx
Normal file
38
sites/dev/docs/reference/api/snippet/rotate/readme.mdx
Normal file
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
title: Snippet.rotate()
|
||||
---
|
||||
|
||||
The `Snippet.rotate()` method allows you to scale a snippet. Under the hood, it
|
||||
sets the `data-rotate` property.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Snippet snippet.rotate(rotation, overwrite=true)
|
||||
```
|
||||
|
||||
:::tipThis method is chainable as it returns the `Snippet` object:::
|
||||
|
||||
## Example
|
||||
|
||||
<Example caption="An example of the Snippet.rotate() method">
|
||||
```js
|
||||
({ Point, Path, paths, Snippet, snippets, part }) => {
|
||||
|
||||
for (const i of [0,1,2,3,4,5,6]) {
|
||||
snippets[`demo${i}`] = new Snippet(
|
||||
"logo",
|
||||
new Point(60*i, 0)
|
||||
).rotate(60 * i)
|
||||
}
|
||||
|
||||
// Prevent clipping
|
||||
paths.diag = new Path()
|
||||
.move(new Point(-30,-50))
|
||||
.move(new Point(400,50))
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
</Example>
|
||||
|
38
sites/dev/docs/reference/api/snippet/scale/readme.mdx
Normal file
38
sites/dev/docs/reference/api/snippet/scale/readme.mdx
Normal file
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
title: Snippet.scale()
|
||||
---
|
||||
|
||||
The `Snippet.scale()` method allows you to scale a snippet. Under the hood, it
|
||||
sets the `data-scale` property.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Snippet snippet.scale(scale, overwrite=true)
|
||||
```
|
||||
|
||||
:::tipThis method is chainable as it returns the `Snippet` object:::
|
||||
|
||||
## Example
|
||||
|
||||
<Example caption="An example of the Snippet.clone() method">
|
||||
```js
|
||||
({ Point, Path, paths, Snippet, snippets, part }) => {
|
||||
|
||||
for (const i of [1,2,3,4,5,6]) {
|
||||
snippets[`demo${i}`] = new Snippet(
|
||||
"logo",
|
||||
new Point(30*i, 0)
|
||||
).scale(i/10)
|
||||
}
|
||||
|
||||
// Prevent clipping
|
||||
paths.diag = new Path()
|
||||
.move(new Point(0,-30))
|
||||
.move(new Point(200,20))
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
</Example>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue