Skip to content
Snippets Groups Projects
Commit 90195f21 authored by Julian's avatar Julian
Browse files

Rename every occurrence of "splitted" to "split"

parent a294eda8
No related branches found
No related tags found
No related merge requests found
Showing
with 30 additions and 25 deletions
# django_splitted_input
# django_split_input
## About
This is a django widget for multiple fixed size inputs for one form field. These could be used for those super fancy
verification code forms. The cursor is moved to the next input field using JS/jQuery.
![django_splitted_input Showcase](django_splitted_input_showcase.png)
![django_split_input Showcase](django_split_input_showcase.png)
## Usage
1. Install `django_splitted_input` and add it to your `INSTALLED_APPS`.
1. Install `django_split_input` and add it to your `INSTALLED_APPS`.
```shell
pip install django-splitted-input
pip install django-split-input
```
In your settings.py:
```python
"django_splitted_input",
"django_split_input",
```
2. Install `jQuery` using your preferred method (e.g.
[django-yarnpkg](https://pypi.org/project/django-yarnpkg/))
3. Create a form with a `CharField`.
4. Use `SplittedInput` as a widget and supply the sizes of all input fields.
4. Use `SplitInput` as a widget and supply the sizes of all input fields.
```python
from django import forms
from django_splitted_input import SplittedInput
from django_split_input import SplitInput
class VerificationForm(forms.Form):
auth_code = forms.CharField(label='Code', widget=SplittedInput(sizes=(3, 3, 3)))
auth_code = forms.CharField(label='Code', widget=SplitInput(sizes=(3, 3, 3)))
```
from .widgets import SplitInput
from django.apps import AppConfig
class DjangoSplittedInputConfig(AppConfig):
name = 'django_splitted_input'
class DjangoSplitInputConfig(AppConfig):
name = 'django_split_input'
......@@ -2,7 +2,7 @@
display: flex;
justify-content: center; }
.splitted_input {
.split_input {
font-family: "Roboto Mono", monospace;
margin: 0 5px; }
......
{
"version": 3,
"mappings": "AAAA,YAAa;EACX,OAAO,EAAE,IAAI;EACb,eAAe,EAAE,MAAM;;AAGzB,eAAgB;EACd,WAAW,EAAE,wBAAwB;EACrC,MAAM,EAAE,KAAK",
"mappings": "AAAA,YAAa;EACX,OAAO,EAAE,IAAI;EACb,eAAe,EAAE,MAAM;;AAGzB,YAAa;EACX,WAAW,EAAE,wBAAwB;EACrC,MAAM,EAAE,KAAK",
"sources": ["input.scss"],
"names": [],
"file": "input.css"
......
......@@ -3,7 +3,7 @@
justify-content: center;
}
.splitted_input {
.split_input {
font-family: "Roboto Mono", monospace;
margin: 0 5px;
}
\ No newline at end of file
......@@ -3,8 +3,8 @@ from typing import Optional, Tuple, Type
from django.forms.widgets import Widget, MultiWidget, TextInput
class SplittedInput(MultiWidget):
template_name = 'django_splitted_input/widget.html'
class SplitInput(MultiWidget):
template_name = 'django_split_input/widget.html'
def __init__(self, sizes: Tuple[int, ...], attrs: Optional[dict] = None,
input_widget: Optional[Type[Widget]] = None):
......@@ -19,7 +19,7 @@ class SplittedInput(MultiWidget):
self.input_widget = input_widget if input_widget else TextInput
self.sizes = sizes
self.indexed_sizes = [sum(self.sizes[:i]) for i in range(len(self.sizes) + 1)]
self.attrs = dict(attrs, **{"class": "splitted_input"})
self.attrs = dict(attrs, **{"class": "split_input"})
self.widgets = [
self.input_widget(attrs=dict(
self.attrs,
......@@ -48,6 +48,6 @@ class SplittedInput(MultiWidget):
class Media:
css = {
"all": ("django_splitted_input/css/input.css",)
"all": ("django_split_input/css/input.css",)
}
js = ("django_splitted_input/js/input.js",)
js = ("django_split_input/js/input.js",)
File moved
from .widgets import SplittedInput
# _django_splitted_input_ example project
# _django_split_input_ example project
Please install `django` and `django-yarnpkg` in your python environment.
The `manage.py` file for the project is in `example/`.
\ No newline at end of file
from django import forms
from django_splitted_input import SplittedInput
from django_split_input import SplitInput
class SplittedInputForm(forms.Form):
splitted_input_1 = forms.CharField(label='3 3-wide text inputs', widget=SplittedInput(sizes=(3, 3, 3)))
splitted_input_1 = forms.CharField(label='3 3-wide text inputs', widget=SplitInput(sizes=(3, 3, 3)))
splitted_input_2 = forms.CharField(label='4 different sized password inputs',
widget=SplittedInput(sizes=(1, 2, 3, 4), input_widget=forms.PasswordInput))
widget=SplitInput(sizes=(1, 2, 3, 4), input_widget=forms.PasswordInput))
......@@ -31,7 +31,7 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.staticfiles',
'django_splitted_input',
'django_split_input',
'django_yarnpkg',
'example'
]
......
[tool.poetry]
name = "django-splitted-input"
name = "django-split-input"
version = "0.1.1"
description = "A widget to have a django text input splitted into multiple HTML inputs."
description = "A widget to have a django text input split into multiple HTML inputs."
authors = ["Julian Leucker <leuckerj@gmail.com>"]
readme = "README.md"
repository = "https://edugit.org/AlekSIS/libs/django-splitted-input"
repository = "https://edugit.org/AlekSIS/libs/django-split-input"
keywords = ["django", "widget"]
classifiers = [
"Environment :: Web Environment",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment