Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!
OK after the words of encouragement I did the tutorial for Webpack.
It bundles the CSS with the JS and then injects the CSS inline in the head? Isn't that bad and will prevent the CSS file from being cached? Won't that be really bad when I switch it to my minified app.css that has styles for everything on the site?

I'm guessing I'm missing something, but the tutorial ended there.

Adbot
ADBOT LOVES YOU

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

The Merkinman posted:

OK after the words of encouragement I did the tutorial for Webpack.
It bundles the CSS with the JS and then injects the CSS inline in the head? Isn't that bad and will prevent the CSS file from being cached? Won't that be really bad when I switch it to my minified app.css that has styles for everything on the site?

I'm guessing I'm missing something, but the tutorial ended there.

The files won't be cached individually, but your whole package will be.

WORLDS BEST BABY
Aug 26, 2006

The Merkinman posted:

OK after the words of encouragement I did the tutorial for Webpack.
It bundles the CSS with the JS and then injects the CSS inline in the head? Isn't that bad and will prevent the CSS file from being cached? Won't that be really bad when I switch it to my minified app.css that has styles for everything on the site?

I'm guessing I'm missing something, but the tutorial ended there.

This is where webpack's extensibility comes in, though. You can use the extract-text-webpack-plugin to pull your loaded styles into a separate file. You can split your app's big dependencies out into a 'vendors' bundle so your users don't need to redownload everything when you deploy a bug fix. You can even split different parts of your app up into different bundles so users only download the parts of the app they need right now.

Much of which is stuff that Rollup can't do, btw. I think Rollup is a great solution for publishing libraries, but for a big app I'd pick webpack in a heartbeat.

Tivac
Feb 18, 2003

No matter how things may seem to change, never forget who you are

Thermopyle posted:

Just so you know, people use ES2015 modules with webpack as well. I haven't used require in a year or two.

Yup, webpack does everything. Still prefer rollup whenever possible :)

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

The Merkinman posted:

OK after the words of encouragement I did the tutorial for Webpack.
It bundles the CSS with the JS and then injects the CSS inline in the head? Isn't that bad and will prevent the CSS file from being cached? Won't that be really bad when I switch it to my minified app.css that has styles for everything on the site?

I'm guessing I'm missing something, but the tutorial ended there.

I posted my dev and production configs here on in the JS thread a couple days ago. In dev, you bundle everything into one blob because you are just hot reloading out of memory. In production, your CSS is pulled out into a file, your 3rd party JS is pulled into a file, and your app code is pulled into a third file. These are all named by their chunks hashes, so if an update doesn't add any new deps or change styles, those files stay the same and cached.

You can get more complicated and have different bundling with more splits / files, but I haven't built anything complex enough to need it.


The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!
Anyone have experience with ionic?
One of our developers mentioned it, but he has the habit of waiting to reinvent the wheel with new and shiny and a total disregard for workload and legacy.

Currently, our ecommerce site has a separate "desktop" version, and a "mobile" version that I'm slowly merging codebases of to one, response, site. We do not have an app of any kind, nor any plans to do so.

HaB
Jan 5, 2001

What are the odds?

The Merkinman posted:

Anyone have experience with ionic?
One of our developers mentioned it, but he has the habit of waiting to reinvent the wheel with new and shiny and a total disregard for workload and legacy.

Currently, our ecommerce site has a separate "desktop" version, and a "mobile" version that I'm slowly merging codebases of to one, response, site. We do not have an app of any kind, nor any plans to do so.

Ionic is a great framework - but it's for mobile. On Desktop it's just gonna look weird. If you don't have an app and aren't planning on it, you don't need Ionic.It's built on top of Cordova/Phonegap - so it's basically for the express purpose of compiling to an app.

lunar detritus
May 6, 2009


HaB posted:

Ionic is a great framework - but it's for mobile. On Desktop it's just gonna look weird. If you don't have an app and aren't planning on it, you don't need Ionic.It's built on top of Cordova/Phonegap - so it's basically for the express purpose of compiling to an app.

This. Ionic is basically Bootstrap for Cordova.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

HaB posted:

Ionic is a great framework - but it's for mobile. On Desktop it's just gonna look weird. If you don't have an app and aren't planning on it, you don't need Ionic.It's built on top of Cordova/Phonegap - so it's basically for the express purpose of compiling to an app.

I liked it quite a bit, for the week or so I was developing a Pokemon Go tracker for mobile. Then all the API projects went dark and I lost interest. The Ionic stuff was pretty good though. The various lab software can be a pain, and will frequently crash or do weird things while hosting up your page, so restart it often.

This is a good article that touches on how one might use Ionic/Electron to have a webapp share code across Web, Mobile, and Desktop.
https://medium.com/@kaumac/cross-pl...d742#.ffyy0az1s

Kekekela
Oct 28, 2004
Is there any way to set a:hover using inline styles in React, or do I just need to use onMouseEnter etc?

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Nope, inline styles don't allow pseudo selectors, just rules on the specific DOM element. When I've needed a style on a particular item that goes beyond what inline styles can do, I'll give it a unique id and put the relevant styling inside a style tag in the component, which react can do with dangerouslySetInnerHtml

Gul Banana
Nov 28, 2003

wouldn't it be easier to use a class than to generate unique ids for each copy of the component?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Gul Banana posted:

wouldn't it be easier to use a class than to generate unique ids for each copy of the component?

Then you are not self-contained.

Gul Banana
Nov 28, 2003

CSS modules or just BEM naming should be able to take care of that

Anony Mouse
Jan 30, 2005

A name means nothing on the battlefield. After a week, no one has a name.
Lipstick Apathy
I've mostly given up on inline styles for React except when absolutely necessary, i.e. something that is actually dependent on component state somehow. Even then I'll sometimes just render a different className and let CSS deal with it.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Gul Banana posted:

CSS modules or just BEM naming should be able to take care of that

True, I prefer BEM, however if the style is truly unique to that instance and generated by JavaScript it's time to crack out the unique id.

M31
Jun 12, 2012
Why would you need dangerouslySetInnerHtml though?

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
I thought it escaped some of the CSS characters within <style> otherwise, might be mistaken, though, been a while since I've done it.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

M31 posted:

Why would you need dangerouslySetInnerHtml though?

CSS uses quite a lot of curly braces...

M31
Jun 12, 2012
You can use a string or template literal:
code:
<div id={id}><style>{`#${id}:hover > * { color: red }`}</style>Foo<span>bar</span></div>

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

M31 posted:

You can use a string or template literal:
code:
<div id={id}><style>{`#${id}:hover > * { color: red }`}</style>Foo<span>bar</span></div>

It doesn't escape the text contents of a style tag?

M31
Jun 12, 2012
No, it creates a text node. Now that you mention it, it maybe doesn't work on React < 15.0.0 as the old versions use innerHTML for the initial render.

Kekekela
Oct 28, 2004

M31 posted:

You can use a string or template literal:
code:
<div id={id}><style>{`#${id}:hover > * { color: red }`}</style>Foo<span>bar</span></div>

Oh drat, had no idea that would work. Thanks.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

M31 posted:

No, it creates a text node. Now that you mention it, it maybe doesn't work on React < 15.0.0 as the old versions use innerHTML for the initial render.

I can't really remember for sure if I tried without dangerouslySetInnerHtml when I did it myself, but it was definitely before they did the rework of the DOM interactions like span wrapping string elements and such. That certainly seems like something that could've blocked this approach being correct sub 0.15.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Okay, so it seems progressive web apps are the new hotness right now. And apparently part of that is not compiling everything into one giant monolithic file. Are there tools/frameworks that help with splitting the core elements from the elements that can be loaded on-demand?

We're still using ember-cli, and the version is relatively fresh. I don't remember exactly what it was, but it's only several months old (instead of years)

edit: looked at my posting history itt and it seems out app is just about to reach its 2nd anniversary :toot:

edit2: found Ember-cli-lazy-load and ember-engines

Wheany fucked around with this message at 07:07 on Sep 19, 2016

The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!

Wheany posted:

Okay, so it seems progressive web apps are the new hotness right now. And apparently part of that is not compiling everything into one giant monolithic file.
Is it? I thought it was just:
* HTTPS
* Some manner of offline functionality
* Service Worker
* Manifest

Tivac
Feb 18, 2003

No matter how things may seem to change, never forget who you are

The Merkinman posted:

Is it? I thought it was just:
* HTTPS
* Some manner of offline functionality
* Service Worker
* Manifest

This is correct. Bundle-splitting is a great best-practice sort of thing but in no way required to build a PWA.

huhu
Feb 24, 2006
I'm working on a website and when I inspect a page in Chrome, there's two ways to resize it, one drag the window horizontally to make it smaller or use the Responsive Design Mode. The thing is, every so often, they render a page differently. Which should I trust and why would there be a difference?

IronDoge
Nov 6, 2008

I use the responsive design mode since it let's me switch between landscape and horizontal easily. Also I believe it also simulates the Device Pixel Ratio, which can mess things up if you don't have certain meta tags set, and changes the user agent. It's generally more accurate in the responsive design mode.

More details on it here: https://developers.google.com/web/tools/chrome-devtools/iterate/device-mode/emulate-mobile-viewports

IronDoge fucked around with this message at 22:06 on Sep 20, 2016

ddiddles
Oct 21, 2008

Roses are red, violets are blue, I'm a schizophrenic and so am I

IronDoge posted:

I use the responsive design mode since it let's me switch between landscape and horizontal easily. Also I believe it also simulates the Device Pixel Ratio, which can mess things up if you don't have certain meta tags set, and changes the user agent. It's generally more accurate in the responsive design mode.

More details on it here: https://developers.google.com/web/tools/chrome-devtools/iterate/device-mode/emulate-mobile-viewports

I like to watch the supercharged and live code session videos on the chrome dev YouTube channel. They do all their debugging with chrome dev tools and I'll usually see a feature I didn't even know existed.

http://youtube.com/user/ChromeDevelopers/videos

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



huhu posted:

I'm working on a website and when I inspect a page in Chrome, there's two ways to resize it, one drag the window horizontally to make it smaller or use the Responsive Design Mode. The thing is, every so often, they render a page differently. Which should I trust and why would there be a difference?

Neither one will reproduce bugs/quirks in real devices accurately :ssh:

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Munkeymon posted:

Neither one will reproduce bugs/quirks in real devices accurately :ssh:

It's still a hell of a lot better than only looking at things on your 4K iMac and saying "should look fine on a small screen, right?" though.

IronDoge
Nov 6, 2008

If you really want to put effort into without buying an iPhone I suppose you could always load up xCode's emulator and try browsing from there. Can't say it's ever been worth the effort though.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Is there a way to make mobile phones show the character BLACK HEART SUIT U+2665 (♥) and also the other suits (♦♣♠) in a way that they can be colored with CSS?

Coloring those characters worked fine on Windows 10 in Firefox and Chrome, but on my Android phone heart and diamond are red and club and spade are black. Because in 2016 everything is an emoji.

Sereri
Sep 30, 2008

awwwrigami

The easiest might be to make your own icon-font with icomoon or something like that.

YO MAMA HEAD
Sep 11, 2007

Wheany posted:

Is there a way to make mobile phones show the character BLACK HEART SUIT U+2665 (♥) and also the other suits (♦♣♠) in a way that they can be colored with CSS?

Coloring those characters worked fine on Windows 10 in Firefox and Chrome, but on my Android phone heart and diamond are red and club and spade are black. Because in 2016 everything is an emoji.

You can try forcing the text variant with FE0E: http://mts.io/2015/04/21/unicode-symbol-render-text-emoji/

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Wheany posted:

Is there a way to make mobile phones show the character BLACK HEART SUIT U+2665 (♥) and also the other suits (♦♣♠) in a way that they can be colored with CSS?

Coloring those characters worked fine on Windows 10 in Firefox and Chrome, but on my Android phone heart and diamond are red and club and spade are black. Because in 2016 everything is an emoji.

Cool, ipad is even worse, the graphics don't even scale with the font size

YO MAMA HEAD
Sep 11, 2007

Wheany posted:

Is there a way to make mobile phones show the character BLACK HEART SUIT U+2665 (♥︎) and also the other suits (♦♣♠) in a way that they can be colored with CSS?

Coloring those characters worked fine on Windows 10 in Firefox and Chrome, but on my Android phone heart and diamond are red and club and spade are black. Because in 2016 everything is an emoji.

Does this work? ♥︎

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

YO MAMA HEAD posted:

Does this work? ♥︎

Not in Awful at least

Adbot
ADBOT LOVES YOU

Anony Mouse
Jan 30, 2005

A name means nothing on the battlefield. After a week, no one has a name.
Lipstick Apathy

Sereri posted:

The easiest might be to make your own icon-font with icomoon or something like that.
Seconding this, icomoon is awesome for any kind of icons you might need. You can size and color them like fonts (because they are fonts) and they have a pretty good selection.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply