Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest news and featured projects component #41

Merged
merged 19 commits into from
Nov 22, 2022
Merged

Latest news and featured projects component #41

merged 19 commits into from
Nov 22, 2022

Conversation

Moggach
Copy link
Contributor

@Moggach Moggach commented Nov 14, 2022

Description

  • Adds gallery component as a struct block for now - needs hooking up to database
  • Should be re-usable across any content type - will need to add logic for this
  • A HTML and CSS template
  • A Stimulus Carousel component for the slider

Motivation and Context

Addresses issues #218 and #216

Figma

How Can It Be Tested?

Download the branch and run locally. Include the 'carousel' block on a page template
Fill in the required fields in the CMS. View the page.

Screenshots (if appropriate):

Screenshot 2022-11-14 at 20 26 56

Screenshot 2022-11-14 at 20 27 29

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I've checked the spec (e.g. Figma file) and documented any divergences.
  • My code follows the code style of this project.

app/templates/app/blocks/carousel_block.html Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
Comment on lines 23 to 44
{% image card.image fill-300x200 as img %}
<img src="{{ img.url }}" alt="{{ img.alt }}" class="rounded-xl mb-4"/>
<div class="flex flex-row gap-2 items-center text-sm font-medium text-gray-700 mb-4">
{{ card.category }}
<svg class="xmlns"
None="http://www.w3.org/2000/svg"
width="4"
height="5"
viewBox="0 0 4 5"
fill="none">
<path d="M1.99141 4.35869C1.64608 4.35869 1.33808 4.28402 1.06741 4.13469C0.806081 3.97602 0.596081 3.76602 0.437414 3.50469C0.288081 3.23402 0.213414 2.92602 0.213414 2.58069C0.213414 2.22602 0.288081 1.91802 0.437414 1.65669C0.596081 1.38602 0.806081 1.17602 1.06741 1.02669C1.33808 0.868023 1.64608 0.78869 1.99141 0.78869C2.34608 0.78869 2.65408 0.868023 2.91541 1.02669C3.18608 1.17602 3.39608 1.38602 3.54541 1.65669C3.70408 1.91802 3.78341 2.22602 3.78341 2.58069C3.78341 2.92602 3.70408 3.23402 3.54541 3.50469C3.39608 3.76602 3.18608 3.97602 2.91541 4.13469C2.65408 4.28402 2.34608 4.35869 1.99141 4.35869Z" fill="#5F5F5F"/>
</svg>
{% comment %} The metadata we display here will depend on the post category {% endcomment %}
{% if self.impact_area %}{{ self.impact_area }}{% endif %}
{% if card.date %}{{ card.date | date:"d M Y" }}{% endif %}
</div>
<h4 class="font-semibold leading-tight sm:text-xl md:text-2xl text-gray-900 mb-4">{{ card.heading }}</h4>
<p class="text-base font-normal text-gray-700 mb-4">{{ card.blurb }}</p>
{% comment %} The metadata we display here will depend on the post category {% endcomment %}
{% if card.organisation %}<p class="text-base font-semibold text-gray-900 mb-7">{{ card.organisation }}</p>{% endif %}
{% if card.author %}<p class="text-base font-semibold text-gray-900 mb-7">{{ card.author }}</p>{% endif %}
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, we should define a carousel_card.html template for each Page Type and include that via {% include page.card_template %}, and use this code as the default implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay great - so the 'type' of data passed to the template e.g. news, projects, tools etc will depend on the Page Type?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think that's wise.

@janbaykara
Copy link
Collaborator

One comment on the desktop screenshot: I think we want the imagery to be full width across its column, right?

Screenshot 2022-11-16 at 11 31 21

@Moggach
Copy link
Contributor Author

Moggach commented Nov 16, 2022

One comment on the desktop screenshot: I think we want the imagery to be full width across its column, right?

Screenshot 2022-11-16 at 11 31 21

Yeah I think this is the case across all screen widths actually. I've changed it now.

@janbaykara
Copy link
Collaborator

Ohh, I see the point of having a generic options-value property. I can reuse that for the impact area carousel. Maybe let's keep it that way then?

@janbaykara
Copy link
Collaborator

janbaykara commented Nov 16, 2022

Ohh, I see the point of having a generic options-value property. I can reuse that for the impact area carousel. Maybe let's keep it that way then?

E.g. here https://github.com/commonknowledge/hotosm-website/pull/44/files#diff-802d9298b6df63d2c47998b8b32f95e08222bcc2410d7ba2066fc98ce8cdef48

@janbaykara janbaykara closed this Nov 16, 2022
@janbaykara janbaykara reopened this Nov 16, 2022
@Moggach
Copy link
Contributor Author

Moggach commented Nov 16, 2022

Ohh, I see the point of having a generic options-value property. I can reuse that for the impact area carousel. Maybe let's keep it that way then?

should we set a series of default styles in the constructor and then have the options value property for overriding them for specific use cases?

@janbaykara
Copy link
Collaborator

Ohh, I see the point of having a generic options-value property. I can reuse that for the impact area carousel. Maybe let's keep it that way then?

should we set a series of default styles in the constructor and then have the options value property for overriding them for specific use cases?

Sounds like a plan, but I wouldn't put it in the constructor. Stimulus has a system for default values.

@Moggach
Copy link
Contributor Author

Moggach commented Nov 16, 2022

Ohh, I see the point of having a generic options-value property. I can reuse that for the impact area carousel. Maybe let's keep it that way then?

should we set a series of default styles in the constructor and then have the options value property for overriding them for specific use cases?

Sounds like a plan, but I wouldn't put it in the constructor. Stimulus has a system for default values.

So I think it already does this by referencing here:


export default class extends Controller {
    swiper: Swiper;
    // @ts-ignore
    optionsValue: SwiperOptions;

    static values = {
        options: Object,
    };

and defining here:

   get defaultOptions(): SwiperOptions {
        return {
            navigation: {
                nextEl: ".swiper-button-next",
                prevEl: ".swiper-button-prev",
            },
            breakpoints: {
                0: {
                    slidesPerView: 1,
                    spaceBetween: 30,
                },
                768: {
                    slidesPerView: 2,
                    spaceBetween: 20,
                },
                1024: {
                    slidesPerView: 3,
                    spaceBetween: 30,
                },
            },
        };

So if we're happy with these being the default options we can leave it as is?

@conatus
Copy link
Collaborator

conatus commented Nov 21, 2022

@Moggach

When merge conflicts are restored, feel that we can take another pass at review here, beyond a draft and get this in. It's quite a big deal to put this in the mix.

@Moggach
Copy link
Contributor Author

Moggach commented Nov 21, 2022

  • This now has a main carousel template which is included with relevant data on latest articles and featured projects templates
  • Latest articles block now pulls from the database and featured projects can be selected in the editor
    I think that
    {{ page.impact_area }} and {{ page.organisation }} will be tags? Is that right @janbaykara? Think this can be merged now anyhow

@Moggach Moggach marked this pull request as ready for review November 21, 2022 18:09
@Moggach Moggach changed the title Gallery component - frontend Latest news and featured projects component Nov 21, 2022
@conatus
Copy link
Collaborator

conatus commented Nov 22, 2022

Tests failing for the same reason as other branches, which is a security update within one of the packages. Should be a straightforward fix.

@conatus
Copy link
Collaborator

conatus commented Nov 22, 2022

@conatus
Copy link
Collaborator

conatus commented Nov 22, 2022

py is consumed by pytest. Likely resolution: upgrade pytest to version that makes this fix.

Note though that this is a false positive. The issue was assigned a CVE without much conversation, for an issue which is extremely low to non-existent risk.

pytest-dev/py#287
pytest-dev/pytest#10392

@conatus
Copy link
Collaborator

conatus commented Nov 22, 2022

We'd have to jump all the way to the latest version https://github.com/pytest-dev/pytest/releases, but as we currently have minimal tests, do not see this as especially problematic.

@conatus conatus mentioned this pull request Nov 22, 2022
3 tasks
Copy link
Collaborator

@conatus conatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice little find with the library here.

Looks good to go to me. This library gives us a lot useful functionality in other places.

I've not checked it out and run the code, but I presume @janbaykara has so proceeding.

class LatestArticles(CarouselBlock):
class Meta:
template = "app/blocks/latest_articles.html"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So latest the LatestArticles block is a raw run of latest articles. Whereas projects can be selected. Cool.

@conatus conatus removed the request for review from janbaykara November 22, 2022 09:29
@conatus conatus merged commit d01e674 into main Nov 22, 2022
@conatus conatus deleted the carousel branch November 22, 2022 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants