django-sample-components 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_sample_components/__init__.py +2 -0
- django_sample_components/admin.py +0 -0
- django_sample_components/apps.py +8 -0
- django_sample_components/models.py +0 -0
- django_sample_components/static/css/style.css +14 -0
- django_sample_components/static/js/main.js +1 -0
- django_sample_components/templates/django_sample_components/components/simple_alert.html +13 -0
- django_sample_components/templates/django_sample_components/pages/alert.html +36 -0
- django_sample_components/templates/django_sample_components/pages/greeting.html +9 -0
- django_sample_components/templates/django_sample_components/pages/home.html +11 -0
- django_sample_components/templates/django_sample_components/pages/master.html +39 -0
- django_sample_components/templates/django_sample_components/partials/menu.html +7 -0
- django_sample_components/templatetags/__init__.py +5 -0
- django_sample_components/templatetags/sample_tags/__init__.py +16 -0
- django_sample_components/templatetags/sample_tags/greeting.py +2 -0
- django_sample_components/templatetags/sample_tags/shout.py +5 -0
- django_sample_components/templatetags/sample_tags/show_today_timestamp.py +5 -0
- django_sample_components/templatetags/sample_tags/simple_alert.py +41 -0
- django_sample_components/urls.py +11 -0
- django_sample_components/views.py +22 -0
- django_sample_components-0.1.0.dist-info/METADATA +97 -0
- django_sample_components-0.1.0.dist-info/RECORD +24 -0
- django_sample_components-0.1.0.dist-info/WHEEL +4 -0
- django_sample_components-0.1.0.dist-info/licenses/LICENSE +21 -0
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.alert.simple-alert{
|
|
2
|
+
background-color: #ff000000;
|
|
3
|
+
border-style: solid;
|
|
4
|
+
border-width: 2px;
|
|
5
|
+
margin: 5px;
|
|
6
|
+
padding: 11px 15px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.simple-alert-icon{
|
|
10
|
+
padding: 0.6rem;
|
|
11
|
+
border-radius: 0.375rem;
|
|
12
|
+
background-color: var(--bs-alert-bg);
|
|
13
|
+
color: var(--bs-alert-color);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log('main.js loaded');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<div
|
|
2
|
+
class="simple-alert alert {{ alert_class }} alert-outline-{{ text_class }} d-flex justify-content-between align-items-center animate-slide-down"
|
|
3
|
+
role="alert">
|
|
4
|
+
<div class="d-flex align-items-center">
|
|
5
|
+
<span class="alert-icon bg-{{ text_class }} rounded bg-opacity-10 me-3 d-flex align-items-center justify-content-center">
|
|
6
|
+
<i class="simple-alert-icon {{ icon_class }} text-{{ text_class }}"></i>
|
|
7
|
+
</span>
|
|
8
|
+
<p class="mb-0">
|
|
9
|
+
{{ slot_content }}
|
|
10
|
+
</p>
|
|
11
|
+
</div>
|
|
12
|
+
{% comment %} <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> {% endcomment %}
|
|
13
|
+
</div>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{% extends 'django_sample_components/pages/master.html' %}
|
|
2
|
+
|
|
3
|
+
{% load sample_tags %}
|
|
4
|
+
|
|
5
|
+
{% block content %}
|
|
6
|
+
<h1>Alert Page</h1>
|
|
7
|
+
|
|
8
|
+
{% simple_alert %}
|
|
9
|
+
This is the content for <i>simple_alert</i>.
|
|
10
|
+
{% endsimple_alert %}
|
|
11
|
+
|
|
12
|
+
{% simple_alert type="info" %}
|
|
13
|
+
info alert example.
|
|
14
|
+
{% endsimple_alert %}
|
|
15
|
+
|
|
16
|
+
{% simple_alert type="success" %}
|
|
17
|
+
success alert example.
|
|
18
|
+
{% endsimple_alert %}
|
|
19
|
+
|
|
20
|
+
{% simple_alert type="warning" %}
|
|
21
|
+
warning alert example.
|
|
22
|
+
{% endsimple_alert %}
|
|
23
|
+
|
|
24
|
+
{% simple_alert type="danger" %}
|
|
25
|
+
danger alert example.
|
|
26
|
+
{% endsimple_alert %}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
{% simple_alert %}
|
|
30
|
+
Este รฉ o alerta pai.
|
|
31
|
+
{% simple_alert %}
|
|
32
|
+
Este รฉ o alerta filho dentro do alerta pai.
|
|
33
|
+
{% endsimple_alert %}
|
|
34
|
+
{% endsimple_alert %}
|
|
35
|
+
|
|
36
|
+
{% endblock %}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{% extends 'django_sample_components/pages/master.html' %}
|
|
2
|
+
|
|
3
|
+
{% load sample_tags %}
|
|
4
|
+
|
|
5
|
+
{% block content %}
|
|
6
|
+
<h1>Welcome to Django Sample Components - Version {{ versao }}</h1>
|
|
7
|
+
|
|
8
|
+
<p>To learn more about the library, <a href="{{ url_pypi }}">visit the PyPI page</a></p>
|
|
9
|
+
<p>Check out the source code on <a href="{{ url_github }}">GitHub</a></p>
|
|
10
|
+
<p>This template was loaded directly from the library package!</p>
|
|
11
|
+
{% endblock %}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{% load static i18n %}
|
|
2
|
+
<!DOCTYPE html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>{% block title %}Django Sample Componentes{% endblock %}</title>
|
|
8
|
+
<link rel="stylesheet" href="{% static 'css/style.css' %}">
|
|
9
|
+
<script src="{% static 'js/main.js' %}"></script>
|
|
10
|
+
|
|
11
|
+
{% block third_party_head_libs %}
|
|
12
|
+
{% comment %} Bootstrap {% endcomment %}
|
|
13
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
|
14
|
+
{% comment %} Font Awesome {% endcomment %}
|
|
15
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="..." crossorigin="anonymous" referrerpolicy="no-referrer" />
|
|
16
|
+
|
|
17
|
+
{% endblock %}
|
|
18
|
+
|
|
19
|
+
{% block extra_head %}{% endblock %}
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
<header>
|
|
23
|
+
{% include "django_sample_components/partials/menu.html" %}
|
|
24
|
+
</header>
|
|
25
|
+
<main>
|
|
26
|
+
{% block content %}{% endblock %}
|
|
27
|
+
</main>
|
|
28
|
+
<footer>
|
|
29
|
+
<p>© {{ year|default:2025 }} My Django Sample Components</p>
|
|
30
|
+
</footer>
|
|
31
|
+
|
|
32
|
+
{% block extra_scripts %}{% endblock %}
|
|
33
|
+
|
|
34
|
+
{% block third_party_head_js %}
|
|
35
|
+
{% comment %} Bootstrap JS{% endcomment %}
|
|
36
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="..." crossorigin="anonymous" referrerpolicy="no-referrer" />
|
|
37
|
+
{% endblock %}
|
|
38
|
+
</body>
|
|
39
|
+
</html>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from django import template
|
|
2
|
+
|
|
3
|
+
from .greeting import greeting
|
|
4
|
+
from .shout import shout
|
|
5
|
+
from .show_today_timestamp import show_today_timestamp
|
|
6
|
+
from .simple_alert import simple_alert
|
|
7
|
+
|
|
8
|
+
register = template.Library()
|
|
9
|
+
|
|
10
|
+
# 1. simple_tags
|
|
11
|
+
register.simple_tag(show_today_timestamp)
|
|
12
|
+
register.simple_tag(greeting)
|
|
13
|
+
|
|
14
|
+
# 2. simple_block_tags
|
|
15
|
+
register.simple_block_tag(shout)
|
|
16
|
+
register.simple_block_tag(simple_alert)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from django.template.loader import render_to_string
|
|
2
|
+
from django.utils.safestring import SafeString
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def simple_alert(
|
|
6
|
+
content: SafeString,
|
|
7
|
+
type: str = 'info',
|
|
8
|
+
):
|
|
9
|
+
"""
|
|
10
|
+
Renders a simple alert box with the given content and optional prefix text.
|
|
11
|
+
Adds a Font Awesome icon based on the alert type.
|
|
12
|
+
"""
|
|
13
|
+
match type:
|
|
14
|
+
case 'info':
|
|
15
|
+
alert_class = 'alert-info'
|
|
16
|
+
text_class = 'text-info'
|
|
17
|
+
icon_class = 'fa fa-info-circle'
|
|
18
|
+
case 'warning':
|
|
19
|
+
alert_class = 'alert-warning'
|
|
20
|
+
text_class = 'text-warning'
|
|
21
|
+
icon_class = 'fa fa-exclamation-triangle'
|
|
22
|
+
case 'danger':
|
|
23
|
+
alert_class = 'alert-danger'
|
|
24
|
+
text_class = 'text-danger'
|
|
25
|
+
icon_class = 'fa fa-times-circle'
|
|
26
|
+
case 'success':
|
|
27
|
+
alert_class = 'alert-success'
|
|
28
|
+
text_class = 'text-success'
|
|
29
|
+
icon_class = 'fa fa-check-circle'
|
|
30
|
+
case _:
|
|
31
|
+
alert_class = 'alert-info'
|
|
32
|
+
text_class = 'text-info'
|
|
33
|
+
icon_class = 'fa fa-info-circle'
|
|
34
|
+
|
|
35
|
+
context = {
|
|
36
|
+
'slot_content': content,
|
|
37
|
+
'alert_class': alert_class,
|
|
38
|
+
'text_class': text_class,
|
|
39
|
+
'icon_class': icon_class,
|
|
40
|
+
}
|
|
41
|
+
return render_to_string('django_sample_components/components/simple_alert.html', context)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from django.urls import path
|
|
2
|
+
|
|
3
|
+
from .views import Alert, Greeting, Home
|
|
4
|
+
|
|
5
|
+
app_name = 'django_sample_components'
|
|
6
|
+
|
|
7
|
+
urlpatterns = [
|
|
8
|
+
path('', Home.as_view(), name='home'),
|
|
9
|
+
path('greeting/', Greeting.as_view(), name='greeting'),
|
|
10
|
+
path('alert/', Alert.as_view(), name='alert'),
|
|
11
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from django.conf import settings
|
|
2
|
+
from django.shortcuts import render
|
|
3
|
+
from django.views import View
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Home(View):
|
|
7
|
+
def get(self, request):
|
|
8
|
+
context = {
|
|
9
|
+
'url_pypi': settings.URL_PYPI,
|
|
10
|
+
'url_github': settings.URL_GITHUB,
|
|
11
|
+
}
|
|
12
|
+
return render(request, 'django_sample_components/pages/home.html', context)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Greeting(View):
|
|
16
|
+
def get(self, request):
|
|
17
|
+
return render(request, 'django_sample_components/pages/greeting.html')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Alert(View):
|
|
21
|
+
def get(self, request):
|
|
22
|
+
return render(request, 'django_sample_components/pages/alert.html')
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-sample-components
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A handy collection of reusable Django UI components, allowing me to share and integrate elements efficiently across various projects.
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: Gustavo Rizzo S M de Albuquerque
|
|
8
|
+
Author-email: grizzo.albu@gmail.com
|
|
9
|
+
Requires-Python: >=3.14,<4.0
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Requires-Dist: django (>=5.2.7,<6.0.0)
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# django-sample-components ๐
|
|
18
|
+
|
|
19
|
+
[](https://pypi.org/project/django-sample-components/)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
> This project is a test for creating a Django library. ๐งฉ
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Installation ๐ฆ
|
|
26
|
+
|
|
27
|
+
You can install the library using pip or poetry:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install django-sample-components
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
or
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
poetry add django-sample-components
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Configuration โ๏ธ
|
|
41
|
+
|
|
42
|
+
Add `django_sample_components` to the `INSTALLED_APPS` list in your `settings.py`:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
INSTALLED_APPS = [
|
|
46
|
+
# ... other apps ...
|
|
47
|
+
'django_sample_components',
|
|
48
|
+
]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Migrations ๐๏ธ
|
|
53
|
+
|
|
54
|
+
After installing and configuring, run the following commands:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
python manage.py makemigrations
|
|
58
|
+
python manage.py migrate
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
๐ Done! Your Django library is installed and ready to use.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## Running locally as a developer ๐ฅ๏ธ
|
|
66
|
+
|
|
67
|
+
To run the Django project locally during development, follow the steps below:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git clone https://github.com/GustavoRizzo/django-sample-components.git
|
|
71
|
+
cd django-sample-components
|
|
72
|
+
poetry install
|
|
73
|
+
cd demo_project
|
|
74
|
+
pip install -e ..
|
|
75
|
+
poetry run ./manage.py runserver
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Tests ๐งช
|
|
79
|
+
To run the tests, use the command below inside the `demo_project` directory:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
poetry run ./manage.py test
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
## Updating and publishing the library ๐ข
|
|
88
|
+
|
|
89
|
+
To update the version, build, and publish your library, use the commands below:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
poetry version patch # to bump the version (e.g.: 0.1.0 โ 0.1.1)
|
|
93
|
+
poetry build
|
|
94
|
+
tar -tzf dist/*.tar.gz | head -20 # to see the files inside the package
|
|
95
|
+
poetry publish
|
|
96
|
+
```
|
|
97
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
django_sample_components/__init__.py,sha256=C_GfzpVLzI8cd065ccOmUeU-gJ7IMzsYhiUaz0tSfUs,153
|
|
2
|
+
django_sample_components/admin.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
django_sample_components/apps.py,sha256=Y4l3Dx3smnEC5yuvWFtvJIcZuipXWNt_mcNkmuaRwUk,220
|
|
4
|
+
django_sample_components/models.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
django_sample_components/static/css/style.css,sha256=5xWTwmVWM4I-8rlHOsngK0WKFHX7YJgE6f5B3YH0UUQ,295
|
|
6
|
+
django_sample_components/static/js/main.js,sha256=DycjxouQQCdfuOkbAyfoLHIvFfxtfNw2qMWG8Osh1bk,30
|
|
7
|
+
django_sample_components/templates/django_sample_components/components/simple_alert.html,sha256=VobcDLKnf2olrres_hMsYYSG1mfW2LxVVoLKs43frok,662
|
|
8
|
+
django_sample_components/templates/django_sample_components/pages/alert.html,sha256=skaLrceKA_LF2NFQJZifIV1NazpiVetoXWP-g5jUEtg,818
|
|
9
|
+
django_sample_components/templates/django_sample_components/pages/greeting.html,sha256=YMbalY1pl_-6rDnLZV56VOc5aa3NOaqqODW8T-jHAXY,191
|
|
10
|
+
django_sample_components/templates/django_sample_components/pages/home.html,sha256=14uFrCnpyfR8ymHUxoRm3kaeGOZdREwBS3CKNRCwTn0,434
|
|
11
|
+
django_sample_components/templates/django_sample_components/pages/master.html,sha256=xr7VW2ALU66NubFf504xkjtZOYBB3GhEB0M6MvAJaM8,1592
|
|
12
|
+
django_sample_components/templates/django_sample_components/partials/menu.html,sha256=zDSC6NwfDjeT1tBkhKmT3w5SQqF5XN6NxXawnKymLAs,244
|
|
13
|
+
django_sample_components/templatetags/__init__.py,sha256=ieX81f0m9BgO6QANOF66q5xM7SB_Lzk93mdZg72UNMk,222
|
|
14
|
+
django_sample_components/templatetags/sample_tags/__init__.py,sha256=Wedfy5LN6i5OveiSGvLj2hlRXvLu0CPJzVLIdi9DLMc,397
|
|
15
|
+
django_sample_components/templatetags/sample_tags/greeting.py,sha256=cBJ_fdNtI7vZ7RLSJtJv3CWMl2Awzxz1KCrcE9Nay8c,49
|
|
16
|
+
django_sample_components/templatetags/sample_tags/shout.py,sha256=1Cm_yN-lXsW_2Jgka4ZT6f88gXOBgupoc2VeLgA4bLM,217
|
|
17
|
+
django_sample_components/templatetags/sample_tags/show_today_timestamp.py,sha256=j33yjxtTe1fvyo9nCwl_IE9eiaqtXtjUOOtPJMWiZCE,75
|
|
18
|
+
django_sample_components/templatetags/sample_tags/simple_alert.py,sha256=cVYgQqrmXIQIUW5bVxw7_3DaZTMHUSV2jV5UIUzi2c0,1331
|
|
19
|
+
django_sample_components/urls.py,sha256=ASNS1_FChiQIwAkrlZBczSRqE98s3wrej-zzaJVuLgE,283
|
|
20
|
+
django_sample_components/views.py,sha256=OAlRx8OuU8nkRkvZhqATN7sxc21bAkWASPI3NQq7vjE,607
|
|
21
|
+
django_sample_components-0.1.0.dist-info/METADATA,sha256=d-j6uzz0C12dTMNxhURO8h9XCjAvsPxXYrCLy5Cjj98,2163
|
|
22
|
+
django_sample_components-0.1.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
23
|
+
django_sample_components-0.1.0.dist-info/licenses/LICENSE,sha256=omeibtobS2xYBqFCu-WthJTVP4jrOP2Viv7ofbh-Rig,1082
|
|
24
|
+
django_sample_components-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Gustavo Rizzo Albuquerque
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|