Browse Source

add content pseudo element to builder (#1680)

resolves #1659

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Fred Lefévère-Laoide 9 months ago
parent
commit
f624ef246c

+ 1 - 1
taipy/gui/builder/__init__.py

@@ -10,7 +10,7 @@
 # specific language governing permissions and limitations under the License.
 
 from ._api_generator import _ElementApiGenerator
-from ._element import html
+from ._element import content, html
 
 # separate import for "Page" class so stubgen can properly generate pyi file
 from .page import Page

+ 19 - 0
taipy/gui/builder/_element.py

@@ -254,3 +254,22 @@ class _Control(_Element):
 
     def __exit__(self, exc_type, exc_value, traceback):
         raise RuntimeError(f"Can't use Context Manager for control type '{self._ELEMENT_NAME}'")
+
+
+class content(_Control):
+    """
+    Create a `content` pseudo-element
+
+    Arguments:
+            None
+
+        Examples:
+            - To generate `content`, use:
+               ```
+               content()
+               ```
+    """
+
+    def _render(self, gui: "Gui") -> str:
+        el = _BuilderFactory.create_element(gui, "content", {})
+        return f"{el[0]}</{el[1]}>"

+ 22 - 0
tests/gui/builder/control/test_content.py

@@ -0,0 +1,22 @@
+# Copyright 2021-2024 Avaiga Private Limited
+#
+# 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.
+import taipy.gui.builder as tgb
+from taipy.gui import Gui
+
+
+def test_content_builder(gui: Gui, test_client, helpers):
+    with tgb.Page(frame=None) as page:
+        tgb.content()
+    expected_list = [
+        '<PageContent ',
+        '></PageContent>',
+    ]
+    helpers.test_control_builder(gui, page, expected_list)