Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Vue example#49

Open
zajonc-gugle wants to merge 18 commits intomasterfrom
vue-example
Open

Vue example#49
zajonc-gugle wants to merge 18 commits intomasterfrom
vue-example

Conversation

@zajonc-gugle
Copy link

It took me quite a while, but I've finally managed to find some time and provide a sample of a frontend app written 100% in Vue.js.
Long story short, I've been trying to rewrite what you guys have implemented in vanilla HTML + CSS + js and pack it into a single page app (except for a few places where I was a bit too lazy to do things exactly as I should). Some things are mocked out, so don't expect the whole app to work - it's just a client making fake requests to a fake service.

Lessons learned:

  • Vue is kinda cool
  • CSS is just black magic
  • I'm really bad at time management

It's probably not going to too useful, but in case you've come to hate frontend development because of all that manual HTML and CSS management, well, here's how it's done (in a simplified form) these days. Some things are much easier this way, there's still plenty of things to drive people crazy, but, all in all, it's a bit more manageable and, most importantly, you can write unit tests.

Either way - don't worry too much about this PR - it can hang here forever. I just had some spare time during Christmas so I've decided to finally send a PR I've been talking about.

P.S. Happy new Year!

Introduce an additional abstraction (service.js) that takes care of
communication between the JS client and the Java server. The main reason
to introduce it is to allow mocking the service - this way we can run a
frontend app locally, even if the Java backend is down.

The *real* reason is that I haven't managed to start the Google App
Engine, because I forgot my security key, so I'm hacking things to
unblock myself.
vue-router is responsible for Client Side Rendering in Vue apps.
This bit is critical to having multiple urls handled by the same Single
Page App - instead of trying to fetch a new html file for each url, the
app will ask the router which component it should render.
- redirect to SearchResults after submitting the form
- fetch data on query update
- render returned results
Icons are usually taken from some public repository, integrated with the
framework.
[Fontawesome](https://fontawesome.com/icons) is probably the most
popular one.
Adding some CSS, Vue-style.
I tried to replicate the original CSS, at least to some extent. I've
simplified things a little bit (i.e. I've used 1 background pic instead
of 2).

Pardon my CSS - I'm definitely not an expert.
To be honest, I have no idea what I'm doing. But it looks ok, imo.
Home uses a slighlty different layout - the search bar is located below
below the text, because it's the main element on the page.
In all other views the search bar functions as a navigation element, so
we put it on the very top.
The component is registered in main.js - as a result, it's not
accessible when we render App directly.
Use the `stubs` property to mock it.
@grenlayk
Copy link
Contributor

Nice to hear from u!
I will look through it during winter holidays (at least, I hope so)

P.S. Happy New Year to you too!)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants