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
Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

kedo posted:

Yeah I have it bookmarked but I'm several thousand posts behind since on the whole I haven't really been giving much attention to modern frameworks, let alone threads about them.

Speaking of staying organized... does anyone have a favorite article or two about the subject I could read? I feel like I want to break my application out into partials (or whatever they're called for React), but I don't know a smart/common way to do that.

Don't overthink it, components are just components, no matter how small or big. You can organise them in folders however you like.

The standard boilerplate I've used for building many a full site in React is:

atoms
molecules
templates

Sort of like atomic design, but I've also had a decent experience building with features as the point of organisation, coupled with a shared folder for all the small atom like components that get used near everywhere.

The thing to recognise is where you're relying on jsx to build out a complex Dom structure, when you probably should've been breaking out clearly reusable components.

Have a good template for new components in your editor of choice so when you want a new component it's quick and easy to do, that way you won't resist building new components due to boilerplate friction.

This is an old blog post but a good one:

http://shripadk.github.io/react/docs/thinking-in-react.html

Adbot
ADBOT LOVES YOU

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I prefer to structure my components into areas of functionality and pages. Directories such as 'page-messages', 'page-accounts', and subdirectories within those. I feel like there's too much emphasis made on component re-usability. When in 90% of cases I've experienced, they are never re-used anywhere.

kedo
Nov 27, 2007

Maluco Marinero posted:

Don't overthink it, components are just components, no matter how small or big. You can organise them in folders however you like.

The standard boilerplate I've used for building many a full site in React is:

atoms
molecules
templates

Sort of like atomic design, but I've also had a decent experience building with features as the point of organisation, coupled with a shared folder for all the small atom like components that get used near everywhere.

The thing to recognise is where you're relying on jsx to build out a complex Dom structure, when you probably should've been breaking out clearly reusable components.

Have a good template for new components in your editor of choice so when you want a new component it's quick and easy to do, that way you won't resist building new components due to boilerplate friction.

This is an old blog post but a good one:

http://shripadk.github.io/react/docs/thinking-in-react.html

This is all good advice, and that article is a good read. However I guess what I'm looking for are some opinionated, practical guides on how to organize the actual file and directory hierarchy. For example, if my application has two main functions, searching for widgets and displaying full widget details, should the components for these two items be broken out into... individual files? Directories? Applications? What's the smartest/best way to link them together? Straight up imports?

In the past most of my JS has lived in a single file (main.js) and was organized using a module pattern along the lines of what's discussed here. But now that I'm putting a lot more code in JS, I feel like using one file simply won't work in the long term.

For the sake of comparison, when I'm writing SCSS I have three main sub-directories in my scss directory: base, modules, and components. Base has code for basic html elements, modules contain mixins and tools and things that don't output CSS, and components contains individual SCSS files for the building blocks of the site (eg. search might be one file, _search.scss, or maybe two at most, _search-form.scss and _search-results.scss) and vendor files. I then have a main.scss file where I import everything.

Right now my structure is from create-react-app, so it's really just two JS files – App.js and index.js in the /src/ directory.

Thermopyle
Jul 1, 2003

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

Nolgthorn posted:

I prefer to structure my components into areas of functionality and pages. Directories such as 'page-messages', 'page-accounts', and subdirectories within those. I feel like there's too much emphasis made on component re-usability. When in 90% of cases I've experienced, they are never re-used anywhere.

The purpose of writing components for re-usability is not actually re-usability.

It's so you develop a clear contract for the components external interface which helps you reason about your system bettererrer.

Ruggan
Feb 20, 2007
WHAT THAT SMELL LIKE?!


fletcher posted:

Words about commit process.

Ok so that is all well and good for application code with well written tests. I agree that your approach makes sense.

Maybe this is the wrong thread, but how do you guys handle versioning databases, if at all? This has always been a pain point and I've never found a good way. Approaches I've seen using Version Control (VC):

- VC scripts that represent the structure of the database. This is stuff like create scripts for tables, stored procedures, views. It also sometimes includes insert scripts for enum data in definition tables. Where this falls short is migration - nothing about these scripts helps you apply changes from dev to testing to production, or to revert a change that was made.

- VC migration scripts that change the state of the database. When you run the script it applies changes. Often times these are paired with the inverse operation to reverse a change. Where this falls short is that it doesn't allow reverting destructive changes to data (for instance, restoring a dropped column doesn't bring its data back). It's also often the Wild West for coding syntax and style as migration scripts are really really hard to auto generate for all weird edge cases.

- VC a god forsaken mix of the two above. For instance, a script might contain a table definition with a bunch of IF NOT EXISTS (select column) ALTER TABLE garbage. Enough of these changes and it's spaghetti. Falls short on a mix of the above issues.

I would really love to hear how other large companies handle versioning databases in a robust, testable, trackable, clean way. Or even how you write good test scripts for database operations.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Kedo, lemme talk about how we do components, obviously not the only way, but it's served us well.

Typically we break everything out, one folder per publicly used component, by publicly used I mean, other classes can make use of the component. For example we'd have a Button component, we'd do this:

front-end/ui/atoms/Button
index.js (entry point JavaScript)
index.less (entry point CSS)
Button.react.js (React component)
Button.client.js (client running code if this is a server side rendering component, exposed to index.js)
Button.less (style sheet)

A more complex component might be:

front-end/ui/molecules/FeaturedProduct
index.js (entry point JavaScript)
index.less (entry point css)
FeaturedProduct.react.js (Main component exposed in index.js)
DisplayMeta.react.js (sub component that is NOT exposed to the index.js)
FeaturedProduct.less
DisplayMeta.less

The whole point here is you encapsulate whatever you want in the component folders, and then things that depend on it have a standard require path, namely the index.js or index.less.

This makes it real simple to contain your shame rather than letting it bleed into other stuff. This is complemented with an approach to CSS that's fairly strict BEM. With a modern CSS transpire language like less, sass or stylus you can require as many times as you like but only render the CSS once, which is great for making the CSS require dependencies just like the JavaScript does.

Either way, this is all contingent on good tooling, so learn you some webpack and have a play around if you haven't already.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

Ruggan posted:

I would really love to hear how other large companies handle versioning databases in a robust, testable, trackable, clean way. Or even how you write good test scripts for database operations.

Not a large company, but a few jobs ago, we kept database schema changes as plain old regular SQL text files on disk, included with the application source. We had a specific naming format to avoid collisions, grouped in directories by release number. They'd get reviewed and merged along with the rest of the code with any change, and rolled out at the same time as new code. Once the file is "run" successfully, the success would be noted in the database itself, and that file would be skipped on the next run. The tool could also actually run scripts in the language of the project that followed the same naming format, a feature we ended up using often to tie together complex changes that couldn't be condensed into static SQL.

We were able to have each dev environment updated every day with last night's live database backup, and had scripts available to the dev that would reimport the backup, in whole or in part, as needed. This is basically the killer feature, especially if you're doing data manipulation as part of the update instead of (just) schema migrations. We were using MySQL, so we couldn't rely on transactions alone. MySQL doesn't let you wrap schema changes in transactions and makes each schema change an implicit commit.

The main problem we had with this setup was having developers accidentally allow their dev instance to have local database changes that weren't merged upstream, or, worse, when they aren't merging in changes from upstream. This can result in changes that are logically and syntactically correct (thus passing initial review) but that ended up bombing when run on a pristine copy of trunk with a fresh database. This is, in reality, more of a version control and procedural problem than a problem with the actual database migration feature, but it's really the only thing that we ever really had trouble with.

All of this was accomplished through a few simple scripts, less than a thousand lines of code total, some in shell, some in the main language of the project. It was developed in-house at a time when the language we used simply had no migration tooling at all, and was rewritten refactored a few times over the years to make sure that it was well maintained and well understood by the entire team.

In the modern era, we'd be using an ORM and so we'd end up basically being forced to use whatever migration tool the ORM provides. This would be best practice, and it's what you should be looking at doing if you're able. That said, don't apply an ORM to an existing codebase, you will find yourself in hell with no escape.

McGlockenshire fucked around with this message at 04:23 on Oct 19, 2017

Thermopyle
Jul 1, 2003

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

The problem with database migrations isn't the migrations, it's different migrations in different branches.

Alligator
Jun 10, 2009

LOCK AND LOAF

Scaramouche posted:

I don't know about "right" necessarily but pre-edge IE was relatively picky about headers compared to the others. Maybe that is right really, one of our suppliers sites will serve up every non-html file as a jpg. Zip file? jpg. PNG? jpg. PDF? jpg. Chrome seemed smart enough to figure it out but maybe that's not something the browser should be assuming.
Nah I looked into it further, the spec was updated to say that only "script like" and style requests should be affected by the nosniff stuff because of it breaking images. Chrome and FF respect that and will happily sniff the content type of images.

https://fetch.spec.whatwg.org/#should-response-to-request-be-blocked-due-to-nosniff?

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

kedo posted:

Question for you React-savvy folks. How dumb is it to build only part of a site with React, and is that even possible/recommended?

I'm not what I would call react savvy, but I can tell you this is absolutely fine and if a) you're working on something legacy or b) you are new to react, there's absolutely nothing wrong with taking things one component at a time.

One thing I'm not sure on, and maybe others can offer suggestions, is how this works in terms of filesystem structure. Where do the client side source files go, vs. client side distribution files? I'm thinking in terms of an ASP.NET MVC project for example. Where do you situate your npm pipeline poo poo?

putin is a cunt fucked around with this message at 12:24 on Oct 19, 2017

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

kedo posted:

Yeah I have it bookmarked but I'm several thousand posts behind since on the whole I haven't really been giving much attention to modern frameworks, let alone threads about them.

Speaking of staying organized... does anyone have a favorite article or two about the subject I could read? I feel like I want to break my application out into partials (or whatever they're called for React), but I don't know a smart/common way to do that.

Others have made good suggestions on organization, but I'll post mine too! The important thing is that whatever you pick, it works for you! Mine is evolving, but I think I'm getting pretty close...

I do something along the lines of:

code:
/
  build/ -- generated things go here
  src/
    index.js -- entry point
    createStore.js -- do redux stuff
    components/
      app/ -- components tightly coupled to the app / one offs
        ButtPage/
           index.js
           style.scss
        SpecificThing/
           index.js
           style.scss
           subcomponentOnlyUsedInSpecficThing.js
      common/ -- components used in several places
        Button/
           index.js
           style.scss
        Heading/
           index.js
           style.scss
    redux/ -- I use something like "ducks" here
      index.js -- only imports others and consolidates them
      auth/ -- state branch
        index.js
      posts/ -- state branch
        index.js
    services/ -- holds code that fetches data
    utility/ -- helper functions and formatters and stuff used in many places

kedo
Nov 27, 2007

Thanks all! Maluco Marinero and Lumpy – those structures both look solid to me. I think my biggest issue for awhile is that I'm not going to be making purely React applications: most of my business is referral and I've done a lot of static or WordPress work, so I'll likely keep getting a more of that. I suppose eventually I could dive into the WP REST API and start making my WP sites entirely in React, but that's a ways down the road I think. But for the time being I feel like there's going to necessarily be come cross contamination between, say, my WP theme CSS and my React CSS, which is unfortunate.

But regardless, I can at least use one of these styles for my search app. Thank you both again for the super helpful posts.

I probably need to start looking into Redux as well.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

kedo posted:

Thanks all! Maluco Marinero and Lumpy – those structures both look solid to me. I think my biggest issue for awhile is that I'm not going to be making purely React applications: most of my business is referral and I've done a lot of static or WordPress work, so I'll likely keep getting a more of that. I suppose eventually I could dive into the WP REST API and start making my WP sites entirely in React, but that's a ways down the road I think. But for the time being I feel like there's going to necessarily be come cross contamination between, say, my WP theme CSS and my React CSS, which is unfortunate.

But regardless, I can at least use one of these styles for my search app. Thank you both again for the super helpful posts.

I probably need to start looking into Redux as well.

Look at Redux, but don't use it until you hit a wall with "normal" React. It's something good to be familiar with both conceptually and practically, but until things get "big" it can add complexity where you don't need it. And when you do start using it, make some good macros; Redux-based code is pretty verbose. That is actually one of the things like like about it, but all my snipmate shortcuts save me a lot of time.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
How the hell do i make a select form required, but have a disabled default value at the same time?

Couldn’t figure out the React way to do it

geeves
Sep 16, 2004

Thermopyle posted:

The purpose of writing components for re-usability is not actually re-usability.

It's so you develop a clear contract for the components external interface which helps you reason about your system bettererrer.

This. We've been trying to implement a pattern library to make sure that everyone uses what they should use for it. The caveat: Product decides: Yes! But it must also do or look like X!''

kedo posted:

Question for you React-savvy folks. How dumb is it to build only part of a site with React, and is that even possible/recommended?

Recommended to me in the Agilefall thread: The Strangler Pattern

I'm not react-savvy (working on it), but we are introducing React to our framework right now. I don't find it dumb at all. It's once piece of stateless, unactionable data. It is simply a view with a handful of toggles. I think it's a perfect gateway into something new (regardless of framework).

How I've demonstrated it to the rest of our team is two-fold:

I took a highly complex and over-engineered page and simplified it using React.

I reconstructed our permission-based navigation into React and also simplified it moving from JSP to React.

I did a side-by-side breakdown with my boss and boss' boss and nobody raised an objection. Granted these changes are not in production or have been through QA, but it's there. If we had regressive functional tests in place this nav update could be dropped in within a sprint or two.

Adding react to other random pieces - why not? It's just a view controller. If I wanted to do Component X in react without interrupted anything else I could. Maybe some legacy code needs a small change to call React's api to work but I think that's okay.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Grump posted:

How the hell do i make a select form required, but have a disabled default value at the same time?

Couldn’t figure out the React way to do it

Same way you do it regular like?

JavaScript code:
<select value={ this.props.theValueOrSomething } onChange={ ... }>
    <option selected disabled value="">Pick a thing, jerk!</option>  
    { this.props.options.map( _o => <option value={ _o }>{ _o}</option> ) }
</select>

Munkeymon
Aug 14, 2003

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



Lumpy posted:

Same way you do it regular like?

JavaScript code:
<select value={ this.props.theValueOrSomething } onChange={ ... }>
    <option selected disabled value="">Pick a thing, jerk!</option>  
    { this.props.options.map( _o => <option value={ _o }>{ _o}</option> ) }
</select>

Wouldn't you have to gate the selected on your default value to allow something else to be selected ever?
code:
<option { this.props.theVauleOrSomething == null ? "selected" : "" } disabled value="">Pick...

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Munkeymon posted:

Wouldn't you have to gate the selected on your default value to allow something else to be selected ever?
code:
<option { this.props.theVauleOrSomething == null ? "selected" : "" } disabled value="">Pick...

Nope, React will take care of it. On my phone, but I did a code pen before I posted that to make sure it still worked.

kedo
Nov 27, 2007

React 16 (and maybe 15, I have no idea!) throws a warning if you use the "selected" attribute on an option, it wants you to do it via defaultProps.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

kedo posted:

React 16 (and maybe 15, I have no idea!) throws a warning if you use the "selected" attribute on an option, it wants you to do it via defaultProps.

Warnings schmorinings! Worked on 15 fine. If it bugs you, just make it not disabled, but have your changed handler not update if they pick that option so they can never select it again.

Munkeymon
Aug 14, 2003

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



Lumpy posted:

Warnings schmorinings! Worked on 15 fine. If it bugs you, just make it not disabled, but have your changed handler not update if they pick that option so they can never select it again.

selected+disabled is a common recommendation for usability because it's screen reader friendly

melon cat
Jan 21, 2010

Nap Ghost
I hope this is the right place to ask. I'm working off of this HTML 5 template. All I'm trying to do is replace that diamond icon with the company's .PNG logo, but can't for the life of me get their PNG logo to stay centred and responsive, properly. The diamond isn't a locally-stored image, so I can't just replace its filepath with the proper image. Any thoughts on what I might be doing wrong? Not sure if I'm giving you guys enough info to work off of- let me know if I'm not.

melon cat fucked around with this message at 03:40 on Jan 16, 2024

Giga Gaia
May 2, 2006

360 kickflip to... Meteo?!
At 736px they opted to put hard heights and widths on their logo div. Get rid of that or change it to closely match what you want your logo size to be.

https://gyazo.com/5039002531262f0c1e425fcbc22c3ebb

Also, ID based CSS selectors. Shameful.

melon cat
Jan 21, 2010

Nap Ghost

Giga Gaia posted:

At 736px they opted to put hard heights and widths on their logo div. Get rid of that or change it to closely match what you want your logo size to be.

https://gyazo.com/5039002531262f0c1e425fcbc22c3ebb

Also, ID based CSS selectors. Shameful.

Thanks a lot for the pointers. I made your suggested edits to the best of my (admittedly very limited) capabilities. Seems to be working, from what I can see? But I have noticed a bit of a jitter in the logo + background graphic when it loads in a non-maximized browser window. It kind of "bumps" to the left upon appearing before settling in the centre. Maybe I have to mess with the margin values, or something.

EDIT: I think I fixed the jitter. The .PNG logo's dimensions were too large. Shrunk it down. Seems to work.

melon cat fucked around with this message at 20:26 on Feb 4, 2024

Giga Gaia
May 2, 2006

360 kickflip to... Meteo?!
You're still gonna run into responsive problems my dude. You gotta fix that CSS in the 736px media query for #header .logo or your stuff is always gonna go out of whack when that query hits. I'd just remove it entirely for now. All of it was there to control the diamond's size.

You also don't need that span around the img tag. They were just using a span because the demo had an icon font to make that diamond happen. Images have their own height and widths so all the css being applied to control those is irrelevant in this case. There's reasons to use width: 100% (though for me max-width: 100% and appropriately sized images is always better) height: auto on images, just not in this case. div.logo is already pos: relative so you're not gaining anything from that being on the span either.

This template has some strange choices being made under the CSS hood.

Giga Gaia fucked around with this message at 00:56 on Oct 22, 2017

Chenghiz
Feb 14, 2007

WHITE WHALE
HOLY GRAIL

Ruggan posted:

Ok so that is all well and good for application code with well written tests. I agree that your approach makes sense.

Maybe this is the wrong thread, but how do you guys handle versioning databases, if at all? This has always been a pain point and I've never found a good way. (...)

I would really love to hear how other large companies handle versioning databases in a robust, testable, trackable, clean way. Or even how you write good test scripts for database operations.

This may be a useless answer depending on your ecosystem, but at work we use SQL Server, and Visual Studio allows you to define your database in a project and generate migration scripts against a given database or just create a new one. It's great because the step of compiling helps you find bad references and you can migrate from any existing schema to your latest. Everything's just flat files so it's easy to put in version control and the diffs are useful, too. I'm not aware of any other solutions that are as good.

Ruggan
Feb 20, 2007
WHAT THAT SMELL LIKE?!


Chenghiz posted:

This may be a useless answer depending on your ecosystem, but at work we use SQL Server, and Visual Studio allows you to define your database in a project and generate migration scripts against a given database or just create a new one. It's great because the step of compiling helps you find bad references and you can migrate from any existing schema to your latest. Everything's just flat files so it's easy to put in version control and the diffs are useful, too. I'm not aware of any other solutions that are as good.

SQL Server and Visual Studio too. So I need to do more research on that. Thanks.

Munkeymon
Aug 14, 2003

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



Ruggan posted:

SQL Server and Visual Studio too. So I need to do more research on that. Thanks.

The place I started at ~six months ago is the first Microsoft shop I've been in that has a database project and it's so loving nice I never want to go back. Only issue is that it's an extra step when going from checkout to running a local copy but it makes database changes so much less annoying that I can't be bothered to be mad about it.

melon cat
Jan 21, 2010

Nap Ghost

Giga Gaia posted:

You're still gonna run into responsive problems my dude. You gotta fix that CSS in the 736px media query for #header .logo or your stuff is always gonna go out of whack when that query hits. I'd just remove it entirely for now. All of it was there to control the diamond's size.

You also don't need that span around the img tag. They were just using a span because the demo had an icon font to make that diamond happen. Images have their own height and widths so all the css being applied to control those is irrelevant in this case. There's reasons to use width: 100% (though for me max-width: 100% and appropriately sized images is always better) height: auto on images, just not in this case. div.logo is already pos: relative so you're not gaining anything from that being on the span either.

This template has some strange choices being made under the CSS hood.
Thanks for the pointers. I implemented everything you suggested and it all seems to be working great.

Next step is to find a way to add in a responsive video portfolio gallery. So glad to have got that logo issue sorted out. :)

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Munkeymon posted:

The place I started at ~six months ago is the first Microsoft shop I've been in that has a database project and it's so loving nice I never want to go back. Only issue is that it's an extra step when going from checkout to running a local copy but it makes database changes so much less annoying that I can't be bothered to be mad about it.

Yeah when it works, MSSQL has some great stuff for portability like this. That said, I still remember tearing my hear out in the past over trimming log files and posting stuck transactions, but it does seem better now. That's more an administrator concern than a developer one anyway.

Giga Gaia
May 2, 2006

360 kickflip to... Meteo?!

melon cat posted:

Thanks for the pointers. I implemented everything you suggested and it all seems to be working great.

Next step is to find a way to add in a responsive video portfolio gallery. So glad to have got that logo issue sorted out. :)

No problem.

I don't know of any out of the box responsive video galleries, but there's lots of techniques out there for responsive videos. Take a look at CSS Trick's "fun with viewport units" article for an example.

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.
I am using react-bootstrap's tool tips. I have a table and sometimes the data for a cell is way too long so I ellipsis it and allow a user ot hover to read it all.

The problem is, if using the center placement of the tooltip things get wonky when there is any overflow. Because I am wrapping my content in a span so the overflow trigger will center over the content of the cell and not just the entire cell (otherwise it looks weird), when there is an overflow it still tries to center over the span, even though the span is much much wider than the actual visibile content, so the "centered" tooltip ends up being very far outside the cell to its right.

How can I fix this? Wrapping the span in a div andusing that as the overlay trigger means that the tooltip is always centered with regards to the cell and not the content of the cell meaning on smaller content that doesn't fill out the cell, the tooltip is now hovering over empty space.

my bony fealty
Oct 1, 2008

One of my sites wants to do more ecommerce and has probably outgrown the hosting plan it's on, which is a basic VPS. It's a WordPress site using WooCommerce. The main concern is that the current hosting can't handle very many concurrent users, and they expect to get 500 - 1000 people trying to hit products at the same time when new items are launched. Any suggestions for hosting solutions that can handle that kind of simultaneous traffic? Is AWS something I should look into here? Thanks fellas.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Knifegrab posted:

I am using react-bootstrap's tool tips. I have a table and sometimes the data for a cell is way too long so I ellipsis it and allow a user ot hover to read it all.

The problem is, if using the center placement of the tooltip things get wonky when there is any overflow. Because I am wrapping my content in a span so the overflow trigger will center over the content of the cell and not just the entire cell (otherwise it looks weird), when there is an overflow it still tries to center over the span, even though the span is much much wider than the actual visibile content, so the "centered" tooltip ends up being very far outside the cell to its right.

How can I fix this? Wrapping the span in a div andusing that as the overlay trigger means that the tooltip is always centered with regards to the cell and not the content of the cell meaning on smaller content that doesn't fill out the cell, the tooltip is now hovering over empty space.

If you don't care about it being pretty, put it all in a title attribute.

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.

Lumpy posted:

If you don't care about it being pretty, put it all in a title attribute.

I do care about it being pretty but yeah this has crossed my mind.

melon cat
Jan 21, 2010

Nap Ghost
On the topic of responsive video players- I'm trying to make embedded videos viewable on my site's 'Video' section. A weird thing's happening, though. If I play the video, then 'X' out the window while the video's playing, the audio still plays even though the window is closed.

Any thoughts on what I can do to fix this?

Here's the code for that window + embedded iframe:

code:
        <article id="videos">

            <h2 class="videos">Our Work</h2>

            <iframe width="345" height="194" src="https://www.youtube.com/embed/meBbDqAXago" frameborder="0" allowfullscreen></iframe>

                <p>Adipiscing magna ...</p>

                <p>Nullam et orci ...</p>

        </article>

melon cat fucked around with this message at 20:29 on Feb 4, 2024

my bony fealty
Oct 1, 2008


The X appears to be closing the modal window by changing its display style and class, but not doing anything to the video itself. So you need to tell the close button to also turn off the video.

The quick and dirty way to do it is by making the close button set the video src to blank, which may not work for you since you'll have to then reset the src via another event if you want to go back to the video without reloading the page.

The other way is to use the Youtube JS api commands to properly stop it; to do this you will have to add ?enablejsapi=1 to the end of the video URL.

Here's both methods demonstrated:

https://jsfiddle.net/z99oudkg/1/

melon cat
Jan 21, 2010

Nap Ghost

my bony fealty posted:

The X appears to be closing the modal window by changing its display style and class, but not doing anything to the video itself. So you need to tell the close button to also turn off the video.

The quick and dirty way to do it is by making the close button set the video src to blank, which may not work for you since you'll have to then reset the src via another event if you want to go back to the video without reloading the page.
Tried that, and that's exactly what happened. It killed the video source food good, up until the next browser refresh. :(

quote:

The other way is to use the Youtube JS api commands to properly stop it; to do this you will have to add ?enablejsapi=1 to the end of the video URL.
Just to clarify- simply add "?enablejsapi=1" to the end of the iframe video URL so it becomes:

?

I added that snippet the URL, but it had no effect at all. Maybe I didn't follow your instructions properly.

In either case, it's starting to sound like an embed link may not be best-suited for modal windows. Maybe I'll just add in a thumbnail image and hyperlink it to the actual YouTube video. :shrug:

melon cat fucked around with this message at 20:30 on Feb 4, 2024

Main Paineframe
Oct 27, 2010

melon cat posted:

I added that snippet the URL, but it had no effect at all. Maybe I didn't follow your instructions properly.

In either case, it's starting to sound like an embed link may not be best-suited for modal windows. Maybe I'll just add in a thumbnail image and hyperlink it to the actual YouTube video. :shrug:

That snippet just gives you the ability to control the video by triggering the YouTube API. You still need to add the actual Javascript to invoke the YT API to tell the video to stop; go look at Youtube's documentation for what exactly to do there.

Basically, just hiding the container the video is in doesn't make the video stop. The video is hidden, but it doesn't actually know it's hidden, so it won't stop automatically - it's up to you to use Javascript to either stop the video or remove the video.

Adbot
ADBOT LOVES YOU

McGlockenshire
Dec 16, 2005

GOLLOCKS!

my bony fealty posted:

One of my sites wants to do more ecommerce and has probably outgrown the hosting plan it's on, which is a basic VPS. It's a WordPress site using WooCommerce. The main concern is that the current hosting can't handle very many concurrent users, and they expect to get 500 - 1000 people trying to hit products at the same time when new items are launched. Any suggestions for hosting solutions that can handle that kind of simultaneous traffic? Is AWS something I should look into here? Thanks fellas.
Are those numbers in concurrent connections, concurrent users, or just some number pulled out of a hat? 500 concurrent users engaging in normal ecommerce activity is going to average out to a few requests a second, and if you're struggling to serve that on a CPU-heavy enough VPS with Wordpress then something has gone very wrong, especially if you're running it under PHP7. On the other hand, if you're expecting 500 concurrent connections, what are you doing hosting that kind of Wordpress site on only one VPS?

if you're only expecting some vague form of traffic, it's time to measure everything that you can. Make sure you can monitor and log performance on the server at the application level, at the web server daemon level, at the PHP level, at the MySQL level, at the disk I/O level, at the CPU level, at the network connection level. If you're getting slammed, you should be able to easily tell where the bottleneck is by monitoring the server, so you can figure out what exactly to take action on. Do not simply throw more hardware resources at the site without knowing that it'll help a specific problem.

If performance is normally not a concern and they're sending out newsletters or somesuch and they expect an immediate burst of traffic, your priority becomes doing as much as you can to stop users from hitting CPU-heavy application pages. One way to do this would be adding a caching proxy server in front. You can do this yourself (pain in the rear end) or use Cloudflare's higher level paid plans (quick, easy, and probably a NSA front :tinfoil:). Alternatively, see if it would be possible to direct as much incoming traffic as possible to regular plain old static HTML pages. I know there are static site generators for Wordpress, but I don't know that any of them work with woocommerce pages. Look at WP Super Cache if you have to.

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