Skip to content

Commit

Permalink
reactor rest of customization
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Feb 2, 2024
1 parent c9158b4 commit f6a53c7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 116 deletions.
32 changes: 6 additions & 26 deletions docs/tour/dimensions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import CodeBlock from '@theme/CodeBlock';
import Dimensions from '@site/static/d2/dimensions.d2';

# Dimensions

You can specify the `width` and `height` of most shapes.
Expand All @@ -6,31 +9,8 @@ You can specify the `width` and `height` of most shapes.
These keywords cannot be set on containers, since containers resize to fit their children.
:::

```d2
direction: right
small jerry: "" {
shape: image
icon: https://static.wikia.nocookie.net/tomandjerry/images/4/46/JerryJumbo3-1-.jpg
width: 200
height: 200
}
med jerry: "" {
shape: image
icon: https://static.wikia.nocookie.net/tomandjerry/images/4/46/JerryJumbo3-1-.jpg
width: 300
height: 300
}
big jerry: "" {
shape: image
icon: https://static.wikia.nocookie.net/tomandjerry/images/4/46/JerryJumbo3-1-.jpg
width: 500
height: 400
}
big jerry -> med jerry -> small jerry
```
<CodeBlock className="language-d2">
{Dimensions}
</CodeBlock>

<div className="embedSVG" dangerouslySetInnerHTML={{__html: require('@site/static/img/generated/dimensions.svg2')}}></div>
24 changes: 10 additions & 14 deletions docs/tour/interactive.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import CodeBlock from '@theme/CodeBlock';
import Tooltip from '@site/static/d2/tooltip.d2';
import Links from '@site/static/d2/links.d2';

# Interactive

## Tooltips
Expand All @@ -10,11 +14,9 @@ Tooltips are text that appear on hover. They serve two purposes:
- Your diagram is getting messy. Instead of adding more text, you can tuck some into
tooltips.

```d2
x: { tooltip: Total abstinence is easier than perfect moderation }
y: { tooltip: Gee, I feel kind of LIGHT in the head now,\nknowing I can't make my satellite dish PAYMENTS! }
x -> y
```
<CodeBlock className="language-d2">
{Tooltip}
</CodeBlock>

Try it out, hover over `x` and `y`. Notice that they have an icon indicating that they
have a tooltip.
Expand All @@ -39,15 +41,9 @@ tooltips.

Links are like tooltips, except you click to go to an external link.

```d2
x: I'm a Mac {
link: https://apple.com
}
y: And I'm a PC {
link: https://microsoft.com
}
x -> y: gazoontite
```
<CodeBlock className="language-d2">
{Links}
</CodeBlock>

Try clicking on each.

Expand Down
94 changes: 18 additions & 76 deletions docs/tour/positions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import CodeBlock from '@theme/CodeBlock';
import NearConstant from '@site/static/d2/near-constant.d2';
import NearContainer from '@site/static/d2/near-container.d2';
import NearExplanation from '@site/static/d2/near-explanation.d2';
import NearLabelIcon from '@site/static/d2/near-label-icon.d2';

# Positions

In general, positioning is controlled entirely by the layout engine. It's one of the
Expand All @@ -23,99 +29,35 @@ Let's explore some use cases:

### Giving your diagram a title

```d2
title: |md
# A winning strategy
| { near: top-center }
poll the people -> results
results -> unfavorable -> poll the people
results -> favorable -> will of the people
```
<CodeBlock className="language-d2">
{NearConstant}
</CodeBlock>

<div className="embedSVG" dangerouslySetInnerHTML={{__html: require('@site/static/img/generated/near-constant.svg2')}}></div>

### Creating a legend

```d2
direction: right
x -> y: {
style.stroke: green
}
y -> z: {
style.stroke: red
}
legend: {
near: bottom-center
color1: foo {
shape: text
style.font-color: green
}
color2: bar {
shape: text
style.font-color: red
}
}
```
<CodeBlock className="language-d2">
{NearContainer}
</CodeBlock>

<div className="embedSVG" dangerouslySetInnerHTML={{__html: require('@site/static/img/generated/near-container.svg2')}}></div>

### Longform description or explanation

```d2
explanation: |md
# LLMs
The Large Language Model (LLM) is a powerful AI\
system that learns from vast amounts of text data.\
By analyzing patterns and structures in language,\
it gains an understanding of grammar, facts,\
and even some reasoning abilities. As users input text,\
the LLM predicts the most likely next words or phrases\
to create coherent responses. The model\
continuously fine-tunes its output, considering both the\
user's input and its own vast knowledge base.\
This cutting-edge technology enables LLM to generate human-like text,\
making it a valuable tool for various applications.
| {
near: center-left
}
ML Platform -> Pre-trained models
ML Platform -> Model registry
ML Platform -> Compiler
ML Platform -> Validation
ML Platform -> Auditing
Model registry -> Server.Batch Predictor
Server.Online Model Server
```
<CodeBlock className="language-d2">
{NearExplanation}
</CodeBlock>

<div className="embedSVG" dangerouslySetInnerHTML={{__html: require('@site/static/img/generated/near-explanation.svg2')}}></div>

## Label and icon positioning

The `near` can be nested to `label` and `icon` to specify their positions.

```d2
direction: right
x -> y
x: worker {
label.near: top-center
icon: https://icons.terrastruct.com/essentials%2F005-programmer.svg
icon.near: outside-top-right
}
y: profits {
label.near: bottom-right
icon: https://icons.terrastruct.com/essentials%2Fprofits.svg
icon.near: outside-top-left
}
```
<CodeBlock className="language-d2">
{NearLabelIcon}
</CodeBlock>

<div className="embedSVG" dangerouslySetInnerHTML={{__html: require('@site/static/img/generated/near-label-icon.svg2')}}></div>

Expand Down

0 comments on commit f6a53c7

Please sign in to comment.