Code Monkey home page Code Monkey logo

rails-turbo-vue's People

Contributors

dependabot[bot] avatar joekrump avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rails-turbo-vue's Issues

๐Ÿ’ก idea for loading vue components on pages

  • create a script that gets loaded in the app layout
    • it registers a turbo:load event listener
    • The handler calls a method that checks a map containing keys which are the current path, and returns an array of arrays looking something like this. Where the first element is the selector for the mount point for some Vue component, and the second is the component to mount.
    • It then calls createApp() and .mount() using those values.
      {
         '/': [['#app-mount', App], ['#app-sidebar', Sidebar]]
      }

Server-side render Vue components?

Open questions

  1. Is it possible to fetch the template from the rails server using an html endpoint which renders the view that maybe written in .html.erb and also has Vue directive markup on it? Ex.
<!-- show.html.erb -->

<template>
  <h1><%= model.name %></h1>
  <button @click="doSomething">Click me!</button>
</template>
  • Where would the doSomething function be defined in this case?

Psuedocode

Here's a rough idea based on my understanding so far

// hit an endpoint on the rails server that renders the `show.html.erb` _(see above)_
const res = await fetch('/model/show.html')

Vue.createApp({
  template: await res.text(), // https://developer.mozilla.org/en-US/docs/Web/API/Response/text
  // Something here to define the doSomething function?
})
  1. Is it valid to include <script> tags with imports, etc within the .html.erb file that is rendered and then processed by Vue as the template option passed to createApp?

Ex. Could I do this?

<!-- show.html.erb -->

<template>
  <h1><%= model.name %></h1>
  <button @click="doSomething">Click me!</button>
</template>

<script setup>
  const doSomething = () => {
    alert("Hello world!")
  };
</script>

Update view_with_vue generator

  • Only generate what's necessary
    • no minitest generation
    • no index.ts file
  • Update what is generated
    • Entry into app/frontend/helpers/route-helper.ts
    • File name that is generated is not generic "App"
    • Basic rspec system test with basic navigation test and check for content
    • Basic vitest component test
  • (stretch) Update the generator test to be an rspec test

Allow skipping generating route and/or controller with view_with_vue generator

This could be handy in cases where a view already exists because it was already generated by something such as the scaffold generator.

If a person wants to just replace the index view with a view that uses Vue.js for part of its rendering, then they may not want to have a new route entry defined (since one already exists) or a new controller method (since that already exists too)

Run screenshot test in a separate github actions job

  • Running screenshot tests on the same OS as the reference screenshots were run on can help ensure the screenshot comparisons are more similar. Ex. run screenshot tests on MacOS
  • Probably want to still run the rests of the RSpec test suite on an environment more similar to a production one (linux)

Splitting out the screenshot tests can allow this. It would also allow for independent scaling of the runner for the screenshot tests if those tests end up running slow compared with other RSpec tests.

The approach would involve having a new spec directory, something like spec/screenshot_specs that could then be ignored when the rest of the RSpec suite is run. This could be done using the --pattern cmd line arg

If a dynamic component import fails, try loading the updated file

Why?

This helps in cases where a user is on a page with some stale JS and they load a page and it tries to fetch a Vue component that loads async but uses a state file name or path.

What?

Use the manifest.json file that is output by Rollup to get the path/filename for the new Vue component and try to load that.

404 for precompiled assets

Hey, I've used this app as template for my own app. So far everything was great and smooth, but once I tried to deploy to prod server I'm getting 404 on any assets. The assets:precompile works great, and assets put into public/vite/assets folder. However when opening app via browser, any assets on such url https://domain.com/vite/assets/application-d671fe8c.css just returns 404. Any ideas where should I look at or what did I miss? I use Capistrano for deployment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.