Skip to content

Commit cb42139

Browse files
authored
👌IMPROVE: Allow auto for grid columns (#8)
1 parent 23c3d9f commit cb42139

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ rtd PRs not working
8787

8888
size octicons to 1rem etc
8989

90+
empty grid item
91+
9092
[github-ci]: https://github.com/executablebooks/sphinx-design/workflows/continuous-integration/badge.svg?branch=main
9193
[github-link]: https://github.com/executablebooks/sphinx-design
9294
[codecov-badge]: https://codecov.io/gh/executablebooks/sphinx-design/branch/main/graph/badge.svg

docs/badges_buttons.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ A coloured icon: :octicon-16:`report;sd-text-info`, some more text.
166166
```
167167
````
168168

169-
````{Dropdown} All Octicons (16px)
169+
````{dropdown} All Octicons (16px)
170170
```{_all-octicon}
171171
:size: 16
172172
```
173173
````
174174

175-
````{Dropdown} All Octicons (24px)
175+
````{dropdown} All Octicons (24px)
176176
```{_all-octicon}
177177
:size: 24
178178
```

docs/css_classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Some CSS styled text
2323
````
2424
`````
2525

26-
If you find yourself using a class(es) often, consider openeing an issue to request a new role/directive or option!
26+
If you find yourself using a class(es) often, consider opening an issue to request a new role/directive or option!
2727

2828
## Text
2929

docs/grids.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,30 @@ D
4141
````
4242
`````
4343

44+
You can also use the `auto` value for the column width(s), to size columns based on the natural width of their content.
45+
46+
::::{grid} auto
47+
48+
:::{grid-item}
49+
:outline:
50+
:padding: 2
51+
52+
short text content
53+
:::
54+
:::{grid-item}
55+
:outline:
56+
:padding: 2
57+
58+
some longer text content
59+
:::
60+
:::{grid-item}
61+
:outline:
62+
:padding: 2
63+
64+
short text content
65+
:::
66+
::::
67+
4468
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:
4569

4670
::::{grid} 2

sphinx_design/compiled/style.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sphinx_design/grids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def _media_option(
7373
def row_columns_option(argument: Optional[str]) -> List[str]:
7474
"""Validate the number of columns (out of 12) a grid row will have.
7575
76-
One or four integers (for "xs sm md lg") between 1 and 12.
76+
One or four integers (for "xs sm md lg") between 1 and 12 (or 'auto').
7777
"""
78-
return _media_option(argument, "sd-row-cols-")
78+
return _media_option(argument, "sd-row-cols-", allow_auto=True)
7979

8080

8181
def item_columns_option(argument: Optional[str]) -> List[str]:

style/_grids.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ $gutter-widths: $spacings;
8181
-ms-flex: 1 0 0%;
8282
}
8383

84+
.sd-row-cols-auto > * {
85+
flex: 0 0 auto;
86+
width: auto;
87+
}
88+
8489
@for $i from 1 through 12 {
8590
.sd-row-cols-#{$i} {
8691
> * {

0 commit comments

Comments
 (0)