You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Allow `use_mutation` to have `refetch=None`, as the docs suggest is possible.
- `use_origin` hook to return the browser's `location.origin`
- Fix flaky `test_use_query_and_mutation` test (Key presses require at least 100ms between `keyup`/`keydown` on GH actions)
- Logging for `use_mutation`/`use_query` errors (currently silent, which is very hard to debug)
- Document `use_mutation`'s `reset()`
- Document `use_query` requires a `Model` or `QuerySet` return (due to enforcing no lazy queries)
- Document interface on all APIs
- Documentation misc cleanup and styling
Copy file name to clipboardExpand all lines: docs/src/features/components.md
+67-31
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,14 @@
1
+
???+ summary
2
+
3
+
Prefabricated components can be used within your `components.py` to help simplify development.
4
+
1
5
## View To Component
2
6
3
7
Convert any Django view into a IDOM component by usng this decorator. Compatible with sync/async [Function Based Views](https://docs.djangoproject.com/en/dev/topics/http/views/) and [Class Based Views](https://docs.djangoproject.com/en/dev/topics/class-based-views/).
4
8
5
9
=== "components.py"
6
10
7
-
```python
11
+
```python linenums="1"
8
12
from idom import component, html
9
13
from django_idom.components import view_to_component
10
14
from .views import hello_world_view
@@ -47,7 +51,7 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
47
51
48
52
=== "components.py"
49
53
50
-
```python
54
+
```python linenums="1"
51
55
from idom import component, html
52
56
from django_idom.components import view_to_component
53
57
from .views import HelloWorldView
@@ -69,7 +73,7 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
69
73
70
74
=== "components.py"
71
75
72
-
```python
76
+
```python linenums="1"
73
77
from idom import component, html
74
78
from django_idom.components import view_to_component
75
79
from .views import hello_world_view
@@ -99,7 +103,7 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
99
103
100
104
=== "components.py"
101
105
102
-
```python
106
+
```python linenums="1"
103
107
from idom import component, html
104
108
from django_idom.components import view_to_component
105
109
from .views import hello_world_view
@@ -125,7 +129,7 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
125
129
126
130
=== "components.py"
127
131
128
-
```python
132
+
```python linenums="1"
129
133
from idom import component, html
130
134
from django_idom.components import view_to_component
131
135
from .views import hello_world_view
@@ -153,7 +157,7 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
153
157
154
158
=== "components.py"
155
159
156
-
```python
160
+
```python linenums="1"
157
161
from idom import component, html
158
162
from django_idom.components import view_to_component
159
163
from .views import hello_world_view
@@ -174,7 +178,7 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
174
178
175
179
=== "views.py"
176
180
177
-
```python
181
+
```python linenums="1"
178
182
from django.http import HttpResponse
179
183
180
184
def hello_world_view(request, *args, **kwargs):
@@ -185,17 +189,33 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
185
189
186
190
Allows you to defer loading a CSS stylesheet until a component begins rendering. This stylesheet must be stored within [Django's static files](https://docs.djangoproject.com/en/dev/howto/static-files/).
187
191
188
-
```python title="components.py"
189
-
from idom import component, html
190
-
from django_idom.components import django_css
192
+
=== "components.py"
193
+
194
+
```python linenums="1"
195
+
from idom import component, html
196
+
from django_idom.components import django_css
197
+
198
+
@component
199
+
def my_component():
200
+
return html.div(
201
+
django_css("css/buttons.css"),
202
+
html.button("My Button!"),
203
+
)
204
+
```
191
205
192
-
@component
193
-
defmy_component():
194
-
return html.div(
195
-
django_css("css/buttons.css"),
196
-
html.button("My Button!"),
197
-
)
198
-
```
206
+
??? example "See Interface"
207
+
208
+
<font size="4">**Parameters**</font>
209
+
210
+
| Name | Type | Description | Default |
211
+
| --- | --- | --- | --- |
212
+
| static_path | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
213
+
214
+
<font size="4">**Returns**</font>
215
+
216
+
| Type | Description |
217
+
| --- | --- |
218
+
| `Component` | An IDOM component. |
199
219
200
220
??? question "Should I put `django_css` at the top of my component?"
201
221
@@ -207,7 +227,7 @@ def my_component():
207
227
208
228
Here's an example on what you should avoid doing for Django static files:
209
229
210
-
```python
230
+
```python linenums="1"
211
231
from idom import component, html
212
232
from django.templatetags.static import static
213
233
@@ -225,7 +245,7 @@ def my_component():
225
245
226
246
For external CSS, substitute `django_css` with `html.link`.
227
247
228
-
```python
248
+
```python linenums="1"
229
249
from idom import component, html
230
250
231
251
@component
@@ -246,17 +266,33 @@ def my_component():
246
266
247
267
Allows you to defer loading JavaScript until a component begins rendering. This JavaScript must be stored within [Django's static files](https://docs.djangoproject.com/en/dev/howto/static-files/).
248
268
249
-
```python title="components.py"
250
-
from idom import component, html
251
-
from django_idom.components import django_js
269
+
=== "components.py"
270
+
271
+
```python linenums="1"
272
+
from idom import component, html
273
+
from django_idom.components import django_js
274
+
275
+
@component
276
+
def my_component():
277
+
return html.div(
278
+
html.button("My Button!"),
279
+
django_js("js/scripts.js"),
280
+
)
281
+
```
252
282
253
-
@component
254
-
defmy_component():
255
-
return html.div(
256
-
html.button("My Button!"),
257
-
django_js("js/scripts.js"),
258
-
)
259
-
```
283
+
??? example "See Interface"
284
+
285
+
<font size="4">**Parameters**</font>
286
+
287
+
| Name | Type | Description | Default |
288
+
| --- | --- | --- | --- |
289
+
| static_path | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
290
+
291
+
<font size="4">**Returns**</font>
292
+
293
+
| Type | Description |
294
+
| --- | --- |
295
+
| `Component` | An IDOM component. |
260
296
261
297
??? question "Should I put `django_js` at the bottom of my component?"
262
298
@@ -268,7 +304,7 @@ def my_component():
268
304
269
305
Here's an example on what you should avoid doing for Django static files:
270
306
271
-
```python
307
+
```python linenums="1"
272
308
from idom import component, html
273
309
from django.templatetags.static import static
274
310
@@ -286,7 +322,7 @@ def my_component():
286
322
287
323
For external JavaScript, substitute `django_js` with `html.script`.
0 commit comments