Skip to content

Conversation

@harryhmc
Copy link

@harryhmc harryhmc commented Jul 8, 2020

PR to add a loading component created as part of Cervical Screening platform.

const Loading: React.FC<Props> = ({ text, ...rest }: Props) => (
<div {...rest}>
<div className="nhsuk-loader__container">
<p className="nhsuk-heading-l">{text}</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we want to render this element if no text prop is supplied?

Copy link
Author

Choose a reason for hiding this comment

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

I was thinking of just using a default value of "Loading..." if text isn't supplied, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant more of an empty string - so if someone wanted to disable the text entirely it wouldn't render an empty <p> tag (which I think can fail some Jest-axe tests but that might only be headers)

Copy link
Author

Choose a reason for hiding this comment

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

Ok, i'll have it check for the text being non-empty 👍

On that note, do you think it's worth adding a withoutText boolean prop for removing the text entirely? Seems like it'd be more intuitive than supplying an empty string to get around the default behaviour

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe allow for similar handling to errors in some components - i.e. allow for the type of text to be string | false and then check for false, and otherwise display any text passed in

Copy link
Author

Choose a reason for hiding this comment

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

updated


.nhsuk-loader {
pointer-events: none;
width: 2.5em;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be specifying the width on the .nhsuk-loader itself? The only way a user would be able to change the size of the spinner would be to directly override the .nhsuk-loader class. Would it be better to ensure that this element takes up 100% of it's container, then set the sizing on the container itself?

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.

2 participants