Commit Graph
105 Commits
Author SHA1 Message Date
dependabot-preview[bot]andCaleb Cartwright 7ed502e23d Build(deps-dev): bump enzyme from 3.9.0 to 3.10.0 (#3579)
* Build(deps-dev): bump enzyme from 3.9.0 to 3.10.0

Bumps [enzyme](https://github.com/airbnb/enzyme/tree/HEAD/packages/enzyme) from 3.9.0 to 3.10.0.
- [Release notes](https://github.com/airbnb/enzyme/releases)
- [Changelog](https://github.com/airbnb/enzyme/blob/master/CHANGELOG.md)
- [Commits](https://github.com/airbnb/enzyme/commits/enzyme@3.10.0/packages/enzyme)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* tests: tweak assertion on emtpy attribute
2019-06-24 21:09:04 -05:00
Caleb CartwrightandGitHub b95811ba40 fix: modal scroll bug (#3517) 2019-06-02 11:42:16 -05:00
Mackenzie MillerandPaul Melnikow ca49e522b3 Make dropdown visible when it overflows modal content (#3510)
Resolves #2806
2019-05-30 21:51:06 -04:00
Marcin MielnickiandGitHub 9008c4ef0f Show a badge pattern instead of a badge url (#3438)
* Show patterns instead of real paths

* realBadge property instead of preview.buildFromExample

* E2e test for displaying a badge

* Check bagde url in badge wrapper

* expectBadgeExample helper function

* Remove a hostname from badge url

* Simpler Cypress assertions

* realBadge -> isBadgeSuggestion

* Do not show regexp in patterns
2019-05-29 21:17:27 +02:00
Paul MelnikowandGitHub 5e8fcc3b3c MarkupModal: Convert from class component to function component (#3415)
This continues the work from #3096, of converting our class components to function components.
2019-05-06 12:13:06 -04:00
Paul MelnikowandPierre-Yves B 1da791e778 LogoPage: Update function style (#3414)
Many of the components (e.g. the ones in `common.js`) have already been converted to this style. This file was missed.
2019-05-06 09:51:07 +01:00
Paul MelnikowandGitHub c3bc0ac96f Take the Endpoint badge out of beta (#3405)
Close #2838
2019-05-01 23:05:34 -04:00
Marcin MielnickiandGitHub eeb78ccf15 Badge suggestion feature fix (#3331)
* Display suggested badges

* E2e test for badge suggestion

* Suggest resource returns example with pattern

* Do not require preview in MarkupModalContent

* Skip integration test for suggestion

* Unmodifiable path in customizer

* Use suggested link

* Allow to change suggested badges

* Enable skipped test

* Enable skipped test

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Unused code removed

* Unused code removed

* getExampleWithServiceByPattern helper added

* BadgeExamples uses examples instead of services definitions

* Revert "getExampleWithServiceByPattern helper added"

This reverts commit 80839fd705.

* style removed from example

* example.exact replaced with preview.buildFromExample

* keywords are required again

* Code refactoring

* More e2e tests for suggestion feature

* Code refactoring

* Build add with a base url

* showActualParams -> isPrefilled

* A new schema for BadgeExamples

* Link moved to queryParams

* Updated documentation for the suggest reponse format

* Link moved to queryParams - another test updated

* Revert "Link moved to queryParams - another test updated"

This reverts commit b5f811bb07.

* Revert "Link moved to queryParams"

This reverts commit 3b54c6d2b4.

* Disable changes in path in suggested badges

* 'link' element documentation restored
2019-04-29 18:38:27 +02:00
tooommandchris48s 4911e11584 add more helpful syntax links to dynamic badges (#3223) 2019-03-22 22:00:10 +00:00
Paul MelnikowandGitHub 667bbbebfa Rewrite a bunch of components as functions, with consistent func style (#3177) 2019-03-08 00:02:23 -05:00
Paul MelnikowandCaleb Cartwright b288c99a29 Fix console error before applying a frontend route redirect (#3176) 2019-03-07 19:34:27 -06:00
Paul MelnikowandGitHub c7deb5a0d1 First adoption of React hooks (#3096)
I did this as a warm-up to using [React hooks](https://reactjs.org/docs/hooks-intro.html), which provide a better way to accomplish stateful things and side effects using functional components. This allows all components to be written in the same style, improves testability, facilitates code reuse, etc.

There's [a intro here](https://reactjs.org/docs/hooks-intro.html) which links to [Dan's talk at React Conf](https://www.youtube.com/watch?time_continue=3599&v=dpw9EHDh2bM) which does a really good job of explaining why hooks are a good way to write components. He describes hooks as being the electrons and neutrons to components which are atoms. Low-level functionality which was always there in React, though not as accessibly or visibly.

This adds a lint rule that enforces "the rule of hooks" which says they have to be declared at the top level in the functional component.

I don't think this changeset does a fabulous job of showing off the improvements hooks allows, though I think it is still a good direction for this code.
2019-03-03 18:30:20 -05:00
XhmikosRandPaul Melnikow 4e2d144f97 Fix footer links (#3121)
Fix discord footer link and remove trailing slash from repo URL
2019-02-28 11:55:38 -05:00
Paul MelnikowandGitHub e3d115cf99 Rename maxAge to cacheSeconds (#3090)
Close #3069
2019-02-23 20:33:38 -05:00
Paul MelnikowandGitHub 09e902fa38 Add frontend prop-type validation for the service definition schema (#3063)
Closes #2702
2019-02-23 15:34:49 -05:00
Paul MelnikowandGitHub cd49bda968 Improve coverage in frontend and remove some dead code (#3031) 2019-02-22 00:08:11 -05:00
Paul MelnikowandGitHub ab18bc0f09 Shorten [endpoint] URL (#3050)
Ref https://github.com/badges/shields/issues/2838#issuecomment-461794344
2019-02-22 00:01:56 -05:00
Paul MelnikowandGitHub 4bd16f93e8 Sort imports and requires (#3056)
This will definitely save time, and ensure more uniformity.

It moves the `createServiceTester()` calls to a different place from where I'd like them, though I'm happy to have them checked by the linter.

Closes #2701
2019-02-21 22:14:40 -05:00
mbarkhauandPaul Melnikow f6628e62b7 [QueryStringStatic] service (#3024)
Ref #2673
2019-02-21 21:12:24 -05:00
Paul MelnikowandGitHub 9e4a8cec09 Consolidate badge URL generation functions (#3032)
This consolidates all the badge URL generation functions into a single place, and updates the rest of the calling code to use it. It renames some things and updates labels to bring the names into alignment with the current API.

Resolve #2027
2019-02-21 21:07:27 -05:00
Paul MelnikowandGitHub 5fda6ac11e Alphabetize JSX props in the frontend (#3055)
I'm game to give this a shot.

Ref #2701
2019-02-20 18:58:24 -05:00
Paul MelnikowandGitHub bc523e3aae Fix your-badge link (#3058)
Fix #1954
2019-02-20 16:34:50 -05:00
chris48sandPaul Melnikow 6d4b80f124 improve docs for simple-icons usage (#3007)
Closes #2980
2019-02-19 22:14:19 -05:00
mbarkhauandPaul Melnikow 6e2992a3e3 Rename colorB -> color; colorA -> labelColor (#3012)
This makes it possible to override the parameters `color` and `labelColor`.

ref #2673
2019-02-19 22:03:45 -05:00
Paul MelnikowandCaleb Cartwright ad81f3c6ec Improve handling of some edge cases and get 100% coverage in generate-image-markup (#3030) 2019-02-18 19:25:02 -06:00
Paul MelnikowandGitHub 0506a1762b Omit style=flat from generated URLs (#3025)
Fix #2953
2019-02-18 18:01:44 -05:00
Paul MelnikowandGitHub d9d8a3b227 Drop-downs for multiple choice in patterns (#2882)
You can see it in effect on the PyPI downloads and the David badges.
2019-02-18 11:15:58 -05:00
chris48sandGitHub 0da1bb2b08 fix asciiDoc links (#3006) 2019-02-17 21:55:22 +00:00
Ville SkyttäandPaul Melnikow 0d4a74bd6b Spelling fixes (#3013) 2019-02-17 14:10:06 -05:00
Paul MelnikowandCaleb Cartwright 90f8ad5b73 Endpoint customizer (#2908)
* Endpoint page: improve formatting

Cherry-picked from #2906 (conflicts with that)

Partly addresses #2837 but does not resolve it

* Add badge customizer to the endpoint page

* Clean lint
2019-02-14 19:08:56 -06:00
Paul Melnikowandchris48s 725ffca2d1 Add some more perfunctory coverage of the frontend (#2962) 2019-02-10 20:34:17 +00:00
Paul MelnikowandGitHub ae37e9b723 Add a diagnostic page for testing logos (#2890)
It can be helpful to have some diagnostic pages for development and quality control. I added one here for the logos, which renders all the named logos in ?style=flat and ?style=social.
2019-02-08 00:08:45 -05:00
Paul MelnikowandGitHub d8ce045ead Adopt Gatsby (#2906)
While Next.js can handle static sites, we've had a few issues with it, notably a performance hit at runtime and some bugginess around routing and SSR. Gatsby being fully intended for high-performance static sites makes it a great technical fit for the Shields frontend. The `createPages()` API should be a really nice way to add a page for each service family, for example.

This migrates the frontend from Next.js to Gatsby. Gatsby is a powerful tool, which has a bit of downside as there's a lot to dig through. Overall I found configuration easier than Next.js. There are a lot of plugins and for the most part they worked out of the box. The documentation is good.

Links are cleaner now: there is no #. This will break old links though perhaps we could add some redirection to help with that. The only one I’m really concerned about `/#/endpoint`. I’m not sure if folks are deep-linking to the category pages.

There are a lot of enhancements we could add, in order to speed up the site even more. In particular we could think about inlining the SVGs rather than making separate requests for each one.

While Gatsby recommends GraphQL, it's not required. To keep things simple and reduce the learning curve, I did not use it here.

Close #1943 
Fix #2837 Fix #2616
2019-02-06 16:37:55 -05:00
Paul MelnikowandCaleb Cartwright 552e5e798d Add semantic color keywords and improve formatting of color examples (#2869)
* Add semantic color keywords

This is based on the list I proposed at https://github.com/badges/shields/issues/1522#issuecomment-456455618. As I started documenting `default` I realized it didn't feel quite right. It's not semantic in relation to the content the way the others are, and it's also not the default left color. I changed it to `disabled` which isn't perfect, but seems better. I'm open to other suggestions.

I updated the documentation but the colors won't render correctly until this is deployed

Close #1522

* Reformat the aliases

* Pretty up the docs

* Reset whitespace changes

* Clean lint
2019-02-04 15:05:57 -06:00
Paul MelnikowandGitHub b01e466284 Endpoint page: improve formatting (#2907)
Partly addresses #2837 but does not resolve it
2019-02-02 14:10:52 -05:00
Paul MelnikowandGitHub 3a7bddbc26 Consolidate service definition schema, removing support for previewUrl (#2895)
This removes `LONG_CACHE` and its descendants, which was a feature that added `?maxAge` to the live preview badges in the frontend. Since they are all static that is no longer needed, as the static badges all have longer cache timeouts regardless.
2019-01-30 18:35:11 -06:00
Paul MelnikowandGitHub 5b122ddd73 Social badge support for static previews (#2871)
The static previews don't support the social badges. Adding that lets us remove support for `exampleUrl`. Close #2479.

This includes `style` and `namedLogo` in the service-definition export and updates the frontend to use it. To accomplish this, it passes `namedLogo` through `coalesceBadge`. After logo resolution is moved to `makeBadge` this duplication can be removed, as `logo` will no longer be needed in the result of `coalesceBadge`.
2019-01-28 22:44:25 -06:00
chris48sandGitHub a8bedce8a4 clarify cache docs for endpoint badge (#2855) 2019-01-23 22:02:43 +00:00
Paul MelnikowandGitHub 0fc3df84d7 [Endpoint] badge (#2473)
This reimplements the idea @bkdotcom came up with in #1519, and took a stab at in #1525. It’s a really powerful way to add all sorts of custom badges, particularly considering [tools like RunKit endpoints and Jupyter Kernel Gateway](https://github.com/badges/shields/issues/2259#issuecomment-444186589), not to mention all the other ways cloud functions can be deployed these days.
2019-01-21 22:55:24 -05:00
Paul MelnikowandGitHub 2ece7c4ee2 Wrap HTML in __html in service def export (#2791)
The intention of wrapping HTML in an `__html` is to avoid accidentally unsafe rendering of something that is non-html.

Including this in the definition export solves the problem, and does not seem too onerous for other possible users of that file.

Close #2725
2019-01-17 13:47:23 -05:00
Paul MelnikowandGitHub 4415a3e94e Reorganize badge URL helper functions (#2790)
Ref #2698
2019-01-17 13:44:46 -05:00
Paul MelnikowandGitHub 22e8510fc7 Remove some unused state to clear lgtm alerts (#2767)
https://lgtm.com/projects/g/badges/shields/snapshot/39309c9c207b770716a37e481419a5d4ea028250/files/frontend/components/markup-modal/markup-modal-content.js?sort=name&dir=ASC&mode=heatmap#x9b1573629b59d42e:1
2019-01-15 14:59:02 -05:00
chris48sandGitHub e22934eab0 only display the menu once (#2727)
* only display the menu once
2019-01-11 21:28:18 +00:00
Paul MelnikowandGitHub 6c2b040fa6 Better modal (#2554)
- With examples using `pattern`s, allow building the URL from its component parts, including the query string.
- Provide a button to copy the link, with an animation.

To enable this for other badges, convert them to use a `pattern`: #1961.
2019-01-10 21:04:07 -05:00
Paul MelnikowandGitHub 06c6f13770 Add category nav menu (#2682)
Adapted from @chris48s’ work from #1842.
2019-01-09 08:46:27 -05:00
Maximilian BrandauandPaul Melnikow 9faa0088bf Replace open collective with shields rendered badges (#2672)
Closes #2498
2019-01-07 15:02:39 -05:00
Paul MelnikowandGitHub a9839845a1 Add some test coverage in frontend/lib (#2615) 2019-01-02 00:12:51 -05:00
dependabot[bot]andPaul Melnikow 860c426a0c Bump eslint-plugin-react from 7.11.1 to 7.12.0 (#2609)
* Bump eslint-plugin-react from 7.11.1 to 7.12.0

Bumps [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) from 7.11.1 to 7.12.0.
- [Release notes](https://github.com/yannickcr/eslint-plugin-react/releases)
- [Changelog](https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yannickcr/eslint-plugin-react/compare/v7.11.1...v7.12.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Fix lint errors

* Better link

* Re-bump package version and remove lint disable
2019-01-01 21:22:09 -05:00
Paul MelnikowandGitHub 5c7d07f5be Rework styling using styled-components (#2517)
The CSS in the project is relatively difficult to change. While it is very DRY, it relies heavily on inheritance. It's difficult to make changes in the markup modal without it also affecting styles elsewhere.
 
[styled-components](https://www.styled-components.com/) is one of the leading CSS-in-JS libraries. By reducing dependency on global state and CSS inheritance, styles become explicit and are easier to inspect and change. It's also convenient that styles can be embedded with the components they modify.

At runtime, the library creates CSS classes, so it's pretty efficient.

We were using a little bit of [styled-jsx](https://github.com/zeit/styled-jsx) before, which ships with Next.js, though styled-components is more widely used and I've had good experiences with it all around.

In a few cases I've duplicated styles where it feels more natural to do that: for example, `text-align: center` is duplicated in `Main` and `MarkupModal`.

Much of this is a refactor, though there are a few visual changes, particularly in the markup modal and the style examples.
2018-12-18 16:44:47 -05:00
Paul MelnikowandGitHub a677c5bbef Add some basic frontend tests (#2490)
The frontend has a few tests in `lib/` but not all of that is covered. The components are not covered at all. It's difficult to make changes to the frontend because you have to manually test that things haven't broken.

This PR uses [Enzyme](https://airbnb.io/enzyme/) to add some [shallow-rendering tests](https://github.com/airbnb/enzyme/blob/master/docs/api/shallow.md), which are essentially unit tests of the components.

This should pave the way for functional tests of the more complex components.
2018-12-10 17:20:01 -05:00