-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from curtis-allan/tw-cli
Added Scroll Area & Aspect Ratio
- Loading branch information
Showing
17 changed files
with
667 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
## Setup | ||
|
||
Make sure the relevant packages are installed, and setup the imports as shown below. | ||
|
||
> [!NOTE] | ||
> If you wish to seperately import components you can do so too. Make sure to import and setup `ShadHead()` as well. | ||
```python | ||
from fasthtml import * | ||
from shad4fast import * | ||
|
||
app, rt = fast_app(pico=False, hdrs=(ShadHead(),)) | ||
``` | ||
|
||
--- | ||
|
||
## Usage | ||
|
||
To use the aspect ratio component, structure your code as with a normal FT method. The component takes a `ratio` parameter, which is the width by height of the aspect ratio you wish to create. | ||
|
||
```python | ||
AspectRatio( | ||
Img( | ||
src="/public/aspect.webp", | ||
cls="w-full h-full rounded-md object-cover", | ||
loading="lazy", | ||
), | ||
ratio={16 / 9}, | ||
) | ||
``` | ||
|
||
--- | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --------- | ---------------------------------------------------------------------------------- | --------------------------------------- | | ||
| ratio | ratio value: either `{width / height}`, `height / width` or the ratio as a `float` | The width by height of the aspect ratio | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## Setup | ||
|
||
Make sure the relevant packages are installed, and setup the imports as shown below. | ||
|
||
> [!NOTE] | ||
> If you wish to seperately import components you can do so too. Make sure to import and setup `ShadHead()` as well. | ||
```python | ||
from fasthtml import * | ||
from shad4fast import * | ||
|
||
app, rt = fast_app(pico=False, hdrs=(ShadHead(),)) | ||
``` | ||
|
||
--- | ||
|
||
## Usage | ||
|
||
To use the scroll area component, structure your code as with a normal FT method. The component takes an `orientation` parameter, which is the orientation of the scroll area. | ||
|
||
```python | ||
def fake_data(): | ||
results = () | ||
for i in range(50): | ||
results += (Div(f"Item Entry #{i}", cls="text-sm"), Separator(cls="my-2")) | ||
return results | ||
|
||
ScrollArea( | ||
Div( | ||
H4("Entries", cls="mb-4 text-sm font-medium leading-none"), | ||
*fake_data(), | ||
cls="p-4", | ||
), | ||
cls="h-72 w-48 rounded-md border", | ||
) | ||
``` | ||
|
||
> [!NOTE] | ||
> If not set, the orientation will default to `vertical`. | ||
--- | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| ----------- | ----- | ---------------------------------------------------------- | | ||
| orientation | `str` | The orientation of the scroll area. Defaults to `vertical` | |
Oops, something went wrong.