Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

feat: migrate role from types #222

Merged
merged 6 commits into from
Jul 13, 2021
Merged

feat: migrate role from types #222

merged 6 commits into from
Jul 13, 2021

Conversation

jamie-lynch
Copy link
Contributor

What does this change?

  • Migrates role from @guardian/types to @guardian/libs

Why?

See guardian/types#136

@jamie-lynch jamie-lynch requested review from gtrufitt and a team as code owners June 23, 2021 15:02
README.md Outdated
@@ -71,6 +72,10 @@ Inject an external JavaScript file.

Selectively log team-specific messages to the console.

### [`role`](./src/role.README.md)

<!-- Insert summary here -->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't able to guess at a useful summary here so suggestions welcome.

Copy link
Member

Choose a reason for hiding this comment

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

We should def rename this :)

Copy link
Member

Choose a reason for hiding this comment

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

I have no idea what to though

Copy link
Contributor Author

@jamie-lynch jamie-lynch Jun 28, 2021

Choose a reason for hiding this comment

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

@JamieB-gu Looks like it might have been you that added this initially (guardian/types#33). We're not entirely sure what this is / what it's used for so have you got any suggestions for the summary and a more specific name?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can give it a go.

It's a semantic/layout-oriented property that's applied to elements in an article. It describes the "role" of that element in the piece and how it should be laid out within the page. It's probably easiest to understand when thinking about images. Is the image filling a "supporting" role? Is it just a thumbnail (for example the author avatars here)? Is it "showcasing" something (as in this piece). Whilst most commonly used for images, it can also apply to atoms and embeds.

That's the limit of my understanding, but @paperboyo can probably give a more accurate answer with some historical context.

I don't think it has another name; "role" is how it's referred to throughout the CAPI models and most likely in Composer too.

Choose a reason for hiding this comment

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

All what Jamie said is true! Only Composer calls it weighting in the UI, because nothing is ever perfect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, thanks for explaining that. In that case, could we call it something like ArticleElementRole to make it a bit more explicit? In the meantime, I'll update the README to add this in.

Copy link
Contributor

@JamieB-gu JamieB-gu Jun 29, 2021

Choose a reason for hiding this comment

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

Awesome, thanks Jamie! 🚀

As an aside: The argument @sndrs made about Format not belonging in libs is perhaps also relevant to Role. If it's specifically an Editorial concept that's going to lose context when placed in a "generic" repo like libs then perhaps this is ultimately not the place for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's a fair point. I've add a comment to the thread in #220 so once we reach a final decision for Format, should we just do the same thing with Role?

src/role.test.ts Outdated
Comment on lines 1 to 5
import { Role } from './role';

it('Role enum contains Standard', () => {
expect(Role.Standard).toBeDefined();
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to #220 (comment), I'm not sure if this is useful beyond keeping coveralls happy.

Copy link
Contributor

Choose a reason for hiding this comment

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

At the very least it means that if you’re changing a type, you need to change it in two places, which seems like it’s a good reminded that it is a breaking change?

@coveralls
Copy link

coveralls commented Jul 5, 2021

Coverage Status

Coverage increased (+0.01%) to 99.525% when pulling 7ef2cda on migrate-role into 654a80f on main.

@jamie-lynch jamie-lynch merged commit 8ea2829 into main Jul 13, 2021
@jamie-lynch jamie-lynch deleted the migrate-role branch July 13, 2021 12:50
@github-actions
Copy link

🎉 This PR is included in version 2.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

6 participants