django-cotton-components


Namedjango-cotton-components JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryA Django package with pre-built cotton-based UI components for rapid development.
upload_time2024-11-01 13:32:56
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 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.
keywords django components ui cotton
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django Cotton Components

A collection of pre-built, stylish, and functional form components to streamline your Django development process.

## Key Features:

- Pre-built Components: Quickly add common form elements like text inputs, textareas, select boxes, and more.
- Alpine.js for Interactivity: Leverage Alpine.js to add dynamic behavior to your components without relying on full-fledged JavaScript frameworks.
- Easy to Use: Simple installation and configuration, allowing you to focus on building your application.

## Dependencies:

- [Django-Cotton](https://django-cotton.com/)
- [AlpineJs](https://alpinejs.dev/)
- [TailwindCSS](https://tailwindcss.com/) (optional)

## Installation:

```python

    pip install django-cotton-components

```

- Follow the [Django-Cotton](https://django-cotton.com/docs/quickstart#install) installation steps.
- Add [AlpineJs](https://alpinejs.dev/) and its plugins(collapse, focus, mask).
- Add [TailwindCSS](https://tailwindcss.com/).

#### Add to installed apps

```python

    INSTALLED_APPS = [
        ...
        "django_cotton",
        "django_cotton_components",
        ...
    ]

```

## DISCLAIMER

The package is under active development. More changes will occur. The package is not yet stable. When using it and run into issues and/or have suggestions please create an ISSUE on [GITHUB](https://github.com/SakariaNdadi/django-cotton-components)

## Inheritance

In your 'templates' directory, create a cotton directory.

example: create `input.html`

```html
<c-dcc-input class="styling classes" errorTimer="1000" />
```

In your project reference your component, `<c-input id="thisInput" type="date" />`.

## Components

By default some components come with TailwindCSS styling.

### Headers

```html
<c-dcc-h title="" class="" url="" {{ attrs }}>`extra content`</c-dcc-h>
```

By default it is a `h1`, no styling is provided.

- id: Unique identifier for the input.
- class: Customise to your preference add your own.
- url: If provided, the heading becomes a link.

### Input

```html
<c-dcc-input
	id=""
	class=""
	type=""
	errorTimer=""
	borderErrorClass=""
	errorDivClass=""
	validationUrl=""
	{{attrs}}
/>
```

By default it is a text input if no type is provided..

- id: Unique identifier for the input.
- class: Customise to your preference add your own.
- type: By default this is text. Define your type (date, email, number, etc.).
- errorTimer: If variable is not passed the form errors will show indefinitely. Pass milliseconds to prop to display how long the error will be displayed for.
- validationUrl: Requires [HTMX](https://htmx.org/). This will validate your input such as username, checkout [example](https://youtu.be/yf7_txKvexk?si=WAuxBFEfnrqmCYWp).
- attrs: Do not reference attrs. Add extra attributes such as 'name', 'value', 'placeholder', 'required' etc.

### Textarea

```html
<c-dcc-textarea
	id=""
	class=""
	errorTimer=""
	errorDivClass=""
	validationUrl=""
	{{attrs}}
/>
```

- id: Unique identifier for the input.
- errorTimer: If variable is not passed the form errors will show indefinitely. Pass milliseconds to prop to display how long the error will be displayed for.
- validationUrl: Requires [HTMX](https://htmx.org/). This will validate your input such as username, checkout [example](https://youtu.be/yf7_txKvexk?si=WAuxBFEfnrqmCYWp).
- attrs: Do not reference attrs. Add extra attributes such as 'name', 'value', 'placeholder', 'rows' etc.

### Password Input

```html
<c-dcc-password-input id="" name="" show {{ attrs }} />
```

- id: Unique identifier for the password input.
- show: Enables password visibility toggle.
- attrs: Do not reference attrs. Add extra attributes such as 'name', 'value', 'placeholder', 'required' etc.

### Button

```html
<c-dcc-button id="" class="" title="" icon="" svg="" url="" />
```

- id: Unique identifier for the button.
- class: Add styling to your button.
- title: Button text.
- type: Button type(submit, reset etc.).
- url: If provided, the button renders as `<a href="...">` otherwise, it renders as `<button>`.

##### Icon or SVG not both

- icon: Icon name to be displayed on the button.
- svg: Path to an SVG icon.

##### Extra

You can add extra attributes on the button, example, `<c-button id="" title="Testing" hx-get="some_url" hx-trigger="click" hx-target="#some_id" />`

### Select options

##### Single Select

```html
<c-dcc-select
	id=""
	name=""
	:options="['Option1','Option2']"
	:data="cars"
	search
	value=""
/>
```

- id: Unique identifier for the select.
- options: Array of options to be displayed in the select.
- data: Data passed from your view ( `cars = Car.objects.all()` ).
- search: Enables search functionality.
- value: When provided, the component checks each item in the values array against the data (e.g, an array of objects) and marks the matching options as selected.

Note: If you use ':data' and no data is provided an 'IndexError' will be produced.

##### MultiSelect

```html
<c-dcc-select-multiple
	id=""
	label=""
	name=""
	:options="[]"
	:data=""
	:values=""
/>
```

- id: Unique identifier for the select.
- label: Label displayed above the select.
- options: Array of options to be displayed in the select.
- data: Data passed from your view ( `cars = Car.objects.all()` ).
- values: When provided, the component checks each item in the values array against the data (e.g, an array of objects) and marks the matching options as selected.

Note: Being worked on, display of selected options when using ':data' not on par with ':options'

### Checkbox

```html
<c-dcc-checkbox id="" label="" description="" value="" />
```

- id: Unique identifier for the checkbox.
- label: Label displayed above the checkbox.
- description: displayed below the checkbox.
- value: Value to be passed when clicked.

### Toggle

```html
<c-dcc-toggle id="" label="" value="" />
```

- id: Unique identifier for the toggle.
- label: Label displayed above the toggle.
- value: Value to be passed when toggled.

### Radio

```html
<c-dcc-radio id="" label="" description="" value="" />
```

- id: Unique identifier for the radio.
- label: Label displayed above the radio.
- description: displayed below the radio.
- value: Value to be passed when clicked.

### Modal

```html
<c-dcc-modal
	id=""
	buttonClass=""
	modalClass=""
	headerClass=""
	headerLabelClass=""
	bodyClass=""
	header=""
	label=""
>
	<!-- Your content -->
</c-dcc-modal>
```

- header: Header text for the modal.
- label: Label for the modal toggle.

### Table

```html
<c-dcc-table
	id=""
	:th="[]"
	thClass=""
	:tr=""
	trClass=""
	paginate_by=""
	search
/>
```

- id: Unique identifier for the table.
- th: Array of column names that specify which data fields will display.
- thClass: Custom class for `<thead>` styling.
- tr: Data from the view (must be a list of dictionaries).
  Example:<br>
  `cars = Car.objects.all()`<br>
  `context={"table_cars":list(cars.values())}`
- trClass: Custom class for <tr> row styling.
- paginate_by: Number of rows displayed per page.
- search: Enables search functionality across the specified columns in :th.

## Attributes

- You can add other attributes to the components such as `aria-label` etc.
- You can also add custom attributes to the components to suit your needs such as HTMX.
- Read more about [{{ attrs }}](https://django-cotton.com/docs/components#attrs)

### Mentions

- [Penguin](https://www.penguinui.com/) components.
- [BugBytes](https://www.youtube.com/@bugbytes3923) educational content.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-cotton-components",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "django, components, ui, cotton",
    "author": null,
    "author_email": "Sakaria Ndadi <oipapi.ndadi@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/18/c4/c2e2b4e9e3f8e9e7b32ff7c30df2a150c8e5ef40b0c60de595fec317c1fa/django_cotton_components-0.1.5.tar.gz",
    "platform": null,
    "description": "# Django Cotton Components\n\nA collection of pre-built, stylish, and functional form components to streamline your Django development process.\n\n## Key Features:\n\n- Pre-built Components: Quickly add common form elements like text inputs, textareas, select boxes, and more.\n- Alpine.js for Interactivity: Leverage Alpine.js to add dynamic behavior to your components without relying on full-fledged JavaScript frameworks.\n- Easy to Use: Simple installation and configuration, allowing you to focus on building your application.\n\n## Dependencies:\n\n- [Django-Cotton](https://django-cotton.com/)\n- [AlpineJs](https://alpinejs.dev/)\n- [TailwindCSS](https://tailwindcss.com/) (optional)\n\n## Installation:\n\n```python\n\n    pip install django-cotton-components\n\n```\n\n- Follow the [Django-Cotton](https://django-cotton.com/docs/quickstart#install) installation steps.\n- Add [AlpineJs](https://alpinejs.dev/) and its plugins(collapse, focus, mask).\n- Add [TailwindCSS](https://tailwindcss.com/).\n\n#### Add to installed apps\n\n```python\n\n    INSTALLED_APPS = [\n        ...\n        \"django_cotton\",\n        \"django_cotton_components\",\n        ...\n    ]\n\n```\n\n## DISCLAIMER\n\nThe package is under active development. More changes will occur. The package is not yet stable. When using it and run into issues and/or have suggestions please create an ISSUE on [GITHUB](https://github.com/SakariaNdadi/django-cotton-components)\n\n## Inheritance\n\nIn your 'templates' directory, create a cotton directory.\n\nexample: create `input.html`\n\n```html\n<c-dcc-input class=\"styling classes\" errorTimer=\"1000\" />\n```\n\nIn your project reference your component, `<c-input id=\"thisInput\" type=\"date\" />`.\n\n## Components\n\nBy default some components come with TailwindCSS styling.\n\n### Headers\n\n```html\n<c-dcc-h title=\"\" class=\"\" url=\"\" {{ attrs }}>`extra content`</c-dcc-h>\n```\n\nBy default it is a `h1`, no styling is provided.\n\n- id: Unique identifier for the input.\n- class: Customise to your preference add your own.\n- url: If provided, the heading becomes a link.\n\n### Input\n\n```html\n<c-dcc-input\n\tid=\"\"\n\tclass=\"\"\n\ttype=\"\"\n\terrorTimer=\"\"\n\tborderErrorClass=\"\"\n\terrorDivClass=\"\"\n\tvalidationUrl=\"\"\n\t{{attrs}}\n/>\n```\n\nBy default it is a text input if no type is provided..\n\n- id: Unique identifier for the input.\n- class: Customise to your preference add your own.\n- type: By default this is text. Define your type (date, email, number, etc.).\n- errorTimer: If variable is not passed the form errors will show indefinitely. Pass milliseconds to prop to display how long the error will be displayed for.\n- validationUrl: Requires [HTMX](https://htmx.org/). This will validate your input such as username, checkout [example](https://youtu.be/yf7_txKvexk?si=WAuxBFEfnrqmCYWp).\n- attrs: Do not reference attrs. Add extra attributes such as 'name', 'value', 'placeholder', 'required' etc.\n\n### Textarea\n\n```html\n<c-dcc-textarea\n\tid=\"\"\n\tclass=\"\"\n\terrorTimer=\"\"\n\terrorDivClass=\"\"\n\tvalidationUrl=\"\"\n\t{{attrs}}\n/>\n```\n\n- id: Unique identifier for the input.\n- errorTimer: If variable is not passed the form errors will show indefinitely. Pass milliseconds to prop to display how long the error will be displayed for.\n- validationUrl: Requires [HTMX](https://htmx.org/). This will validate your input such as username, checkout [example](https://youtu.be/yf7_txKvexk?si=WAuxBFEfnrqmCYWp).\n- attrs: Do not reference attrs. Add extra attributes such as 'name', 'value', 'placeholder', 'rows' etc.\n\n### Password Input\n\n```html\n<c-dcc-password-input id=\"\" name=\"\" show {{ attrs }} />\n```\n\n- id: Unique identifier for the password input.\n- show: Enables password visibility toggle.\n- attrs: Do not reference attrs. Add extra attributes such as 'name', 'value', 'placeholder', 'required' etc.\n\n### Button\n\n```html\n<c-dcc-button id=\"\" class=\"\" title=\"\" icon=\"\" svg=\"\" url=\"\" />\n```\n\n- id: Unique identifier for the button.\n- class: Add styling to your button.\n- title: Button text.\n- type: Button type(submit, reset etc.).\n- url: If provided, the button renders as `<a href=\"...\">` otherwise, it renders as `<button>`.\n\n##### Icon or SVG not both\n\n- icon: Icon name to be displayed on the button.\n- svg: Path to an SVG icon.\n\n##### Extra\n\nYou can add extra attributes on the button, example, `<c-button id=\"\" title=\"Testing\" hx-get=\"some_url\" hx-trigger=\"click\" hx-target=\"#some_id\" />`\n\n### Select options\n\n##### Single Select\n\n```html\n<c-dcc-select\n\tid=\"\"\n\tname=\"\"\n\t:options=\"['Option1','Option2']\"\n\t:data=\"cars\"\n\tsearch\n\tvalue=\"\"\n/>\n```\n\n- id: Unique identifier for the select.\n- options: Array of options to be displayed in the select.\n- data: Data passed from your view ( `cars = Car.objects.all()` ).\n- search: Enables search functionality.\n- value: When provided, the component checks each item in the values array against the data (e.g, an array of objects) and marks the matching options as selected.\n\nNote: If you use ':data' and no data is provided an 'IndexError' will be produced.\n\n##### MultiSelect\n\n```html\n<c-dcc-select-multiple\n\tid=\"\"\n\tlabel=\"\"\n\tname=\"\"\n\t:options=\"[]\"\n\t:data=\"\"\n\t:values=\"\"\n/>\n```\n\n- id: Unique identifier for the select.\n- label: Label displayed above the select.\n- options: Array of options to be displayed in the select.\n- data: Data passed from your view ( `cars = Car.objects.all()` ).\n- values: When provided, the component checks each item in the values array against the data (e.g, an array of objects) and marks the matching options as selected.\n\nNote: Being worked on, display of selected options when using ':data' not on par with ':options'\n\n### Checkbox\n\n```html\n<c-dcc-checkbox id=\"\" label=\"\" description=\"\" value=\"\" />\n```\n\n- id: Unique identifier for the checkbox.\n- label: Label displayed above the checkbox.\n- description: displayed below the checkbox.\n- value: Value to be passed when clicked.\n\n### Toggle\n\n```html\n<c-dcc-toggle id=\"\" label=\"\" value=\"\" />\n```\n\n- id: Unique identifier for the toggle.\n- label: Label displayed above the toggle.\n- value: Value to be passed when toggled.\n\n### Radio\n\n```html\n<c-dcc-radio id=\"\" label=\"\" description=\"\" value=\"\" />\n```\n\n- id: Unique identifier for the radio.\n- label: Label displayed above the radio.\n- description: displayed below the radio.\n- value: Value to be passed when clicked.\n\n### Modal\n\n```html\n<c-dcc-modal\n\tid=\"\"\n\tbuttonClass=\"\"\n\tmodalClass=\"\"\n\theaderClass=\"\"\n\theaderLabelClass=\"\"\n\tbodyClass=\"\"\n\theader=\"\"\n\tlabel=\"\"\n>\n\t<!-- Your content -->\n</c-dcc-modal>\n```\n\n- header: Header text for the modal.\n- label: Label for the modal toggle.\n\n### Table\n\n```html\n<c-dcc-table\n\tid=\"\"\n\t:th=\"[]\"\n\tthClass=\"\"\n\t:tr=\"\"\n\ttrClass=\"\"\n\tpaginate_by=\"\"\n\tsearch\n/>\n```\n\n- id: Unique identifier for the table.\n- th: Array of column names that specify which data fields will display.\n- thClass: Custom class for `<thead>` styling.\n- tr: Data from the view (must be a list of dictionaries).\n  Example:<br>\n  `cars = Car.objects.all()`<br>\n  `context={\"table_cars\":list(cars.values())}`\n- trClass: Custom class for <tr> row styling.\n- paginate_by: Number of rows displayed per page.\n- search: Enables search functionality across the specified columns in :th.\n\n## Attributes\n\n- You can add other attributes to the components such as `aria-label` etc.\n- You can also add custom attributes to the components to suit your needs such as HTMX.\n- Read more about [{{ attrs }}](https://django-cotton.com/docs/components#attrs)\n\n### Mentions\n\n- [Penguin](https://www.penguinui.com/) components.\n- [BugBytes](https://www.youtube.com/@bugbytes3923) educational content.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024  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. ",
    "summary": "A Django package with pre-built cotton-based UI components for rapid development.",
    "version": "0.1.5",
    "project_urls": null,
    "split_keywords": [
        "django",
        " components",
        " ui",
        " cotton"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c07289b527227c613aac86984fe0b3b835c9cd0c49620f341a6bfcf811bd414",
                "md5": "6b436e3497677418ddb5a20184a5322d",
                "sha256": "a93e9cefb281c6620b166f7ea30fa1a55bd80c430a8d0c8f5cdec8d992e66d87"
            },
            "downloads": -1,
            "filename": "django_cotton_components-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6b436e3497677418ddb5a20184a5322d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 21769,
            "upload_time": "2024-11-01T13:32:54",
            "upload_time_iso_8601": "2024-11-01T13:32:54.133292Z",
            "url": "https://files.pythonhosted.org/packages/5c/07/289b527227c613aac86984fe0b3b835c9cd0c49620f341a6bfcf811bd414/django_cotton_components-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "18c4c2e2b4e9e3f8e9e7b32ff7c30df2a150c8e5ef40b0c60de595fec317c1fa",
                "md5": "f36dc4ecbc3c8cd87e84eea9f61f8751",
                "sha256": "4201ef907a1edf5705cd4aa2aa36834e21177c2e859b48d621aaa681c12599fc"
            },
            "downloads": -1,
            "filename": "django_cotton_components-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "f36dc4ecbc3c8cd87e84eea9f61f8751",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 17642,
            "upload_time": "2024-11-01T13:32:56",
            "upload_time_iso_8601": "2024-11-01T13:32:56.658184Z",
            "url": "https://files.pythonhosted.org/packages/18/c4/c2e2b4e9e3f8e9e7b32ff7c30df2a150c8e5ef40b0c60de595fec317c1fa/django_cotton_components-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-01 13:32:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-cotton-components"
}
        
Elapsed time: 0.42104s