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
RobertKerans
Aug 25, 2006

There is a heppy lend
Fur, fur aw-a-a-ay.

Tei posted:

Can you make the mouse change to arrow on-hover?

https://output.jsbin.com/warahaquri/1

I don't quite see how what you want is logically possible: if you move the cursor over the image, you are by definition hovering, so
code:
.card { cursor: arrow; }
is all you need. You can't change it on hover because you are already hovering, it makes no sense to have a different cursor for the image and the image hover state because w/r/t the cursor property, that's exactly the same thing

Adbot
ADBOT LOVES YOU

Tei
Feb 19, 2011

Interesting enough the arrow is show when I click the mouse on my iphone.

I guess safari is emulating the onhover with a tap.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Tei posted:

Interesting enough the arrow is show when I click the mouse on my iphone.

I guess safari is emulating the onhover with a tap.

Yep. Elements with a :hover on them get that state with the first tap so all the CSS based menus work on phones.

kedo
Nov 27, 2007

I'm working on a site that's going to be built with React on the front end driven by MongoDB on the back, but I need some basic CMS functionality (ie. creating/modifying posts, flexible custom fields on those posts, user/account functionality). I'll also likely be using NodeBB for comments on posts – I'd like to offer threading, bookmarking, etc. and haven't found many CMS options that include that sort of functionality out of the box.

I'm curious if anyone has a suggestion for the CMS portion? Keystone seems like an option, but I know little about it.

huhu
Feb 24, 2006

kedo posted:

I'm working on a site that's going to be built with React on the front end driven by MongoDB on the back, but I need some basic CMS functionality (ie. creating/modifying posts, flexible custom fields on those posts, user/account functionality). I'll also likely be using NodeBB for comments on posts – I'd like to offer threading, bookmarking, etc. and haven't found many CMS options that include that sort of functionality out of the box.

I'm curious if anyone has a suggestion for the CMS portion? Keystone seems like an option, but I know little about it.

What languages would you be comfortable using for the CMS?

kedo
Nov 27, 2007

I'm trying to do as much of it in JS as possible because I'm treating this as a learning opportunity. Right now I use JS purely on the front end, so I'm curious how it feels to use it on the backend as well.

PHP would also be fine as the vast majority of my work deals with PHP and WordPress, but I'm trying to move away from that here, if I can.

uncle blog
Nov 18, 2012

I'm building a React app that I'm currently running locally with a Node server. It's just for learning purposes, so it will never be deployed anywhere. The trouble is that I'm trying to get some data from an open API, but the browser blocks it because no 'Access-Control-Allow-Origin' header is present on the requested resource. I'm guessing this is to block browsers to get the data? Would I be able to access it from some sort of back-end? If so, can I simulate it on my machine?

huhu
Feb 24, 2006

uncle blog posted:

I'm building a React app that I'm currently running locally with a Node server. It's just for learning purposes, so it will never be deployed anywhere. The trouble is that I'm trying to get some data from an open API, but the browser blocks it because no 'Access-Control-Allow-Origin' header is present on the requested resource. I'm guessing this is to block browsers to get the data? Would I be able to access it from some sort of back-end? If so, can I simulate it on my machine?

Is the blocking happening at your API or the public API you're using?

If it's your API, start here: https://expressjs.com/en/resources/middleware/cors.html

If it's not, unless I'm misunderstanding, it sounds like a bad API.

spiritual bypass
Feb 19, 2008

Grimey Drawer
You could probably use some local proxy to get around the CORS thing, but I don't have any specifics suggestions at hand

uncle blog
Nov 18, 2012

It's on a public API. So this is not common? I managed to get around it using a proxy, but this feels like cheating.


Edit:
I can get the data with a CURL request in Terminal, but not with the fetch command in Node.js.

spiritual bypass
Feb 19, 2008

Grimey Drawer
CORS is a basic security feature of the browser. Check out the MDN page for a better description than I could give.

uncle blog
Nov 18, 2012

I understand what it is, and that the API needs headers to allow cross origin requests (like mine are). I just don't understand if this is common on public API's, and if so, how am I supposed to access it?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
If it's an api that you're supposed to use from your backend instead of directly calling from the user's browser, then they're not going to make it callable from browsers.

You'll need to structure your app so that your server makes the calls, and exposes its own api to your React app with the results.

uncle blog
Nov 18, 2012

Thanks guys. Learned a bunch of new stuff, and even made it work in the end.

prom candy
Dec 16, 2005

Only I may dance
So after a week of issues I'm off windows and back on my Mac again. I really want Windows dev to work for me and maybe I'm going about it in the wrong way (trying to bring over all my workflows from MacOS) but I was just running into issue after issue:

1. Couldn't find a terminal emulator that did everything I wanted: render utf8/powerline fonts, worked nicely with tmux incl. mouse mode. Tried Hyper, Ubuntu.exe, cmder.

2. zsh kept hanging after command execution. Not all the time, usually ctrl-c a couple times worked, but not always.

3. Ran into issues a couple times where webpack-dev-server would just stop responding at all. Restarting it didn't fix, the only thing that worked was running it again on a new port. So it was like there was a ghost process.

4. Docker seemed to have file permission errors. When I would connect to the app running my Rails server it wasn't outputting anything (normally rails server is noisy as hell) and would frequently not write anything to the log folder. Now and then it would just refuse to start and say it couldn't see the log folder.

I dunno if I should give up on running WSL and try installing node etc. directly to Windows. I need Docker to work but the permissions issues might've also been related to being installed/mounted through a windows drive that's also on WSL? It sounds like there's a bunch of you in this thread who have long term web dev experience on Windows, any suggestions?

bigmandan
Sep 11, 2001

lol internet
College Slice

prom candy posted:

So after a week of issues I'm off windows and back on my Mac again. I really want Windows dev to work for me and maybe I'm going about it in the wrong way (trying to bring over all my workflows from MacOS) but I was just running into issue after issue:

1. Couldn't find a terminal emulator that did everything I wanted: render utf8/powerline fonts, worked nicely with tmux incl. mouse mode. Tried Hyper, Ubuntu.exe, cmder.

2. zsh kept hanging after command execution. Not all the time, usually ctrl-c a couple times worked, but not always.

3. Ran into issues a couple times where webpack-dev-server would just stop responding at all. Restarting it didn't fix, the only thing that worked was running it again on a new port. So it was like there was a ghost process.

4. Docker seemed to have file permission errors. When I would connect to the app running my Rails server it wasn't outputting anything (normally rails server is noisy as hell) and would frequently not write anything to the log folder. Now and then it would just refuse to start and say it couldn't see the log folder.

I dunno if I should give up on running WSL and try installing node etc. directly to Windows. I need Docker to work but the permissions issues might've also been related to being installed/mounted through a windows drive that's also on WSL? It sounds like there's a bunch of you in this thread who have long term web dev experience on Windows, any suggestions?

You could use a VM (Virtual Box or VMware) and a shared folder. You could also automate setup and tear down of the VM with Vagrant if you need to have a VM configuration shared.

Tei
Feb 19, 2011

I like things from Windows. At least from Windows 2000, not sure about modern versions.

The use of space, snappiness of Windows 2000, the pragmatic rendering of fonts.

Windows XP and later versions diluted that by a lot, so I am not sure if is the same OS. They have evolved the OS to be a consumer OS, good to launch Office and do some minor menial work.

The average windows user never open a 1MB text file.

Is not optimized for us, web developers, more like optimized away from us, to a different set of users.

Is okay if you don't find Windows work for your dev time.

prom candy
Dec 16, 2005

Only I may dance
I've played around with Virtual Machines before, I think at that point I'd rather dual boot to Linux (but I also don't really want to do that because I've never been able to consistently run and enjoy Linux.) I ran Vagrant on my Mac for a while and the shared filesystem thing was a constant source of headaches. Appreciate the suggestion though.

Munkeymon
Aug 14, 2003

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



bigmandan posted:

You could use a VM (Virtual Box or VMware) and a shared folder. You could also automate setup and tear down of the VM with Vagrant if you need to have a VM configuration shared.

Docker should work with Virtual Box on Windows with maybe a little configuration legwork. IIRC it worked no problem with HyperV, but a lot of containers didn't or something like that? It's been a few years since I tried. Never tried it with WSL, but it wouldn't surprise me much if the subsystem didn't have great access to virtualization features.

e: oh you meant for a desktop dev environment nevermind

The Fool
Oct 16, 2003


Use docker for Windows, not Linux docker in wsl

bigmandan
Sep 11, 2001

lol internet
College Slice

prom candy posted:

I've played around with Virtual Machines before, I think at that point I'd rather dual boot to Linux (but I also don't really want to do that because I've never been able to consistently run and enjoy Linux.) I ran Vagrant on my Mac for a while and the shared filesystem thing was a constant source of headaches. Appreciate the suggestion though.

Majority of the headaches for shared folders in Windows can be eliminated with a few tweaks:

- Make sure you can create symlinks
- "VBoxManage.exe setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1"
- Make sure the user that runs virtual box is allowed to make links (use secpol.msc and look for 'Create symbolic links' under 'User Right's assignment')

- Modify LMHOSTS file to speed up access

code:
255.255.255.255        VBOXSVR #PRE
255.255.255.255        VBOXSRV #PRE
- make sure the guest drivers are installed and up to date.


I've been using Virtual Box with shared folders for quite a long time now and with the tweaks above I've rarely run into issues. Disk access can still be a tad sluggish sometimes but not an issue for my dev workflow. I hear the VMware shared folder drivers is faster, but not enough for me to shell out the money for a workstation license.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
This post is over a year old now but it goes into some detail about how far Windows is coming along.

https://char.gd/blog/2017/how-to-set-up-the-perfect-modern-dev-environment-on-windows

I'm starting to get more and more interested in switching. Macbooks have been getting absurd in their price to performance ratios, and Windows machines are getting pretty good by comparison. Also the operating system is languishing on mac, it seems like they've developed nothing but iOS for a decade.

Sooner or later they're probably going to replace macOS with iOS.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

prom candy posted:

So after a week of issues I'm off windows and back on my Mac again. I really want Windows dev to work for me and maybe I'm going about it in the wrong way (trying to bring over all my workflows from MacOS) but I was just running into issue after issue:

1. Couldn't find a terminal emulator that did everything I wanted: render utf8/powerline fonts, worked nicely with tmux incl. mouse mode. Tried Hyper, Ubuntu.exe, cmder.

I use mouse in tmux and use powerline fonts in cmdr. I didn't do anything special for this other than follow the cmdr wiki to install the powerline stuff, so I don't know how to help you on this.

prom candy posted:

2. zsh kept hanging after command execution. Not all the time, usually ctrl-c a couple times worked, but not always.

I guess this was in WSL? I can't say anything about zsh, but I don't have any problem with this in bash/WSL.

prom candy posted:

3. Ran into issues a couple times where webpack-dev-server would just stop responding at all. Restarting it didn't fix, the only thing that worked was running it again on a new port. So it was like there was a ghost process.

I haven't encountered this.

prom candy posted:

4. Docker seemed to have file permission errors. When I would connect to the app running my Rails server it wasn't outputting anything (normally rails server is noisy as hell) and would frequently not write anything to the log folder. Now and then it would just refuse to start and say it couldn't see the log folder.

Yeah, this isn't normal.

prom candy posted:

I dunno if I should give up on running WSL and try installing node etc. directly to Windows. I need Docker to work but the permissions issues might've also been related to being installed/mounted through a windows drive that's also on WSL? It sounds like there's a bunch of you in this thread who have long term web dev experience on Windows, any suggestions?

Yes, my suggestion is don't use WSL unless you really need it for something (for one thing, WSL is slower than not-WSL for different tasks. It's getting better as they keep working on it...). To do web dev work on Windows you have to just install the stuff.

Install node the windows way, install docker the windows way, etc.

Another thing is that you should get used to powershell. It's pretty good (and also bad...like all shells).

prom candy
Dec 16, 2005

Only I may dance
Thanks for all the suggestions. I think some of the issues must just be from copying my dotfiles repo that I've only ever used on Mac and probably causing poo poo not to work so I think I might blow that away and try installing windows packages like you said instead of trying to do everything in WSL land. What's your typical workflow Thermopyle? When do you use Powershell and when do you use bash?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

prom candy posted:

Thanks for all the suggestions. I think some of the issues must just be from copying my dotfiles repo that I've only ever used on Mac and probably causing poo poo not to work so I think I might blow that away and try installing windows packages like you said instead of trying to do everything in WSL land. What's your typical workflow Thermopyle? When do you use Powershell and when do you use bash?

  • For the purposes of web development I work in my IDE (PyCharm aka WebStorm).
  • I keep 1+ Powershell terminals open in Cmder (which is using the powerline prompt as described in the Cmder wiki).
  • I alternate between running my dev server via my IDE's ability to run NPM scripts and running them in a terminal window.
  • When I need postgres or other services running, I just docker run whatever is needed to spin it up.
  • Now that I think about it I think I have node installed via nvm-windows, but I could just have installed Node via node's regular installer, because I never switch node versions.

Bash/WSL doesn't really enter into my typical workflow. I only use it when I come across something like a bash script that I want to run.

Basically, it all works just like it did when I was running Ubuntu instead of Windows except I use powershell instead of bash.

The Fool
Oct 16, 2003


The only time I'm using bash in windows is when I need to manually run certbot, practically everything else I need is from node or python and runs just fine in windows.

prom candy
Dec 16, 2005

Only I may dance
Okay cool, I'm going to give that set up a try when I have some more time to mess around with it. Thanks and sorry for hijacking the thread all weekend

tankadillo
Aug 15, 2006

I’m looking to play around with making static sites in Node; is there any package in particular that stands out? I tried some stuff with Metalsmith which doesn’t seem very robust but it looks easy to hack and customize, which I like. I also recently learned about Eleventy, but I haven’t tried yet.

I don’t want to use React or any other framework like that.

The Fool
Oct 16, 2003


Gatsby is super popular, but uses React.

Maybe Hugo? https://gohugo.io/

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Why not just html if it's static. If it's semi static what about rendering out some mustache using restify or express.

prom candy
Dec 16, 2005

Only I may dance
So I ended up trying out Tailwind on a simple little app we were extracting from our main project. No idea how well it would scale on a huge product but man does it ever make building components fast. Not having to jump back and forth between CSS and markup, or come up with a name for every stupid little element that needs some styling is really nice.

my bony fealty
Oct 1, 2008

every day is a constant struggle to resist spending hours rewriting/reorganizing stuff while I should be working on new features. today I am reorganizing all of my styled components directory and import/export structure how about you.

huhu
Feb 24, 2006
My company calls for 25% refactor time so while we're writing new features, we keep in mind the code that annoys us most and that gets queued for refactoring next. Good way to balance feature work and tech debt.

We're refactoring our main React app file which reached almost 500 lines. Got it down to 60 lines and have a nice tree structure of its dependencies nested underneath it.

Feels good.

Doom Mathematic
Sep 2, 2008

huhu posted:

My company calls for 25% refactor time so while we're writing new features, we keep in mind the code that annoys us most and that gets queued for refactoring next. Good way to balance feature work and tech debt.

Oh, that sounds like heaven. I've been advocating for a similar proportion of time spent where I work but it's never going to happen. The list of stuff customers are asking for is too long.

my bony fealty
Oct 1, 2008

yeah that's a great policy to have in place. modern JS frontends can get really long and ugly really fast, especially React as it doesn't really prescribe any best practices or code structure. even if you have the whole thing mapped out before writing any code it still is likely you will encounter decisions about structure not initially thought of.

I moved a context provider today to its own thing instead of living in a parent component for example and its already helped by eliminating an unmounted component memory leak bug. constantly refactoring stuff does have its perks, I'm lucky in that I can use my time however so long as deadlines are met so I have lots of time to do so.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
Our only QA guy quit, so I spent today fixing end-to-end tests.

As if I know what I'm doing :qq:

Tei
Feb 19, 2011

One source of horrible code is when you ask somebody to write something complex that is over his head. And he/she still manage somehow to complete it.

Since the code was written by somebody that literally had no idea what he/she was doing, the result is ugly and convulated, hard to follow, hard to fix, hard to maintain.

Many good programmers have this skill, we have this skill, we can write anything people can ask us, but the result qualities vary.
Then I have seen the oposite, people that flat out reject to write something that the can't write. Is almost a better skill looking back. Except the people that say no, normally ends moving away to other things.

huhu posted:

My company calls for 25% refactor time so while we're writing new features, we keep in mind the code that annoys us most and that gets queued for refactoring next. Good way to balance feature work and tech debt.

We're refactoring our main React app file which reached almost 500 lines. Got it down to 60 lines and have a nice tree structure of its dependencies nested underneath it.

Feels good.

:-O

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Something about refactoring other people's code is a horrible experience compared to refactoring your own code which is bliss and I could spend all day doing it forever.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Good code is modular and made to be refactored while bad code depends on globally mutable magic strings

Adbot
ADBOT LOVES YOU

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender

Nolgthorn posted:

Something about refactoring other people's code is a horrible experience
I get stressed doing this because I'm trying not to cause the original author to feel sad (or worse, mad) because I'm very publicly doing something better with their code than they did.

And it also sucks to have to write a justification for the refactor. Making (say) code more testable is an easy sell, but fixing up horrid "cosmetic" issues like bad variable names can really rankle people.

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