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

Remove example files govuk frontend #890

Merged
merged 6 commits into from
Jul 12, 2018

Conversation

NickColley
Copy link
Contributor

This pull request removes the requirement for components to have a hardcoded example, and instead makes use of the first example as defined in the components 'yaml' config.

While these files are published to npm, as far as I know these are only used for internal documentation on the 'all components' page of the review applications.

It's also unlikely a user would use this functionality, since these files have hardcoded examples.

For this reason I'm determining this as not a breaking change, but a documentation related change.

https://trello.com/c/qM6PLrZj/264-spike-decide-whether-to-generate-example-html-files-from-the-examples-in-the-yaml-file-one-hour

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-890 July 12, 2018 13:18 Inactive
@36degrees
Copy link
Contributor

I think these three commits are largely unrelated – could they be split up into separate PRs?

@NickColley
Copy link
Contributor Author

If the context of the pull request is to remove the examples, then If I do that without updating the 'all components' page our tests will fail, so they can't be split up.

If the context of the pull request is to use the yaml rather than hardcoding, we'd have lots of unused files which normally we would clean up in the same file if possible?

Happy to split up if you think that makes it easier to understand.

Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

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

For some reason I totally failed to recognise that the 'All components' page actually used the .njk files – I thought they weren't being used anywhere any more. Sloppy reviewing on my part – sorry Nick!

Now that I actually understand what this PR is doing, it looks like a really good cleanup and a great improvement to the 'All components' example page 👍 💯

I do wonder whether it would make sense to 'move' the all components page to '/components/all' and move it from the examples list to the components list? As it seems to have more in common with those pages than this one?

Also one relatively minor comment just to make sure we're picking the same example to 'represent' the components.

app/app.js Outdated

res.locals.componentData = components.map(componentName => {
let componentData = fileHelper.getComponentData(componentName)
let firstExample = componentData.examples[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is assuming that the first example will be the 'default' example – to be consistent with what we do elsewhere can we re-use the logic from here to pull out whichever example has the name 'default'?

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 suppose I was not too concerned that this logic does get the default (even though it does by coincidence).

Let's go with your suggestion and have the same intent as elsewhere.

@NickColley
Copy link
Contributor Author

I like your suggestion about having an 'all' rather than in examples, will make that change.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-890 July 12, 2018 15:52 Inactive
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

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

Good stuff! 💯

@NickColley
Copy link
Contributor Author

Need to change the tests since they pointed at the old examples route.

@@ -90,7 +90,10 @@ describe('frontend app', () => {
request.get(requestParamsHomepage, (err, res) => {
let $ = cheerio.load(res.body)
let componentsList = $('li a[href^="/components/"]').get()
expect(componentsList.length).toEqual(lib.allComponents.length)
// Since we have an 'all' component link that renders the default example of all
// components, there will always be one more expected link.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@36degrees
Copy link
Contributor

Good stuff.

@NickColley NickColley merged commit dbd1515 into master Jul 12, 2018
@NickColley NickColley deleted the remove-example-files-govuk-frontend branch July 12, 2018 16:47
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.

3 participants