Skip to content

Commit b9c09fc

Browse files
committed
docs: started work on added component
1 parent 0c1e09c commit b9c09fc

4 files changed

Lines changed: 34 additions & 1 deletion

File tree

docs/components/component/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The object you use to update the components on the web console. It is also known
2626
|`(Component).type`|The type of the component, or **"unknown"** if it isn't known|
2727
|`(Component).parentID`|The parent ID of the component, if the local thread knows it|
2828
|[`(Component).parent`](parent.md)|Get the parent component of this component|
29-
|[`(Component).back`](parent.md)|Syntax sugar: alias for [`(Component).parent`](parent.md)|
29+
|[`(Component).back`](back.md)|Syntax sugar: alias for [`(Component).parent`](parent.md)|
3030
|`(Component).isDead`|Has this component marked removed.|
3131

3232
## See Also
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# `(Component).parent`
2+
A field of [Component](index.md) that lets you grab the parent component table, if the component knows it's parent.
3+
4+
!!! warning "Type"
5+
This field can be `nil` in such cases where the local thread doesn't know the parent of this component, or it is a root component of type `Tab`.
6+
7+
## Alias
8+
`(Component).back`
9+
: This alias is to make chaining functions more readable.
10+
11+
## Example
12+
```lua
13+
tab:newCard({ size = 5, title = "Info" })
14+
:newContainer()
15+
:addText({ text = "Hello World" })
16+
:addText({ text = "I like Mousse!" })
17+
.back
18+
:newCardBody() -- Call on the `Card` component because of the `.back` call above
19+
:addCardTitle({ text = "Card Title" })
20+
:addCardText({ text = "Card Text" })
21+
:addCardFooter({ text = "Card footer" })
22+
```
23+
24+
## See Also
25+
- [Component](index.md)

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ plugins:
4444
- search
4545
- mike:
4646
version_selector: true
47+
- redirects:
48+
redirect_maps:
49+
'components/component/back.md': 'components/component/parent.md'
4750

4851
extra:
4952
version:

proxy.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@ end
7878
local funcKeys = {
7979
parent = function(raw)
8080
loggingStack.push()
81+
if not raw.parentID then return nil end
8182
local v = proxy.get(raw.parentID)
8283
loggingStack.pop()
8384
return v
8485
end,
8586
back = function(raw) -- Alias for parent
8687
loggingStack.push()
88+
if not raw.parentID then return nil end
8789
local v = proxy.get(raw.parentID)
8890
loggingStack.pop()
8991
return v
@@ -203,6 +205,9 @@ proxy._registerLocalChild = function(parentID, childProxy)
203205
end
204206

205207
proxy._unregisterLocalChild = function(parentID, childID)
208+
if not parentID then
209+
return
210+
end
206211
local list = proxy.localChildren[parentID]
207212
if not list then return end
208213
for i = #list, 1, -1 do

0 commit comments

Comments
 (0)