feat(docs): Update context to context-and-state

This commit is contained in:
Gervwyk 2021-01-22 16:36:02 +02:00
parent 938e6fc7b4
commit d6b0081099
3 changed files with 59 additions and 42 deletions

View File

@ -0,0 +1,55 @@
# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/general.yaml.njk
vars:
pageId: context-and-state
pageTitle: Context and State
section: Concepts
content:
- id: md1
type: Markdown
style:
'.markdown-body':
fontSize: 14px
properties:
content: |
#### TDLR;
- The first block on a page must be a `context` category.
- A page can have multiple `context` blocks.
- Every `context` has a single __state__ object.
- All input blocks writes their value to __state__, with the their `id` as the key in the __state__ object.
- Input blocks which are not visible is removed from __state__.
- The [`SetState`](/SetState) action can also modify the __state__ object.
-------
A Lowdefy block with category `context` provides the environment for a part of a Lowdefy app to run in. More than one context can be placed on a page, but generally only one is need. The first block on a page must be a `context` category block.
The standard page blocks like [`PageHeaderMenu`](/PageHeaderMenu) or [`PageSiderMenu`](/PageSiderMenu) are all `context` category blocks, and the [`Context`](/Context) block is a simple container that also provides a context.
Each context provides encapsulation to the blocks inside it. It has it's own __state__ object as well as requests.
Every `input` category block will have a value in the __state__ object, with the their `id` as the key in the __state__ object, unless the block is not visible, in which case the input value is removed the state object.
The only other way to modify the __state__ object is to use a `SetState` action. See [`SetState`](/SetState) and [`actions`](/actions) for more details.
- _ref:
path: templates/navigation_buttons.yaml
vars:
previous_page_title: Tutorial
previous_page_id: tutorial-setup
next_page_title: Actions
next_page_id: actions

View File

@ -1,38 +0,0 @@
# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/general.yaml.njk
vars:
pageId: context
pageTitle: Context
section: Concepts
content:
- id: md1
type: Markdown
style:
'.markdown-body':
fontSize: 14px
properties:
content: |
A Lowdefy block with category `context` provides the environment for a part of a Lowdefy app to run in. More than one context can be placed on a page, but generally only is need. The first block on a page should be a `context` category block. The standard page blocks like [`PageHeaderMenu`](/PageHeaderMenu) or [`PageSiderMenu`](/PageSiderMenu) are all `context` category blocks, and the [`Context`](/Context) block is a simple container that also provides a context.
Each context provides encapsulation to the blocks inside it. It has it's own state object and requests.
- _ref:
path: templates/navigation_buttons.yaml
vars:
previous_page_title: Next Steps
previous_page_id: next-steps
next_page_title: Actions
next_page_id: actions

View File

@ -85,11 +85,11 @@ menus:
title: Concepts
icon: BulbOutlined
links:
- id: context
- id: context-and-state
type: MenuLink
pageId: context
pageId: context-and-state
properties:
title: Context
title: Context and State
- id: actions
type: MenuLink
pageId: actions
@ -243,7 +243,7 @@ pages:
- _ref: tutorial/tutorial-requests.yaml
- _ref: tutorial/next-steps.yaml
- _ref: concepts/context.yaml
- _ref: concepts/context-and-state.yaml
- _ref: concepts/actions.yaml
- _ref: concepts/connections.yaml
- _ref: concepts/layout.yaml