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

[DNM] Sport Tables #9166

Merged
merged 22 commits into from
Jun 24, 2021
Merged

[DNM] Sport Tables #9166

merged 22 commits into from
Jun 24, 2021

Conversation

ryanmccombe
Copy link
Contributor

@ryanmccombe ryanmccombe commented Jun 8, 2021

Do not merge yet - Sport in high scrutiny because of Euros

Resolves NEWSWORLDSERVICE-1252

Overall change:
Implement support for CPS Tables within Story pages, required for Sport

Code changes:

  • Add component and converter for CPS tables
  • Component only renders if service is Sport
  • Update STY page to use the component

  • I have assigned myself to this PR and the corresponding issues
  • I have added the cross-team label to this PR if it requires visibility across World Service teams
  • I have assigned this PR to the Simorgh project
  • (BBC contributors only) This PR follows the repository use guidelines

Testing:

  • Automated (jest and/or cypress) tests added (for new features) or updated (for existing features)
  • If necessary, I have run the local E2E non-smoke tests relevant to my changes (CYPRESS_APP_ENV=local CYPRESS_SMOKE=false yarn test:e2e:interactive)
  • This PR requires manual testing

@ryanmccombe ryanmccombe added the cross-team For visibility for both World Service teams (Engage & Media) label Jun 8, 2021
@ryanmccombe ryanmccombe self-assigned this Jun 8, 2021
@ryanmccombe ryanmccombe marked this pull request as ready for review June 16, 2021 10:35
Copy link
Contributor

@andrewscfc andrewscfc left a comment

Choose a reason for hiding this comment

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

No major comments but just interested in the container/component debate and checking our use of colour constants

@@ -0,0 +1,48 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering why CpsTable is in the containers directory rather than components; tbh I'm not clear what the distinction is in Simorgh myself? The distinction I've come across tends involve where the react component does data fetching or not. So if the CpsTable had a useEffect to get some data it might be more suitable as a container, if it is just a dumb component hydrated with data via props it is more of a component? I'm unsure if the distinction is that useful in our codebase but just want to try and be consitent where we can.

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 I don't find the distinction useful - I think the whole "containers and components" pattern was popularised by Dan Abramov in a 6-year-old medium post that went viral: https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0

He has since updated it to say he doesn't consider it a useful pattern - I tend to agree. Particularly in Simorgh, it seems somewhat arbitrary where we put components. Reason I put this one in containers is really just because that's where all the other block renderers are

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @ryanmccombe, just wanted to sound this out, I'd be in favour flattening the structure to just components we should bring this up with the wider team. Just thinking about this stuff before we do live pages where we will make a lot more components.

I'd stick with this in containers like you've done for now 👍

Choose a reason for hiding this comment

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

I agree! #4478

import CpsText from '../../CpsText';

const StyledTd = styled.td`
border-bottom: 1px solid #dbdbdb;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these colours reference values from https://github.com/bbc/psammead/blob/latest/packages/utilities/psammead-styles/src/colours.js

Just in case we are using colours inconsistent with those agreed by UX?

Copy link
Contributor

Choose a reason for hiding this comment

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

These colours come from the existing Sport colours here - https://github.com/bbc/gs-sass-tools/blob/master/settings/_sport-colours.scss#L14
Should I open a PR to add these two colours to psammead?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah it's a bit annoying but that's our source of truth for colours, just makes clear what UX etc refer to them as and allows us to change them en masse e.g. for chameleon project.

Feel free to do this in a follow-up PR though

Copy link
Contributor Author

@ryanmccombe ryanmccombe Jun 18, 2021

Choose a reason for hiding this comment

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

Sorry was looking into this earlier and got distracted - I did some comparison and it seems the colour here is different to what is on the sport pages like https://www.bbc.co.uk/sport/cricket/54646061

That page seems to have a border-bottom of #eee rather than #dbdbdb - the hover background colour seems to be slightly different too

Not sure if it's an issue. Either way, none of these exact colours were on our pallette. If we wanted to use the variables we'd need to either add new ones to psammead, or update the components to use one of the existing variables if they're "close enough"

Happy to help with either of these :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah good spot! I actually copied these colours from AlephAMP rather than Morph - https://www.bbc.co.uk/sport/amp/cricket/54646061

I'll open a follow up PR to add these to psammead :)

};

const CpsTable = ({ blocks, supportedServices }) => {
const { service } = useContext(ServiceContext);
Copy link
Contributor

@andrewscfc andrewscfc Jun 18, 2021

Choose a reason for hiding this comment

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

Ah the use of the contexts and stuff here makes this feel more like a container, it is pulling in Simorgh specific constructs and sanitising the data for rendering. Again unsure if the distiniction is useful just wanted to open the discussion out.

Maybe CpsTable should be a container while CpsTableRow and CpsTableCell are more components?

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason I put CpsTableRow and CpsTableCell inside the CpsTable folder was because they'll only ever be used as children of a CpsTable component. I'm very new to Simorgh though so maybe this was isn't conventional! I'm happy to move them to components if that's recommended?

Copy link
Contributor

@andrewscfc andrewscfc Jun 18, 2021

Choose a reason for hiding this comment

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

The makes total sense @paulcrane-bbc , we're working this stuff out a bit for ourselves at minute see: #9166 (comment)

I'd leave this as you have done it, it makes perfect sense given we don't have a clear definition of components vs containers.

Copy link
Contributor

@andrewscfc andrewscfc left a comment

Choose a reason for hiding this comment

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

Thanks for the discussions in the comments, approving this, there is a colour issue that could do with a follow-up PR ideally. Thanks!

@LilyL0u
Copy link
Contributor

LilyL0u commented Jun 21, 2021

Do we have an asset on test to use for testing when this is ready? I could add a Cypress test for tables on amp Sport pages

If we don't have one maybe I can make one

@LilyL0u LilyL0u closed this Jun 21, 2021
@LilyL0u LilyL0u reopened this Jun 21, 2021
@LilyL0u
Copy link
Contributor

LilyL0u commented Jun 21, 2021

Sorry I clicked 'close with comment' instead of 'comment' 😱

@paulcrane-bbc
Copy link
Contributor

paulcrane-bbc commented Jun 21, 2021

Hey @LilyL0u 👋
There's this story asset - https://www.test.bbc.co.uk/sport/netball/23288496.amp - bear in mind this contains a table that's intentionally complex. We're only supporting text in the Simorgh implementation so a couple of the rows that contain images or lists are empty.

There's also this asset in live if it's ok to use that environment - https://www.test.bbc.co.uk/sport/cricket/54646061.amp?renderer_env=live

@ryanmccombe ryanmccombe changed the title Sport Tables [DNM] Sport Tables Jun 24, 2021
@paulcrane-bbc paulcrane-bbc merged commit c28d294 into latest Jun 24, 2021
@joshcoventry joshcoventry deleted the sport-table-plumbing branch September 28, 2021 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-team For visibility for both World Service teams (Engage & Media)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants