Skip to content

Commit 2d790ee

Browse files
authored
✨ NEW: Add animations (#12)
1 parent 6d9252d commit 2d790ee

File tree

9 files changed

+140
-3
lines changed

9 files changed

+140
-3
lines changed

docs/css_classes.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ These classes center an image, set their size and add a circular crop:
253253
- `sd-avatar-md`
254254
- `sd-avatar-lg`
255255
- `sd-avatar-xl`
256+
- `sd-avatar-inherit`
257+
- `sd-avatar-initial`
256258

257259
````{grid} 1 2 3 3
258260
:gutter: 1
@@ -273,3 +275,13 @@ These classes center an image, set their size and add a circular crop:
273275
<img src="images/ebp-logo.png" class="sd-avatar-xl sd-border-1">
274276
```
275277
````
278+
279+
## Load Animations
280+
281+
Add CSS animations when loading elements using the `sd-animate-{name}` classes:
282+
283+
- `sd-animate-slide-from-left`
284+
- `sd-animate-slide-from-right`
285+
- `sd-animate-grow100`
286+
- `sd-animate-grow50`
287+
- `sd-animate-grow50-rot20`

docs/grids.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# Grids
44

5+
## Introduction
6+
57
Grids are based on a 12 column system, which can adapt to the size of the viewing screen.
68

79
A `grid` directive can be set with the number of default columns (1 to 12);
@@ -65,6 +67,8 @@ short text content
6567
:::
6668
::::
6769

70+
## Placing a card in a grid
71+
6872
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:
6973

7074
::::{grid} 2
@@ -90,6 +94,8 @@ B
9094
````
9195
`````
9296

97+
## Controlling spacing between items
98+
9399
You can set the spacing between grid items with the `gutter` option.
94100
Like for grid columns, you can either provide a single number or four for small, medium and large and extra-large screens.
95101

@@ -129,6 +135,8 @@ B
129135
````
130136
`````
131137

138+
## Item level column width
139+
132140
You can override the number of columns a single item takes up by using the `columns` option of the `grid-item` directive.
133141
Given the total columns are 12, this means 12 would indicate a single item takes up the entire grid row, or 6 half.
134142
Alternatively, use `auto` to automatically decide how many columns to use based on the item content.
@@ -166,6 +174,29 @@ C
166174
````
167175
`````
168176

177+
## Reversing the item order
178+
179+
Use the `grid` directive's `reverse` option to reverse the order of the items.
180+
This can be useful if you want an item to be on the right side on large screens, but at the top on small screens.
181+
182+
::::{grid} 1 1 2 2
183+
:reverse:
184+
185+
:::{grid-item}
186+
```{image} ./images/ebp-logo.png
187+
:width: 200px
188+
:class: sd-m-auto
189+
```
190+
:::
191+
192+
:::{grid-item-card}
193+
Some text
194+
:::
195+
196+
::::
197+
198+
## Nesting grids
199+
169200
Grids can be nested in other grids to create complex, adaptive layouts:
170201

171202
::::::{grid} 1 1 2 2
@@ -259,6 +290,9 @@ text-align
259290
outline
260291
: Create a border around the grid.
261292

293+
reverse
294+
: Reverse the order of the grid items.
295+
262296
class-container
263297
: Additional CSS classes for the grid container element.
264298

docs/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# sphinx-design
22

33
```{article-info}
4-
:avatar: images/mugshot.jpeg
5-
:avatar-link: https://github.com/chrisjsewell
4+
:avatar: images/ebp-logo.png
5+
:avatar-link: https://executablebooks.org
66
:author: "[Chris Sewell](https://github.com/chrisjsewell)"
77
:date: "{sub-ref}`today`"
88
:read-time: "5 min read"
9+
:class-avatar: sd-animate-grow50-rot20
910
```
1011

1112
A sphinx extension for designing beautiful, screen-size responsive web components.

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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class GridDirective(SphinxDirective):
107107
"padding": padding_option,
108108
"text-align": text_align,
109109
"outline": directives.flag,
110+
"reverse": directives.flag,
110111
"class-container": directives.class_option,
111112
"class-row": directives.class_option,
112113
}
@@ -138,6 +139,7 @@ def run(self) -> List[nodes.Node]:
138139
["sd-row"]
139140
+ column_classes
140141
+ self.options.get("gutter", [])
142+
+ (["sd-flex-row-reverse"] if "reverse" in self.options else [])
141143
+ self.options.get("class-row", []),
142144
)
143145
self.set_source_info(row)

style/_animations.scss

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
@keyframes sd-slide-from-left {
2+
0% {
3+
transform: translateX(-100%);
4+
}
5+
100% {
6+
transform: translateX(0);
7+
}
8+
}
9+
10+
@keyframes sd-slide-from-right {
11+
0% {
12+
transform: translateX(200%);
13+
}
14+
100% {
15+
transform: translateX(0);
16+
}
17+
}
18+
19+
@keyframes sd-grow100 {
20+
0% {
21+
transform: scale(0);
22+
opacity: 0.5;
23+
}
24+
100% {
25+
transform: scale(1);
26+
opacity: 1;
27+
}
28+
}
29+
30+
@keyframes sd-grow50 {
31+
0% {
32+
transform: scale(0.5);
33+
opacity: 0.5;
34+
}
35+
100% {
36+
transform: scale(1);
37+
opacity: 1;
38+
}
39+
}
40+
41+
@keyframes sd-grow50-rot20 {
42+
0% {
43+
transform: scale(0.5) rotateZ(-20deg);
44+
opacity: 0.5;
45+
}
46+
75% {
47+
transform: scale(1) rotateZ(5deg);
48+
opacity: 1;
49+
}
50+
95% {
51+
transform: scale(1) rotateZ(-1deg);
52+
opacity: 1;
53+
}
54+
100% {
55+
transform: scale(1) rotateZ(0);
56+
opacity: 1;
57+
}
58+
}
59+
60+
// animation is shorthand for 'animation-' properties:
61+
// duration | easing-function | delay | iteration-count | direction | fill-mode | play-state | name
62+
63+
.sd-animate-slide-from-left {
64+
animation: 1s ease-out 0s 1 normal none running sd-slide-from-left;
65+
}
66+
67+
.sd-animate-slide-from-right {
68+
animation: 1s ease-out 0s 1 normal none running sd-slide-from-right;
69+
}
70+
71+
.sd-animate-grow100 {
72+
animation: 1s ease-out 0s 1 normal none running sd-grow100;
73+
}
74+
75+
.sd-animate-grow50 {
76+
animation: 1s ease-out 0s 1 normal none running sd-grow50;
77+
}
78+
79+
.sd-animate-grow50-rot20 {
80+
animation: 1s ease-out 0s 1 normal none running sd-grow50-rot20;
81+
}

style/_grids.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,7 @@ $gutter-widths: $spacings;
172172
}
173173
}
174174
}
175+
176+
.sd-flex-row-reverse {
177+
flex-direction: row-reverse !important;
178+
}

style/_icons.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ $avatar-sizes: (
1010
md: 5rem,
1111
lg: 7rem,
1212
xl: 10rem,
13+
inherit: inherit,
14+
initial: initial
1315
);
1416

1517
@each $size, $value in $avatar-sizes {

style/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@import './display';
55
@import './text';
66
@import './borders';
7+
@import './animations';
78
@import './badge';
89
@import './button';
910
@import './icons';

0 commit comments

Comments
 (0)