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

refactor(cc-article-components)!: rework properties to avoid impossible states #1054

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

florian-sanders-cc
Copy link
Contributor

@florian-sanders-cc florian-sanders-cc commented May 7, 2024

What does this PR do?

  • Refactors the cc-article-list & cc-article-card components to implement our new state structure,
  • Implements TypeChecking within the cc-article-list & cc-article-card components and their stories.

How to review?

Copy link
Contributor

github-actions bot commented May 7, 2024

🔎 A preview has been automatically published : https://clever-components-preview.cellar-c2.services.clever-cloud.com/cc-article-list/state-migration/index.html.

This preview will be deleted once this PR is closed.

@florian-sanders-cc florian-sanders-cc changed the title refactor(cc-article-list/card): !: rework properties to avoid impossible states refactor(cc-article-components): !: rework properties to avoid impossible states May 7, 2024
Copy link
Contributor

@pdesoyres-cc pdesoyres-cc left a comment

Choose a reason for hiding this comment

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

Well done. I have only a suggestion

Comment on lines 3 to 5
export interface ArticleCardStateLoaded {
type: 'loaded';
banner: string;
date: string;
description: string;
link: string;
title: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export interface ArticleCardStateLoaded {
type: 'loaded';
banner: string;
date: string;
description: string;
link: string;
title: string;
}
export interface ArticleCardStateLoaded extends SkeletonArticle {
type: 'loaded';
}

If we do that, we should rename SkeletonArticle interface into Article.

Copy link
Member

Choose a reason for hiding this comment

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

I like Pierre's suggestion 👍

type: 'error';
export interface ArticleListStateLoaded {
type: 'loaded';
articles: ArticleCardStateLoaded[];
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: I'm ok with that but when I look at the smart component, I can see that all articles are fetch in one call. So there is no need to provide a state but only the data.

Copy link
Contributor

@pdesoyres-cc pdesoyres-cc left a comment

Choose a reason for hiding this comment

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

Well done with some little nitpicks

@florian-sanders-cc florian-sanders-cc changed the title refactor(cc-article-components): !: rework properties to avoid impossible states refactor(cc-article-components)!: rework properties to avoid impossible states May 13, 2024
Copy link
Member

@Galimede Galimede left a comment

Choose a reason for hiding this comment

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

Nice work, GG! 💪

I've just left a suggestion and a thought about having a state on cc-article-card but overall, LGTM! 🙂

<div class="title">
${ccLink(this.link, title, skeleton)}
${ccLink(this.state.link, data.title)}
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: while this.state.link is valid, you could use data.link to make it less confusing

Comment on lines 3 to 5
export interface ArticleCardStateLoaded {
type: 'loaded';
banner: string;
date: string;
description: string;
link: string;
title: string;
}
Copy link
Member

Choose a reason for hiding this comment

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

I like Pierre's suggestion 👍

const rawArticleListData = parseRssFeed(rssFeed, limit);

return rawArticleListData.map((rawArticle) => ({
type: 'loaded',
Copy link
Member

Choose a reason for hiding this comment

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

thought: Okay, I think this line makes me question having a state for cc-article-card. My "problem" is that cc-article-card is not loading data directly, it will be the role of this smart for cc-article-list. It feels like managing two states here. Plus, as we'll only use the card component within the list it might be overkill 🤔. Feel free to ping me if it's unclear for you. 😉

HeleneAmouzou and others added 4 commits June 5, 2024 15:50
BREAKING CHANGE: the properties have changed
- `state`: new property containing the whole state
- `title`: property has been deleted as it is now part of the state
- `description`: property has been deleted as it is now part of the state
- `banner`: property has been deleted as it is now part of the state
- `date`: property has been deleted as it is now part of the state
- `link`: property has been deleted as it is now part of the state
Copy link
Contributor

@pdesoyres-cc pdesoyres-cc left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants