Skip to content

Conversation

@kitten
Copy link
Contributor

@kitten kitten commented Oct 31, 2017

Fix #388

  • Remove all references to prism's CSS and CDN bundle from the readme
  • Add prismjs package
  • Use react-live's 1.8.0-1 i.e. spectacletest release which includes a language prop and externalised prism build
  • Add src/utils/prism-import file (This includes all syntaxes that we'll support out of the box)
  • Mirror ComponentPlayground theming and setup
  • Rename theme properties

Breaking Changes:

  • The codePane theme's properties have been changed to wrapper and editor. They could stay pre and code, but this wouldn't reflect the actual elements accurately.

Future:

It'd be great to add some instructions on how to add more prism components. The added text to the Readme is minimal but doesn't really say much.

It'd be great to make the playground and codepane's theme props only recognise light and dark so that it can be set to another value so the user can write/use their own themes.

Improvements Summary:

So while the bundle will grow, since more prism components are now included (which doesn't matter much since removing codemirror and babel-standalone for buble should've helper it a little), this gets rid of extra setup steps for the user. Previously a Prism CSS and CDN bundle would have to be added manually.

Also, this should make the syntax theme between the playground and the codepane 100% consistent.

@@ -0,0 +1,48 @@
/* eslint-disable filenames/match-regex */
Copy link
Member

Choose a reason for hiding this comment

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

Why did we disable filenames for this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rule didn’t like something about the prism core import :(

Copy link
Member

Choose a reason for hiding this comment

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

It's complaining about src/utils/prismImport.js name of this file, not the imports within the code I believe.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, all the prismjs imported file names abide by the lint rule we have for this repo 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, ok. Sorry, I’ll make a change

@@ -0,0 +1,48 @@
/* eslint-disable filenames/match-regex */

import 'prismjs/components/prism-core';
Copy link
Member

@ryan-roemer ryan-roemer Oct 31, 2017

Choose a reason for hiding this comment

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

How much weight does this add to the bundle seeing that we're including "everything"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All in all if we take the other React-live PR into account it’s a net minus altogether:

before the react-live and codepane refactors: 2.4M (min, non-gzip, without prism) and after: 1.6M (min, non-gzip, with prism)

Copy link
Member

Choose a reason for hiding this comment

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

How much is just the prism part if you "external" 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.

I’ll check

Copy link
Contributor Author

@kitten kitten Oct 31, 2017

Choose a reason for hiding this comment

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

@ryan-roemer so, it's tough to exclude prism without excluding buble as both are also imported by react-live with the respective prism subpaths as well, but if I exclude: prism, react-live, and (thus also) buble, then I land at ~1.33MB

Copy link
Member

Choose a reason for hiding this comment

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

So that's just a ~0.3MB min difference? If so, I'm totally cool with that...

docs/tag-api.md Outdated
|source| PropTypes.string| String of code to be shown |

You can change your syntax highlighting theme by swapping the prism.js CSS file in `index.html`. Prism.js supports `Markup`, `CSS`, `C-like`and `Javascript` languages out of the box. To add more [supported languages](http://prismjs.com/#languages-list), you have to load the respective language's prism.js plugin in your index.html.
Prism.js supports `Markup`, `CSS`, `C-like`and `Javascript` languages out of the box. To add more [supported languages](http://prismjs.com/#languages-list), you have to import the respective language's prism.js component/plugin from `prismjs/components/prism-javascript`.
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you're importing a number of prism components, so you may want to modify this to match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, I'll clarify this a little

Copy link
Contributor

@carloskelly13 carloskelly13 left a comment

Choose a reason for hiding this comment

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

Does this fix the current errors about certain props not existing on elements?

@kitten
Copy link
Contributor Author

kitten commented Oct 31, 2017

@carlospaelinck where did you encounter these errors? I can take a look and see whether it outputs any warnings/errors w/ this PR

Edit: Ok, I see what you mean. That's not fixed but I'll make the change
Edit 2: So the warnings are coming from the playground. I'd have to add a small component inbetween react-live and emotion to make the errors go away. Separate PR?

@carloskelly13
Copy link
Contributor

@philpl Yeah that sounds fine!

<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700" rel="stylesheet" type="text/css">
<link href="https://unpkg.com/prismjs@1/themes/prism-tomorrow.css" rel="stylesheet" type="text/css">
<link href="https://unpkg.com/normalize.css@7/normalize.css" rel="stylesheet" type="text/css">
<link href="https://unpkg.com/spectacle/lib/themes/default/index.css" rel="stylesheet" type="text/css">
Copy link
Member

Choose a reason for hiding this comment

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

Can we update the spectacle unpkg link to include a major semver range? Here we'll proactively get ahead of things with our anticipated major bump to 4:

    <link href="https://unpkg.com/spectacle@^4/lib/themes/default/index.css" rel="stylesheet" type="text/css">
...
    <script src="https://unpkg.com/spectacle@^4/dist/spectacle.js"></script>
    <script src="https://unpkg.com/spectacle@^4/lib/one-page.js"></script>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :) c190c00

The links will obviously not work until we release v4

Copy link
Member

@ryan-roemer ryan-roemer left a comment

Choose a reason for hiding this comment

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

One suggestion for one-page.html. Everything else looks and works great!

@kitten
Copy link
Contributor Author

kitten commented Nov 1, 2017

@carlospaelinck I've got a follow up PR for the props issue here: #391 (includes a fix for the key propagation)

@kitten kitten merged commit 1cea368 into master Nov 1, 2017
@kitten kitten deleted the feature/bundled-prism branch November 1, 2017 18:22
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.

5 participants