Metadata-Version: 2.1
Name: flask-tailwind-manager
Version: 0.0.6
Summary: Easily use tailwind css with Flask projects
Author-email: Sebastian Salinas <seba.salinas.delrio@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Sebastian Salinas Del Rio
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/sebasalinass/flask-tailwindcss
Keywords: flask,tailwind,tailwindcss
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: flask<4,>=3.0.0

# Flask-Tailwind-Manager

Flask-Tailwind-Manager provides a simple interface to use TailwindCSS with your Flask project. It will let you hide it in a folder called .tailwind so you dont have to see any node_modules or any other javascript. Even tho you DO need npm and npx to be available on your machine.

```{warning}
🚧 This package is under heavy development..
```

## Installation

Install the extension with pip:

```bash
pip install flask-tailwind-manager
```

## Configuration

This are some of the settings available. All of the configurations are optional, and in most cases it should work without any configuration.

| Config                                   | Description                             | Type | Default         |
| ---------------------------------------- | --------------------------------------- | ---- | --------------- |
| TAILWIND_CWD                             | CWD for node_modules.                   | str  | `.tailwind`     |
| TAILWIND_OUTPUT_PATH                     | CSS file output path inside app static. | str  | `css/style.css` |
| TAILWIND_NPM_BIN_PATH                    | Npm binary path.                        | str  | `npm`           |
| TAILWIND_NPX_BIN_PATH                    | Npx binary path.                        | str  | `npx`           |
| TAILWIND_TEMPLATE_FOLDER                 | Name of the templates folder.           | str  | `templates`     |

## Usage

Once installed Flask-TailwindCSS is easy to use. Let's walk through setting up a basic application. Also please note that this is a very basic guide: we will be taking shortcuts here that you should never take in a real application.

To begin we'll set up a Flask app:

```python
from flask import Flask
from flask_tailwind import TailwindCSS

app = Flask(__name__)

tailwind = TailwindCSS()
tailwind.init_app(app)
```

## Using the CLI tool.

Once you completed the extension configuration, you can access the Flask-TailwindCSS CLI tool. There is 4 useful commands you will use. 
    
1. Installing Node and TailwindCSS basic configuration. By default this extension will generate a `tailwind.config.js` generic file, ready to use. If you need to futher customize you will need to edit this file accordingly.  
```bash
    flask tailwind init 
```   
2. Once installed all modules will be found on `.tailwind` folder (or CWD you define). The default configuration will look for changes at `{APP_NAME}/**/{TEMPLATES_FOLDER}/*{.html,.jinja,.j2}`. You can always modify `tailwind.config.js` file in order to customize it.

3. To start watching files and changes. use the `start` command as follows.
```bash
    flask tailwind start
```
4. Almost every time you are using you will install plugins like Preline, Flowbite, daysiUI, etc... For this cases you can use the `npx` or `npm` commands. In the following example we will install the PrelineUI plugin as follows.
```bash
    flask tailwind npm i preline
```
5. After the installation you will have to configure it manually.

This will ensure the plugins are installed in the correct CWD.
 

## Load resources

Once the extension is set up, this will make available the `tailwind_css` function into the templates context so you could load the generated css like this.

```html
<head>
  {{ tailwind_css() }} 
</head>
```
