Skip to content

Commit 123b58e

Browse files
committed
Working on two options, They need to be tested
1 parent 701df85 commit 123b58e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+383
-15
lines changed

.eslintrc-react.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:react/recommended",
9+
"plugin:prettier/recommended",
10+
"plugin:tailwindcss/recommended"
11+
],
12+
"parserOptions": {
13+
"ecmaFeatures": {
14+
"jsx": true
15+
},
16+
"ecmaVersion": 13,
17+
"sourceType": "module"
18+
},
19+
"plugins": [
20+
"react"
21+
],
22+
"rules": {
23+
"react/react-in-jsx-scope": "on"
24+
}
25+
}

.eslintrc-vue.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"plugin:vue/essential",
8+
"eslint:recommended",
9+
"plugin:prettier/recommended",
10+
"plugin:tailwindcss/recommended"
11+
],
12+
"parserOptions": {
13+
"ecmaVersion": 12,
14+
"sourceType": "module"
15+
},
16+
"plugins": [
17+
"vue"
18+
],
19+
"rules": {
20+
}
21+
}

app-react/assets/config/manifest.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//= link_tree ../images
2+
//= link_directory ../stylesheets .css
File renamed without changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* This is a manifest file that'll be compiled into application.css, which will include all the files
3+
* listed below.
4+
*
5+
* Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
6+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
7+
*
8+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
9+
* compiled file so the styles you add here take precedence over styles defined in any other CSS
10+
* files in this directory. Styles in this file should be added after the last require_* statement.
11+
* It is generally better to create a new file per style scope.
12+
*
13+
*= require_tree .
14+
*= require_self
15+
*/
File renamed without changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
3+
export default function Home() {
4+
return (
5+
<>
6+
<h3>This is the homepage component</h3>
7+
<h6>You can find me in: <span className="px-2 py-1 bg-slate-100">frontend/components/views/home.jsx</span></h6>
8+
</>
9+
)
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import "./main.scss";
2+
3+
import React, {createElement} from 'react';
4+
import { createRoot } from 'react-dom/client';
5+
import App from '@/components/views/home';
6+
7+
const domContainer = document.querySelector('#home');
8+
const root = createRoot(domContainer);
9+
root.render(createElement(App));
File renamed without changes.

app-react/helpers/tag_helpers.rb

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# frozen_string_literal: true
2+
3+
# Public: Allows to render HTML tags for scripts and styles processed by Vite.
4+
module ViteRails::TagHelpers
5+
# Public: Renders a script tag for vite/client to enable HMR in development.
6+
def vite_client_tag
7+
return unless src = vite_manifest.vite_client_src
8+
9+
tag.script(src: src, type: 'module')
10+
end
11+
12+
# Public: Renders a script tag to enable HMR with React Refresh.
13+
def vite_react_refresh_tag
14+
vite_manifest.react_refresh_preamble&.html_safe
15+
end
16+
17+
# Public: Resolves the path for the specified Vite asset.
18+
#
19+
# Example:
20+
# <%= vite_asset_path 'calendar.css' %> # => "/vite/assets/calendar-1016838bab065ae1e122.css"
21+
def vite_asset_path(name, **options)
22+
path_to_asset vite_manifest.path_for(name, **options)
23+
end
24+
25+
# Public: Renders a <script> tag for the specified Vite entrypoints.
26+
def vite_javascript_tag(*names,
27+
type: 'module',
28+
asset_type: :javascript,
29+
skip_preload_tags: false,
30+
skip_style_tags: false,
31+
crossorigin: 'anonymous',
32+
media: 'screen',
33+
**options)
34+
entries = vite_manifest.resolve_entries(*names, type: asset_type)
35+
tags = javascript_include_tag(*entries.fetch(:scripts), crossorigin: crossorigin, type: type, extname: false, **options)
36+
tags << vite_preload_tag(*entries.fetch(:imports), crossorigin: crossorigin, **options) unless skip_preload_tags
37+
tags << stylesheet_link_tag(*entries.fetch(:stylesheets), media: media, **options) unless skip_style_tags
38+
tags
39+
end
40+
41+
# Public: Renders a <script> tag for the specified Vite entrypoints.
42+
def vite_typescript_tag(*names, **options)
43+
vite_javascript_tag(*names, asset_type: :typescript, **options)
44+
end
45+
46+
# Public: Renders a <link> tag for the specified Vite entrypoints.
47+
def vite_stylesheet_tag(*names, **options)
48+
style_paths = names.map { |name| vite_asset_path(name, type: :stylesheet) }
49+
stylesheet_link_tag(*style_paths, **options)
50+
end
51+
52+
# Public: Renders an <img> tag for the specified Vite asset.
53+
def vite_image_tag(name, **options)
54+
if options[:srcset] && !options[:srcset].is_a?(String)
55+
options[:srcset] = options[:srcset].map do |src_name, size|
56+
"#{ vite_asset_path(src_name) } #{ size }"
57+
end.join(', ')
58+
end
59+
60+
image_tag(vite_asset_path(name), options)
61+
end
62+
63+
private
64+
65+
# Internal: Returns the current manifest loaded by Vite Ruby.
66+
def vite_manifest
67+
ViteRuby.instance.manifest
68+
end
69+
70+
# Internal: Renders a modulepreload link tag.
71+
def vite_preload_tag(*sources, crossorigin:, **options)
72+
sources.map { |source|
73+
href = path_to_asset(source)
74+
try(:request).try(:send_early_hints, 'Link' => %(<#{ href }>; rel=modulepreload; as=script; crossorigin=#{ crossorigin }))
75+
tag.link(rel: 'modulepreload', href: href, as: 'script', crossorigin: crossorigin, **options)
76+
}.join("\n").html_safe
77+
end
78+
end
File renamed without changes.
File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>RailsReactVite</title>
5+
<meta name="viewport" content="width=device-width,initial-scale=1">
6+
<%= csrf_meta_tags %>
7+
<%= csp_meta_tag %>
8+
9+
<%= stylesheet_link_tag "application" %>
10+
<%= vite_client_tag %>
11+
<%= vite_javascript_tag 'application' %>
12+
<%= vite_react_refresh_tag %>
13+
</head>
14+
15+
<body>
16+
<main class="container mx-auto mt-28 px-5 flex flex-col">
17+
<%= yield %>
18+
</main>
19+
</body>
20+
</html>

app-react/views/pages/home.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<h1>Pages#home</h1>
2+
<p>Find me in app/views/pages/home.html.erb</p>
3+
<hr class="my-8">
4+
<div id="home"></div>
File renamed without changes.

app-vue/assets/images/.keep

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ApplicationCable
2+
class Channel < ActionCable::Channel::Base
3+
end
4+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ApplicationCable
2+
class Connection < ActionCable::Connection::Base
3+
end
4+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationController < ActionController::Base
2+
end

app-vue/controllers/concerns/.keep

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class PagesController < ApplicationController
2+
def home
3+
end
4+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@import "tailwindcss/base";
2+
@import "tailwindcss/components";
3+
4+
@import "./stylesheets/global";
5+
6+
@import "tailwindcss/utilities";
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
html {
2+
scroll-behavior: smooth;
3+
}
4+
5+
body {
6+
@apply text-base text-slate-800 leading-5 bg-gray-50;
7+
}
8+
9+
h1 {
10+
font-size: 2.75em;
11+
}
12+
13+
h2 {
14+
font-size: 2.25em;
15+
}
16+
17+
h3 {
18+
font-size: 2em;
19+
}
20+
21+
h4 {
22+
font-size: 1.625em;
23+
}
24+
25+
h5 {
26+
font-size: 1.25em;
27+
}
28+
29+
h6 {
30+
font-size: 1.125em;
31+
}
32+
33+
p {
34+
font-size: 1em;
35+
margin-bottom: 10px;
36+
}
37+
38+
h1, h2, h3, h4, h5, h6, button, a, label{
39+
@apply font-sans;
40+
}
41+
42+
h1, h2, h3, h4, h5, h6 {
43+
@apply leading-tight;
44+
}
45+
46+
h1, h2, h3 {
47+
@apply font-bold;
48+
}
49+
50+
@media screen and (max-width: 767px){
51+
h1 {
52+
font-size: 2em;
53+
}
54+
55+
h2 {
56+
font-size: 1.875em;
57+
}
58+
59+
h3 {
60+
font-size: 1.75em;
61+
}
62+
63+
h4 {
64+
font-size: 1.5em;
65+
}
66+
67+
h5 {
68+
font-size: 1.375em;
69+
}
70+
}
71+
72+
img, svg {
73+
@apply w-full h-auto;
74+
}
75+
76+
.main {
77+
@apply flex flex-col h-screen;
78+
}
79+
80+
.wrapper {
81+
@apply flex-1 relative;
82+
}
83+
84+
.container {
85+
width: 95%;
86+
@apply mx-auto py-10;
87+
}

app-vue/helpers/application_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end

app-vue/helpers/pages_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module PagesHelper
2+
end

app-vue/jobs/application_job.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ApplicationJob < ActiveJob::Base
2+
# Automatically retry jobs that encountered a deadlock
3+
# retry_on ActiveRecord::Deadlocked
4+
5+
# Most jobs are safe to ignore if the underlying records are no longer available
6+
# discard_on ActiveJob::DeserializationError
7+
end

app-vue/mailers/application_mailer.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class ApplicationMailer < ActionMailer::Base
2+
default from: "[email protected]"
3+
layout "mailer"
4+
end

app-vue/models/application_record.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ApplicationRecord < ActiveRecord::Base
2+
primary_abstract_class
3+
end

app-vue/models/concerns/.keep

Whitespace-only changes.

app-vue/views/layouts/mailer.html.erb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5+
<style>
6+
/* Email styles need to be inline */
7+
</style>
8+
</head>
9+
10+
<body>
11+
<%= yield %>
12+
</body>
13+
</html>

app-vue/views/layouts/mailer.text.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= yield %>
File renamed without changes.

app/.DS_Store

-8 KB
Binary file not shown.

app/assets/.DS_Store

-6 KB
Binary file not shown.

app/frontend/.DS_Store

-6 KB
Binary file not shown.

app/views/.DS_Store

-6 KB
Binary file not shown.

jsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
"sourceMap": true,
1010
"strict": true,
1111
"paths": {
12-
"@/*": ["./app/*"],
13-
"~/*": ["./app/frontend/*"]
12+
"@/*": ["app/*"],
13+
"@/component*": ["app/frontend/components/*"]
1414
}
1515
},
16-
"include": ["app/**/*"],
16+
"include": ["app/**/*", "app/frontend/components/*"],
1717
"exclude": [
1818
"**/dist",
1919
"**/node_modules",

0 commit comments

Comments
 (0)