Skip to content

Commit 39180ba

Browse files
committed
📚 DOCS: Fix sizing classes, grid rows, tab links, MyST prereqs
- Correct the sizing CSS class names to the generated `sd-w-{25,50,75,100,auto}` / `sd-h-{25,50,75,100,auto}` (per `style/_sizing.scss`) (#172) - Note the MyST syntax extensions (`colon_fence`, `html_image`, `attrs_inline`) that the documentation examples rely on (#122) - Add a "Multiple rows" section to the grid docs, and clarify that a single-value column count is fixed across all screen sizes, for both the `grid` argument and the item-level `columns` option (#184, #182) - Document how to author links to synchronised tabs with query strings, from both MyST Markdown and reStructuredText (#247)
1 parent 5f41b8e commit 39180ba

4 files changed

Lines changed: 96 additions & 7 deletions

File tree

docs/css_classes.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ For more information, see [this guide to flexbox](https://css-tricks.com/snippet
9393

9494
## Sizing
9595

96-
Size objects width/height by percentage:
96+
Size objects (`w`)idth/(`h`)eight by percentage:
9797

98-
- `sd-width-25`, `sd-height-25`
99-
- `sd-width-50`, `sd-height-50`
100-
- `sd-width-75`, `sd-height-75`
101-
- `sd-width-100`, `sd-height-100`
102-
- `sd-width-auto`, `sd-height-auto`
98+
- `sd-w-25`, `sd-h-25`
99+
- `sd-w-50`, `sd-h-50`
100+
- `sd-w-75`, `sd-h-75`
101+
- `sd-w-100`, `sd-h-100`
102+
- `sd-w-auto`, `sd-h-auto`
103103

104104
## Spacing
105105

docs/get_started.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ extensions = ["myst_parser", "sphinx_design"]
2424
myst_enable_extensions = ["colon_fence"]
2525
```
2626

27+
:::{note}
28+
The MyST Markdown examples in this documentation assume that certain optional [MyST syntax extensions](https://myst-parser.readthedocs.io/en/latest/syntax/optional.html) have been enabled, *via* the `myst_enable_extensions` configuration above:
29+
30+
- `colon_fence`: used by all examples, to write directives delimited by `:::` fences
31+
- `html_image`: only for examples using raw HTML `<img>` tags, such as the avatar images in [CSS Classes](./css_classes.md)
32+
- `attrs_inline`: only for examples adding attributes to inline elements, such as the links to synchronised [Tabs](./tabs.md)
33+
:::
34+
2735
## Configuration
2836

2937
To hide the title header of a page, add to the top of the page:

docs/grids.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ A `grid` directive can be set with the number of default columns (1 to 12);
1010
either a single number for all screen sizes, or four numbers for extra-small (<576px), small (768px), medium (992px) and large screens (>1200px),
1111
then child `grid-item` directives should be set for each item.
1212

13+
Note, a single number **fixes** the number of columns for all screen sizes,
14+
whereas four numbers allow the layout to adapt responsively to the screen size,
15+
as in the example below.
16+
1317
Try re-sizing the screen to see the number of columns change:
1418

1519
::::{grid} 1 2 3 4
@@ -65,6 +69,54 @@ short text content
6569
:::
6670
::::
6771

72+
## Multiple rows
73+
74+
There is no need to add a directive per row;
75+
when the number of items exceeds the number of columns,
76+
the additional items simply wrap onto new rows, as required:
77+
78+
::::{grid} 3
79+
:outline:
80+
81+
:::{grid-item}
82+
A
83+
:::
84+
:::{grid-item}
85+
B
86+
:::
87+
:::{grid-item}
88+
C
89+
:::
90+
:::{grid-item}
91+
D
92+
:::
93+
::::
94+
95+
However, to deliberately separate items into distinct rows,
96+
use a separate `grid` directive for each row:
97+
98+
::::{grid} 3
99+
:outline:
100+
101+
:::{grid-item}
102+
A
103+
:::
104+
:::{grid-item}
105+
B
106+
:::
107+
::::
108+
109+
::::{grid} 3
110+
:outline:
111+
112+
:::{grid-item}
113+
C
114+
:::
115+
:::{grid-item}
116+
D
117+
:::
118+
::::
119+
68120
## Placing a card in a grid
69121

70122
The `grid-item-card` directive is a short-hand for placing a card content container inside a grid item (see [Cards](./cards.md)). Most of the `card` directive's options can be used also here:
@@ -134,7 +186,9 @@ B
134186
You can override the number of columns a single item takes up by using the `columns` option of the `grid-item` directive.
135187
Given the total columns are 12, this means 12 would indicate a single item takes up the entire grid row, or 6 half.
136188
Alternatively, use `auto` to automatically decide how many columns to use based on the item content.
137-
Like for grid columns, you can either provide a single number or four for small, medium and large and extra-large screens.
189+
Like for grid columns, you can either provide a single number or four for small, medium and large and extra-large screens,
190+
and likewise, a single number fixes the item's width for all screen sizes,
191+
overriding any responsive behaviour set by the parent `grid`.
138192

139193
::::{grid} 2
140194
:::{grid-item-card}

docs/tabs.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,33 @@ Content 2
9797
````
9898
`````
9999

100+
### Linking to synchronised tabs
101+
102+
To author a link that pre-selects a tab, append the query string (and optionally a page anchor) to the URL of the **built** HTML page.
103+
Sphinx referencing roles, such as `ref` and `doc`, cannot output URLs containing query strings,
104+
so instead write the URL directly:
105+
106+
- In MyST Markdown, add an `external` class to the link (using the [`attrs_inline` extension](https://myst-parser.readthedocs.io/en/latest/syntax/optional.html)), so that the URL is output as-is, rather than being resolved as a cross-reference.
107+
- In reStructuredText, use a standard (external) hyperlink.
108+
109+
````{tab-set-code}
110+
```{code-block} markdown
111+
[Open with key2 selected](tabs.html?category=key2#synchronised-tabs){.external}
112+
```
113+
```{code-block} rst
114+
`Open with key2 selected <tabs.html?category=key2#synchronised-tabs>`_
115+
```
116+
````
117+
118+
For example: [open the tabs above with `key2` selected](tabs.html?category=key2#synchronised-tabs){.external}
119+
120+
:::{warning}
121+
Such URLs are relative to the location of the current page in the built HTML output, not to the source files
122+
(for example, a page in a sub-folder would require `../tabs.html?...`).
123+
They are not checked by Sphinx, so they will break silently if the target page is moved,
124+
and they do not apply to other output formats.
125+
:::
126+
100127
## Tabbed code examples
101128

102129
The `tab-set-code` directive provides a shorthand for synced code examples.

0 commit comments

Comments
 (0)