Skip to content

Commit 126ea59

Browse files
committed
rename element to component
1 parent 6fd73fd commit 126ea59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+524
-533
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ IDOM can be used to create a simple slideshow which changes whenever a user clic
5050
```python
5151
import idom
5252

53-
@idom.element
53+
@idom.component
5454
def Slideshow():
5555
index, set_index = idom.hooks.use_state(0)
5656
url = f"https://picsum.photos/800/300?image={index}"

docs/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def forward_to_index(request):
2323
return response.redirect("/docs/index.html")
2424

2525

26-
mount, element = multiview()
26+
mount, component = multiview()
2727

2828
examples_dir = here / "source" / "examples"
2929
sys.path.insert(0, str(examples_dir))
@@ -54,7 +54,9 @@ async def forward_to_index(request):
5454
idom.run = original_run
5555

5656

57-
server = PerClientStateServer(element, {"redirect_root_to_index": False}).register(app)
57+
server = PerClientStateServer(component, {"redirect_root_to_index": False}).register(
58+
app
59+
)
5860

5961

6062
def production():

docs/source/core-concepts.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ This section covers core features of IDOM that are used in making
55
interactive interfaces.
66

77

8-
Pure Elements
9-
-------------
8+
Pure Components
9+
---------------
1010

1111
As in most programming paradigms, so many of the problems come down to how we manage
1212
state. The first tool in encouraging its proper curation is the usage of
@@ -17,7 +17,7 @@ way to manage state is to have no state at all."
1717
With IDOM the core of your application will be built on the back of basic functions and
1818
coroutines that return :ref:`VDOM <VDOM Mimetype>` models and which do so without state
1919
and without `side effects`_. We call these kinds of model rendering functions
20-
:ref:`Pure Elements`. For example, one might want a function which
20+
:ref:`Pure Components`. For example, one might want a function which
2121
accepted a list of strings and turned it into a series of paragraph elements:
2222

2323
.. code-block::
@@ -26,12 +26,12 @@ accepted a list of strings and turned it into a series of paragraph elements:
2626
return idom.html.div([idom.html.p(text) for text in list_of_text])
2727
2828
29-
Stateful Elements
30-
-----------------
29+
Stateful Components
30+
-------------------
3131

32-
A Stateful Element is one which uses a :ref:`Life Cycle Hooks`. These life cycle hooks
33-
allow you to add state to otherwise stateless functions. To create a stateful element
34-
you'll need to apply the :func:`~idom.core.element.element` decorator to a coroutine_
32+
A Stateful Component is one which uses a :ref:`Life Cycle Hooks`. These life cycle hooks
33+
allow you to add state to otherwise stateless functions. To create a stateful component
34+
you'll need to apply the :func:`~idom.core.component.component` decorator to a coroutine_
3535
whose body contains a hook usage. We'll demonstrate that with a simple
3636
:ref:`click counter`:
3737

@@ -40,7 +40,7 @@ whose body contains a hook usage. We'll demonstrate that with a simple
4040
import idom
4141

4242

43-
@idom.element
43+
@idom.component
4444
def ClickCount():
4545
count, set_count = idom.hooks.use_state(0)
4646

@@ -50,14 +50,14 @@ whose body contains a hook usage. We'll demonstrate that with a simple
5050
)
5151

5252

53-
Element Layout
54-
--------------
53+
Component Layout
54+
----------------
5555

56-
Displaying an element requires you to turn elements into :ref:`VDOM <VDOM Mimetype>` -
56+
Displaying components requires you to turn them into :ref:`VDOM <VDOM Mimetype>` -
5757
this is done using a :class:`~idom.core.layout.Layout`. Layouts are responsible for
58-
rendering elements (turning them into VDOM) and scheduling their re-renders when they
58+
rendering components (turning them into VDOM) and scheduling their re-renders when they
5959
:meth:`~idom.core.layout.Layout.update`. To create a layout, you'll need an
60-
:class:`~idom.core.element.Element` instance, which will become its root, and won't
60+
:class:`~idom.core.component.Component` instance, which will become its root, and won't
6161
ever be removed from the model. Then you'll just need to call and await a
6262
:meth:`~idom.core.layout.Layout.render` which will return a :ref:`JSON Patch`:
6363

@@ -80,7 +80,7 @@ have to re-render the layout and see what changed:
8080
event_handler_id = "on-click"
8181

8282

83-
@idom.element
83+
@idom.component
8484
def ClickCount():
8585
count, set_count = idom.hooks.use_state(0)
8686

@@ -212,7 +212,7 @@ models:
212212
import idom
213213
from idom.server.sanic import PerClientStateServer
214214
215-
@idom.element
215+
@idom.component
216216
def View(self):
217217
return idom.html.h1(["Hello World"])
218218
@@ -233,7 +233,7 @@ The implementation registers hooks into the application to serve the model once
233233
234234
app = Sanic()
235235
236-
@idom.element
236+
@idom.component
237237
def View(self):
238238
return idom.html.h1(["Hello World"])
239239

docs/source/examples/click_count.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import idom
22

33

4-
@idom.element
4+
@idom.component
55
def ClickCount():
66
count, set_count = idom.hooks.use_state(0)
77

docs/source/examples/material_ui_button_no_action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
material_ui = idom.install("@material-ui/core", fallback="loading...")
44

55
idom.run(
6-
idom.element(
6+
idom.component(
77
lambda: material_ui.Button(
88
{"color": "primary", "variant": "contained"}, "Hello World!"
99
)

docs/source/examples/material_ui_button_on_click.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
material_ui = idom.install("@material-ui/core", fallback="loading...")
77

88

9-
@idom.element
9+
@idom.component
1010
def ViewSliderEvents():
1111
event, set_event = idom.hooks.use_state(None)
1212

docs/source/examples/material_ui_slider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
material_ui = idom.install("@material-ui/core", fallback="loading...")
77

88

9-
@idom.element
9+
@idom.component
1010
def ViewSliderEvents():
1111
event, set_event = idom.hooks.use_state(None)
1212

docs/source/examples/matplotlib_plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from idom.widgets.html import image
77

88

9-
@idom.element
9+
@idom.component
1010
def PolynomialPlot():
1111
coefficients, set_coefficients = idom.hooks.use_state([0])
1212

@@ -19,7 +19,7 @@ def PolynomialPlot():
1919
)
2020

2121

22-
@idom.element
22+
@idom.component
2323
def ExpandableNumberInputs(values, set_values):
2424
inputs = []
2525
for i in range(len(values)):

docs/source/examples/simple_dashboard.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
victory = idom.install("victory", fallback="loading...")
1010

1111

12-
@idom.element
12+
@idom.component
1313
def RandomWalk():
1414
mu = idom.hooks.use_ref(0)
1515
sigma = idom.hooks.use_ref(1)
@@ -38,7 +38,7 @@ def RandomWalk():
3838
)
3939

4040

41-
@idom.element
41+
@idom.component
4242
def RandomWalkGraph(mu, sigma):
4343
interval = use_interval(0.5)
4444
data, set_data = idom.hooks.use_state([{"x": 0, "y": 0}] * 50)
@@ -56,7 +56,7 @@ async def animate():
5656
return victory.VictoryLine({"data": data, "style": {"parent": {"width": "500px"}}})
5757

5858

59-
@idom.element
59+
@idom.component
6060
def NumberInput(label, value, set_value_callback, domain):
6161
minimum, maximum, step = domain
6262
attrs = {"min": minimum, "max": maximum, "step": step}

docs/source/examples/slideshow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import idom
22

33

4-
@idom.element
4+
@idom.component
55
def Slideshow():
66
index, set_index = idom.hooks.use_state(0)
77

0 commit comments

Comments
 (0)