-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: master
Are you sure you want to change the base?
Conversation
🔎 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. |
There was a problem hiding this 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
export interface ArticleCardStateLoaded { | ||
type: 'loaded'; | ||
banner: string; | ||
date: string; | ||
description: string; | ||
link: string; | ||
title: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
There was a problem hiding this comment.
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[]; |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
2e30bba
to
99185ac
Compare
There was a problem hiding this 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)} |
There was a problem hiding this comment.
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
export interface ArticleCardStateLoaded { | ||
type: 'loaded'; | ||
banner: string; | ||
date: string; | ||
description: string; | ||
link: string; | ||
title: string; | ||
} |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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. 😉
92a6cda
to
3dab4cf
Compare
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
7cdfdc8
to
ecd09d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this PR do?
cc-article-list
&cc-article-card
components to implement our new state structure,cc-article-list
&cc-article-card
components and their stories.How to review?