seoscribe / jsearch

jsearch: a drop-in library for client-side search if you don't have a back-end.
BSD 3-Clause Clear License
2 stars 1 forks source link

Iframe needs to resize to suit contents #9

Open wnda opened 7 years ago

wnda commented 7 years ago

Continued from #4 :

Styling is okay, but we need a means to adjust the sizing of the iframe when the search bar opens and when the results are displayed.

It's not difficult, we just need to decide on the proper event to trigger the resize. I'm thinking:

submit - resizes iframe to accommodate results display click - resizes iframe to accommodate (or not) search bar.

artmilt commented 7 years ago

Are we putting the event listener within the iframe global context or in the top global context?

artmilt commented 7 years ago

Can't edit on phone.

I can do this one if you want.

wnda commented 7 years ago

Oh, you do exist! I was beginning to wonder if you were still up for it.

Please feel free, just follow my conventions if you don't mind. I suggest you have a read through the prior issues and review the source code to see where we're up to.

In jsearch.iframe.js you'll see that we're injecting the Javascript as a string using encodeURIComponent and then creating a Blob URL. It's not pretty, but this way it works self-contained i.e. no additional HTTP request is required.

The code that is currently being injected is technically a few commits behind where jsearch.js core is up to, but you can work with the jsearch.iframe.js script and just get it resizing appropriately.

Remember it needs to be responsive, full screen coverage on mobile and standard sort of widget sizing on desktop, I mean 25% width of screen sort of thing, maybe a max-width of 300px. We want it to look neat.

Lois and I have been blogging and covering some SEO/marketing basics to get started. I didn't mention any content writing to you because I wasn't sure how you would feel about it — I anticipated that you would have no interest in that side of things. You're of course welcome to contribute if you want.

If you have any questions or if you need anything, don't raise an issue, just go to Gitter. I'll invite you to the dev channel. I'm trying to keep our internal chatter there.

loisatwood commented 7 years ago

welcome aboard arthur.

@wnda you didn't answer arthur's question; @artmilt i guess that's something we need to do from inside the iframe using window.postMessage

wnda commented 7 years ago

@loisatwood @artmilt Sorry about that, I didn't notice the first message!

Lois is right, we could use postMessage to send a signal to resize the iframe from the top level context, that would probably be the best and easiest way.

wnda commented 7 years ago

I'll let you two come up with a way to do this nice and smoothly while I work on the finer points of how I think the widget should look.