wagtail-tw-blocks 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.
@@ -0,0 +1,54 @@
1
+ """Wagtail Blocks"""
2
+
3
+ from django.utils.translation import gettext_lazy as _
4
+
5
+ # Constants
6
+ ACCORDION_STYLE_VARIANTS = [
7
+ ("plus", _("Plus")),
8
+ ("arrow", _("Arrow")),
9
+ ]
10
+
11
+ ALERT_STYLE_VARIANTS = [
12
+ ("soft", _("Soft")),
13
+ ("outlined", _("Outlined")),
14
+ ("dashed", _("Dashed")),
15
+ ]
16
+
17
+ ALERT_LEVELS = [
18
+ ("info", _("Info")),
19
+ ("success", _("Success")),
20
+ ("warning", _("Warning")),
21
+ ("error", _("Error")),
22
+ ]
23
+
24
+ # The popular programming languages
25
+ PROGRAMMING_LANGUAGES = [
26
+ ("auto", _("Auto")),
27
+ ("bash", "Bash"),
28
+ ("c", "C"),
29
+ ("cpp", "C++"),
30
+ ("csharp", "C#"),
31
+ ("css", "CSS"),
32
+ ("dart", "Dart"),
33
+ ("dockerfile", "Dockerfile"),
34
+ ("go", "Go"),
35
+ ("html", "HTML"),
36
+ ("java", "Java"),
37
+ ("javascript", "JavaScript"),
38
+ ("json", "JSON"),
39
+ ("kotlin", "Kotlin"),
40
+ ("lua", "Lua"),
41
+ ("markdown", "Markdown"),
42
+ ("php", "PHP"),
43
+ ("python", "Python"),
44
+ ("ruby", "Ruby"),
45
+ ("rust", "Rust"),
46
+ ("scss", "SCSS"),
47
+ ("shell", "Shell"),
48
+ ("sql", "SQL"),
49
+ ("swift", "Swift"),
50
+ ("typescript", "TypeScript"),
51
+ ("xml", "XML"),
52
+ ("yaml", "YAML"),
53
+ ("plaintext", _("Plain text")),
54
+ ]
wagtail_blocks/apps.py ADDED
@@ -0,0 +1,12 @@
1
+ """AppConf for wagtail_blocks"""
2
+
3
+ from django.apps import AppConfig
4
+
5
+
6
+ # Create your config here.
7
+ class WagtailBlocksConfig(AppConfig):
8
+ """App configuration for wagtail_blocks"""
9
+
10
+ name = "wagtail_blocks"
11
+ label = "wagtail_tw_blocks"
12
+ default_auto_field = "django.db.models.BigAutoField"
@@ -0,0 +1,224 @@
1
+ """Custom Wagtail CMS blocks"""
2
+
3
+ from django.conf import settings
4
+ from django.utils.translation import gettext_lazy as _
5
+ from wagtail import blocks
6
+ from wagtail.embeds.blocks import EmbedBlock
7
+ from wagtail.images.blocks import ImageBlock
8
+
9
+ from wagtail_blocks import (
10
+ ACCORDION_STYLE_VARIANTS,
11
+ ALERT_LEVELS,
12
+ ALERT_STYLE_VARIANTS,
13
+ PROGRAMMING_LANGUAGES,
14
+ )
15
+
16
+
17
+ # Settings
18
+ PROGRAMMING_LANGUAGES = getattr(
19
+ settings,
20
+ "WAGTAIL_BLOCKS_PROGRAMMING_LANGUAGES",
21
+ PROGRAMMING_LANGUAGES,
22
+ )
23
+
24
+ SHOW_PROGRAMMING_LANGUAGE = getattr(
25
+ settings,
26
+ "WAGTAIL_BLOCKS_SHOW_PROGRAMMING_LANGUAGE",
27
+ True,
28
+ )
29
+
30
+ SHOW_COPY_BUTTON = getattr(
31
+ settings,
32
+ "WAGTAIL_BLOCKS_SHOW_COPY_BUTTON",
33
+ True,
34
+ )
35
+
36
+
37
+ class ButtonBlock(blocks.StructBlock):
38
+ """Action block (link)"""
39
+
40
+ label = blocks.CharBlock(
41
+ max_length=32,
42
+ required=False,
43
+ help_text=_("Action label"),
44
+ )
45
+ page = blocks.PageChooserBlock(
46
+ required=False,
47
+ help_text=_("Action internal link"),
48
+ )
49
+ url = blocks.URLBlock(
50
+ required=False,
51
+ help_text=_("Action external link"),
52
+ )
53
+
54
+
55
+ class AccordionItemBlock(blocks.StructBlock):
56
+ """Accordion Item"""
57
+
58
+ is_expanded = blocks.BooleanBlock(
59
+ default=False,
60
+ required=False,
61
+ help_text=_("Wether to show or hide item content"),
62
+ )
63
+ title = blocks.CharBlock(
64
+ max_length=64,
65
+ required=True,
66
+ help_text=_("Item title"),
67
+ )
68
+ content = blocks.RichTextBlock(
69
+ required=True,
70
+ help_text=_("Item content"),
71
+ )
72
+
73
+
74
+ class AccordionBlock(blocks.StructBlock):
75
+ """Accordions block"""
76
+
77
+ name = blocks.CharBlock(
78
+ max_length=64,
79
+ required=True,
80
+ help_text=_("Accordion name"),
81
+ )
82
+ variant = blocks.ChoiceBlock(
83
+ choices=ACCORDION_STYLE_VARIANTS,
84
+ required=False,
85
+ help_text=_("Style variant"),
86
+ )
87
+ items = blocks.ListBlock(
88
+ AccordionItemBlock(),
89
+ required=True,
90
+ help_text=_("Accordion items"),
91
+ )
92
+
93
+ class Meta:
94
+ """Meta data"""
95
+
96
+ icon = "folder-open-inverse"
97
+ template = "wagtail_blocks/blocks/accordion.html"
98
+
99
+
100
+ class AlertBlock(blocks.StructBlock):
101
+ """Alert block"""
102
+
103
+ variant = blocks.ChoiceBlock(
104
+ choices=ALERT_STYLE_VARIANTS,
105
+ required=False,
106
+ help_text=_("Style variant"),
107
+ )
108
+ level = blocks.ChoiceBlock(
109
+ choices=ALERT_LEVELS,
110
+ required=False,
111
+ help_text=_("Alert level"),
112
+ )
113
+ message = blocks.RichTextBlock(
114
+ required=True,
115
+ help_text=_("Alert message"),
116
+ features=[
117
+ "bold",
118
+ "italic",
119
+ "link",
120
+ "document-link",
121
+ "code",
122
+ "superscript",
123
+ "subscript",
124
+ "strikethrough",
125
+ ],
126
+ )
127
+ actions = blocks.ListBlock(
128
+ ButtonBlock(
129
+ required=False,
130
+ help_text=_("Alert action"),
131
+ ),
132
+ required=False,
133
+ help_text=_("Alert actions"),
134
+ )
135
+
136
+ class Meta:
137
+ """Meta data"""
138
+
139
+ icon = "warning"
140
+ template = "wagtail_blocks/blocks/alert.html"
141
+
142
+
143
+ class CarouselItemBlock(blocks.StructBlock):
144
+ """Carousel Item block"""
145
+
146
+ image = ImageBlock(
147
+ required=False,
148
+ help_text=_("Image"),
149
+ )
150
+ video = EmbedBlock(
151
+ required=False,
152
+ help_text=_("Video"),
153
+ )
154
+
155
+
156
+ class CarouselBlock(blocks.StructBlock):
157
+ """Carousel block"""
158
+
159
+ is_vertical = blocks.BooleanBlock(
160
+ default=False,
161
+ required=False,
162
+ help_text=_("Designates if carousel is vertical or horizontal (default)"),
163
+ )
164
+ items = blocks.ListBlock(
165
+ CarouselItemBlock(),
166
+ required=True,
167
+ help_text=_("Carousel items"),
168
+ )
169
+
170
+ class Meta:
171
+ """Meta data"""
172
+
173
+ icon = "image"
174
+ template = "wagtail_blocks/blocks/carousel.html"
175
+
176
+
177
+ class CodeBlock(blocks.StructBlock):
178
+ """Code block"""
179
+
180
+ show_language = blocks.BooleanBlock(
181
+ default=SHOW_PROGRAMMING_LANGUAGE,
182
+ required=False,
183
+ help_text=_("Wether to show or hide which programming language is used"),
184
+ )
185
+ show_copy_btn = blocks.BooleanBlock(
186
+ default=SHOW_COPY_BUTTON,
187
+ required=False,
188
+ help_text=_("Wether to show or hide copy buttons"),
189
+ )
190
+ language = blocks.ChoiceBlock(
191
+ choices=PROGRAMMING_LANGUAGES,
192
+ default="auto",
193
+ required=True,
194
+ help_text=_("Programming language"),
195
+ )
196
+ code = blocks.TextBlock(
197
+ required=True,
198
+ help_text=_("Code content"),
199
+ )
200
+
201
+ class Meta:
202
+ """Meta data"""
203
+
204
+ icon = "code"
205
+ template = "wagtail_blocks/blocks/code.html"
206
+
207
+
208
+ class DiffBlock(blocks.StructBlock):
209
+ """Diff block"""
210
+
211
+ item_1 = ImageBlock(
212
+ required=True,
213
+ help_text=_("Diff Item 1"),
214
+ )
215
+ item_2 = ImageBlock(
216
+ required=True,
217
+ help_text=_("Diff Item 2"),
218
+ )
219
+
220
+ class Meta:
221
+ """Meta data"""
222
+
223
+ icon = "code"
224
+ template = "wagtail_blocks/blocks/diff.html"
@@ -0,0 +1,4 @@
1
+ {
2
+ "tailwindStylesheet": "./css/app.css",
3
+ "plugins": ["prettier-plugin-tailwindcss"]
4
+ }
@@ -0,0 +1,23 @@
1
+ # UI Styles
2
+
3
+ Basic commands to get started.
4
+
5
+ First `cd` into dir:
6
+
7
+ ```console
8
+ cd .\wagtail_blocks\static\wagtail_blocks\
9
+ ```
10
+
11
+ To generate the styles:
12
+
13
+ ```console
14
+ npm install
15
+ cd .\wagtail_blocks\static\wagtail_blocks\
16
+ npx @tailwindcss/cli -i ../static/wagtail_blocks/css/app.css -o ../static/wagtail_blocks/css/styles.css --cwd ../../templates -m -w
17
+ ```
18
+
19
+ To format the templates:
20
+
21
+ ```console
22
+ npx prettier -w ../../templates
23
+ ```
@@ -0,0 +1,6 @@
1
+ @import "tailwindcss";
2
+ @plugin "@tailwindcss/typography";
3
+
4
+ @plugin "daisyui" {
5
+ themes: all;
6
+ }