|
12 | 12 | {% endblock %} |
13 | 13 |
|
14 | 14 | {% block content %} |
15 | | - <div class="py-0 px-3 mb-3 md:py-6 md:px-0"> |
16 | | - <div class="mx-auto w-full" style="display: flex; justify-content: center;"> |
17 | | - <noscript> |
18 | | - <style> |
19 | | - .create-post-page__content-field, |
20 | | - .create-post-page__link-fields { display: none !important; } |
21 | | - .create-post-page__card:has(select[name="post_type"] option[value="blog"]:checked) .create-post-page__content-field, |
22 | | - .create-post-page__card:has(select[name="post_type"] option[value="news"]:checked) .create-post-page__content-field { display: flex !important; } |
23 | | - .create-post-page__card:has(select[name="post_type"] option[value="video"]:checked) .create-post-page__link-fields, |
24 | | - .create-post-page__card:has(select[name="post_type"] option[value="link"]:checked) .create-post-page__link-fields { display: flex !important; flex-direction: column; gap: var(--space-xlarge, 24px); } |
25 | | - </style> |
26 | | - </noscript> |
27 | | - <div class="create-post-wrapper" x-data="createPostForm()" @field-change="handleFieldChange($event)"> |
28 | | - <form |
29 | | - class="create-post-page" |
30 | | - enctype="multipart/form-data" |
31 | | - method="post" |
32 | | - :novalidate="true" |
33 | | - action="{{ blogpost_create_url }}" |
34 | | - :action="formAction" |
35 | | - @submit="prepareSubmit" |
36 | | - data-create-post-form |
37 | | - > |
38 | | - {% csrf_token %} |
39 | | - |
40 | | - <div class="create-post-page__header"> |
41 | | - <h1 class="create-post-page__title">Create Post</h1> |
42 | | - <p class="create-post-page__subtitle"> |
43 | | - Posts will be reviewed by the moderation team before they appear in the feed. |
44 | | - </p> |
45 | | - </div> |
46 | | - |
47 | | - <div class="create-post-page__card"> |
48 | | - {% comment %} Post Type dropdown: Blog, News, Video, Link. Placeholder "Select Post Type". Controls conditional fields. {% endcomment %} |
49 | | - {% include "v3/includes/_field_dropdown.html" with name="post_type" label="Post type *" options=post_type_options placeholder="Select Post Type" required=True %} |
50 | | - <p class="field__error" id="post-type-error" role="alert" x-show="errors.post_type" x-text="errors.post_type" x-cloak></p> |
51 | | - |
52 | | - <div class="field" :class="{ 'field--error': errors.title }"> |
53 | | - <label class="field__label" for="field-title">Post title *</label> |
54 | | - <div class="field__control"> |
55 | | - <input class="field__input" type="text" id="field-title" name="title" placeholder="Title" required |
56 | | - :aria-invalid="!!errors.title" |
57 | | - :aria-describedby="errors.title ? 'field-title-error' : null"> |
58 | | - |
59 | | - </div> |
60 | | - <p class="field__error" id="field-title-error" role="alert" x-show="errors.title" x-text="errors.title" x-cloak aria-live="polite"></p> |
| 15 | + <div class="create-post-section"> |
| 16 | + <noscript> |
| 17 | + <style> |
| 18 | + .create-post-page__content-field, |
| 19 | + .create-post-page__link-fields { display: none !important; } |
| 20 | + .create-post-page__card:has(select[name="post_type"] option[value="blog"]:checked) .create-post-page__content-field, |
| 21 | + .create-post-page__card:has(select[name="post_type"] option[value="news"]:checked) .create-post-page__content-field { display: flex !important; } |
| 22 | + .create-post-page__card:has(select[name="post_type"] option[value="video"]:checked) .create-post-page__link-fields, |
| 23 | + .create-post-page__card:has(select[name="post_type"] option[value="link"]:checked) .create-post-page__link-fields { display: flex !important; flex-direction: column; gap: var(--space-xlarge, 24px); } |
| 24 | + </style> |
| 25 | + </noscript> |
| 26 | + <div class="create-post-wrapper" x-data="createPostForm()" @field-change="handleFieldChange($event)"> |
| 27 | + <form |
| 28 | + class="create-post-page" |
| 29 | + enctype="multipart/form-data" |
| 30 | + method="post" |
| 31 | + :novalidate="true" |
| 32 | + action="{{ blogpost_create_url }}" |
| 33 | + :action="formAction" |
| 34 | + @submit="prepareSubmit" |
| 35 | + data-create-post-form |
| 36 | + > |
| 37 | + {% csrf_token %} |
| 38 | + |
| 39 | + <div class="create-post-page__header"> |
| 40 | + <h1 class="create-post-page__title">Create Post</h1> |
| 41 | + <p class="create-post-page__subtitle"> |
| 42 | + Posts will be reviewed by the moderation team before they appear in the feed. |
| 43 | + </p> |
61 | 44 | </div> |
62 | 45 |
|
63 | | - {% comment %} Write Up (Blog, News): Content required. WYSIWYG editor (Markdown). {% endcomment %} |
64 | | - <div class="field create-post-page__content-field" x-show="isWriteUp" :class="{ 'field--error': errors.content }"> |
65 | | - <label class="field__label" for="field-content">Content *</label> |
66 | | - {% include "v3/includes/_wysiwyg_editor.html" with textarea_id="field-content" textarea_name="content" label="Content" %} |
67 | | - <p class="field__error" id="field-content-error" role="alert" x-show="errors.content" x-text="errors.content" x-cloak aria-live="polite"></p> |
68 | | - <p class="field__help" id="field-content-help" x-show="!errors.content">This editor supports Markdown: headings, lists, code blocks, links, and more.</p> |
69 | | - </div> |
| 46 | + <div class="create-post-page__card"> |
| 47 | + {% comment %} Post Type dropdown: Blog, News, Video, Link. Placeholder "Select Post Type". Controls conditional fields. {% endcomment %} |
| 48 | + {% include "v3/includes/_field_dropdown.html" with name="post_type" label="Post type *" options=post_type_options placeholder="Select Post Type" required=True %} |
| 49 | + <p class="field__error" id="post-type-error" role="alert" x-show="errors.post_type" x-text="errors.post_type" x-cloak></p> |
70 | 50 |
|
71 | | - {% comment %} Link (Video, Link): Link (required) and Description (optional). {% endcomment %} |
72 | | - <div class="create-post-page__link-fields" x-show="isLinkType" x-cloak> |
73 | | - <div class="field" :class="{ 'field--error': errors.external_url }"> |
74 | | - <label class="field__label" for="field-external_url">Link *</label> |
| 51 | + <div class="field" :class="{ 'field--error': errors.title }"> |
| 52 | + <label class="field__label" for="field-title">Post title *</label> |
75 | 53 | <div class="field__control"> |
76 | | - <input class="field__input" type="url" id="field-external_url" name="external_url" placeholder="https://..." |
77 | | - :aria-invalid="!!errors.external_url" |
78 | | - :aria-describedby="errors.external_url ? 'field-external_url-error' : null"> |
| 54 | + <input class="field__input" type="text" id="field-title" name="title" placeholder="Title" required |
| 55 | + :aria-invalid="!!errors.title" |
| 56 | + :aria-describedby="errors.title ? 'field-title-error' : null"> |
| 57 | + |
79 | 58 | </div> |
80 | | - <p class="field__error" id="field-external_url-error" role="alert" x-show="errors.external_url" x-text="errors.external_url" x-cloak aria-live="polite"></p> |
| 59 | + <p class="field__error" id="field-title-error" role="alert" x-show="errors.title" x-text="errors.title" x-cloak aria-live="polite"></p> |
| 60 | + </div> |
| 61 | + |
| 62 | + {% comment %} Write Up (Blog, News): Content required. WYSIWYG editor (Markdown). {% endcomment %} |
| 63 | + <div class="field create-post-page__content-field" x-show="isWriteUp" :class="{ 'field--error': errors.content }"> |
| 64 | + <label class="field__label" for="field-content">Content *</label> |
| 65 | + {% include "v3/includes/_wysiwyg_editor.html" with textarea_id="field-content" textarea_name="content" label="Content" %} |
| 66 | + <p class="field__error" id="field-content-error" role="alert" x-show="errors.content" x-text="errors.content" x-cloak aria-live="polite"></p> |
| 67 | + <p class="field__help" id="field-content-help" x-show="!errors.content">This editor supports Markdown: headings, lists, code blocks, links, and more.</p> |
| 68 | + </div> |
| 69 | + |
| 70 | + {% comment %} Link (Video, Link): Link (required) and Description (optional). {% endcomment %} |
| 71 | + <div class="create-post-page__link-fields" x-show="isLinkType" x-cloak> |
| 72 | + <div class="field" :class="{ 'field--error': errors.external_url }"> |
| 73 | + <label class="field__label" for="field-external_url">Link *</label> |
| 74 | + <div class="field__control"> |
| 75 | + <input class="field__input" type="url" id="field-external_url" name="external_url" placeholder="https://..." |
| 76 | + :aria-invalid="!!errors.external_url" |
| 77 | + :aria-describedby="errors.external_url ? 'field-external_url-error' : null"> |
| 78 | + </div> |
| 79 | + <p class="field__error" id="field-external_url-error" role="alert" x-show="errors.external_url" x-text="errors.external_url" x-cloak aria-live="polite"></p> |
| 80 | + </div> |
| 81 | + {% include "v3/includes/_field_textarea.html" with name="content_link" label="Description" placeholder="Optional description" rows=3 %} |
81 | 82 | </div> |
82 | | - {% include "v3/includes/_field_textarea.html" with name="content_link" label="Description" placeholder="Optional description" rows=3 %} |
83 | | - </div> |
84 | 83 |
|
85 | | - {% include "v3/includes/_field_file.html" with name="image" label="Image" accept="image/png,image/jpeg" preview=True alpine_error="errors.image" error=form.errors.image.0 help_text="This should be a PNG or JPEG format and no longer than 5MB" extra_class="field--file-narrow create-post-page__field-image" %} |
| 84 | + {% include "v3/includes/_field_file.html" with name="image" label="Image" accept="image/png,image/jpeg" preview=True alpine_error="errors.image" error=form.errors.image.0 help_text="This should be a PNG or JPEG format and no longer than 5MB" extra_class="field--file-narrow create-post-page__field-image" %} |
86 | 85 |
|
87 | | - {% include "v3/includes/_field_dropdown.html" with name="related_libraries" label="Related Libraries" options=related_libraries_options placeholder="Select" %} |
| 86 | + {% include "v3/includes/_field_dropdown.html" with name="related_libraries" label="Related Libraries" options=related_libraries_options placeholder="Select" %} |
88 | 87 |
|
89 | | - {% include "v3/includes/_field_text.html" with name="publish_at" label="Publish Date" type="datetime-local" value=publish_at_initial %} |
| 88 | + {% include "v3/includes/_field_text.html" with name="publish_at" label="Publish Date" type="datetime-local" value=publish_at_initial %} |
90 | 89 |
|
91 | | - <div class="create-post-page__actions"> |
92 | | - <a href="{% url 'news' %}" class="btn btn-secondary">Cancel</a> |
93 | | - <button type="submit" class="btn btn-primary">Submit</button> |
| 90 | + <div class="create-post-page__actions"> |
| 91 | + <a href="{% url 'news' %}" class="btn btn-secondary">Cancel</a> |
| 92 | + <button type="submit" class="btn btn-primary">Submit</button> |
| 93 | + </div> |
94 | 94 | </div> |
95 | | - </div> |
96 | | - </form> |
97 | | - </div> |
| 95 | + </form> |
98 | 96 | </div> |
99 | 97 | </div> |
100 | 98 |
|
101 | | - <script> |
| 99 | + <script> |
102 | 100 | document.addEventListener('alpine:init', () => { |
103 | 101 | const createUrls = { |
104 | 102 | blog: '{{ blogpost_create_url }}', |
|
0 commit comments