Skip to content

Commit

Permalink
Updated to 0.0.5 alpha.
Browse files Browse the repository at this point in the history
  • Loading branch information
Almas-Ali committed May 29, 2023
1 parent af2d9f7 commit 433adde
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs_src/docs/widgets/attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Attributes

## Attributes of widgets

All widgets have some attributes that can be used to customize the widget. The attributes are:

### load_css

This attribute is used to load the CSS of the widget. It is a boolean value. If it is `True`, the CSS of the widget will be loaded. If it is `False`, the CSS of the widget will not be loaded. The default value is `False`. If you need to add the CSS of the widget, you can add it manually. `FormWidget(load_css=True)` will load the CSS of the `FormWidget` widget.

### forms_type

This attribute is used to set the type of the form. It is a string value. The default value is `loginform`. Currently, we are working on `loginform`, `registrationform`, `contactform`, `searchform`, `subscribeform` and `commentform`. More will come soon. `FormWidget(forms_type="loginform")` will set the type of the form to `loginform`.

### action

This attribute is used to set the action of the form. It is a string value. The default value is `#`. `FormWidget(action="/login")` will set the action of the form to `/login`. If you need to set the action of the form to the current page, you can set it to `""` or `#`.

### method

This attribute is used to set the method of the form. It is a string value. The default value is `POST`. `FormWidget(method="GET")` will set the method of the form to `GET`.

### add_element

This attribute is used to add more elements to the form. You can use it `FormWidget().add_element(element)` to add an element to the form. `FormWidget().add_element(Input(type="text", name="username"))` will add an input element to the form.

34 changes: 34 additions & 0 deletions docs_src/docs/widgets/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Widgets Introduction

## What is a widget?

A widget is a set of components that can be used to build a user interface (UI) smoothly and very quickly. Widgets are build for making development process easier and faster. Widgets are also used to make the UI more beautiful and attractive with a single line of code.

## How to use a widget?

To use a widget, you need to import it from the `fronty.html.widgets` module. For example, if you need to make a login form, you can use the `FormWidget` widget. You can simply call the `FormWidget` class and add it to your page.

```py linenums="1" title="main.py" hl_lines="16"
from fronty.html.widgets import FormWidget
from fronty.html import *

from flask import Flask

app = Flask(__name__)

@app.route("/")
def login():
return Html(
Head(
Meta(charset="utf-8"),
Title("Test case"),
),
Body(
FormWidget(load_css=True)
)
).render()


if __name__ == "__main__":
app.run(debug=True)
```
3 changes: 3 additions & 0 deletions docs_src/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ nav:
- Introduction: components/js/introduction.md
- Customization:
- HTML Customization: customization/customized-html.md
- Widgets:
- Introduction: widgets/introduction.md
- Attributes: widgets/attributes.md
- Projects:
- Starter Project: projects/starter-project.md
- Bootstrap Integration: projects/bootstrap-integration.md
Expand Down

0 comments on commit 433adde

Please sign in to comment.