diff --git a/Gemfile b/Gemfile
index d4383c2..c909951 100644
--- a/Gemfile
+++ b/Gemfile
@@ -36,10 +36,6 @@ gem 'faker'
# Front-end
gem 'slim-rails', '~> 3.6', '>= 3.6.3'
-gem 'dry-initializer', '~> 3.1'
-gem 'dry-types', '~> 1.7', '>= 1.7.2'
-gem 'view_component', '~> 3.17'
-gem 'view_component-contrib', '~> 0.2.3'
gem 'simple_form'
# Pagination
@@ -63,7 +59,6 @@ group :development do
gem 'bundler-audit', require: false
gem 'lefthook'
gem 'letter_opener'
- gem 'lookbook'
gem 'pgcli-rails'
gem 'rubocop', require: false
gem 'rubocop-factory_bot', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index 12e8fec..8d32345 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -114,8 +114,6 @@ GEM
bigdecimal
rexml
crass (1.0.6)
- css_parser (1.19.1)
- addressable
date (3.3.4)
debug (1.9.2)
irb (~> 1.10)
@@ -131,22 +129,6 @@ GEM
dotenv (3.1.4)
drb (2.2.1)
dry-cli (1.2.0)
- dry-core (1.0.1)
- concurrent-ruby (~> 1.0)
- zeitwerk (~> 2.6)
- dry-inflector (1.1.0)
- dry-initializer (3.1.1)
- dry-logic (1.5.0)
- concurrent-ruby (~> 1.0)
- dry-core (~> 1.0, < 2)
- zeitwerk (~> 2.6)
- dry-types (1.7.2)
- bigdecimal (~> 3.0)
- concurrent-ruby (~> 1.0)
- dry-core (~> 1.0)
- dry-inflector (~> 1.0)
- dry-logic (~> 1.4)
- zeitwerk (~> 2.6)
enumerize (2.8.1)
activesupport (>= 3.2)
erubi (1.13.0)
@@ -185,8 +167,6 @@ GEM
railties (>= 3.1)
hashdiff (1.1.1)
hashie (5.0.0)
- htmlbeautifier (1.4.3)
- htmlentities (4.3.4)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
image_processing (1.13.0)
@@ -210,18 +190,6 @@ GEM
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
- lookbook (2.3.2)
- activemodel
- css_parser
- htmlbeautifier (~> 1.3)
- htmlentities (~> 4.3.4)
- marcel (~> 1.0)
- railties (>= 5.0)
- redcarpet (~> 3.5)
- rouge (>= 3.26, < 5.0)
- view_component (>= 2.0)
- yard (~> 0.9)
- zeitwerk (~> 2.5)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
@@ -229,7 +197,6 @@ GEM
net-smtp
marcel (1.0.4)
matrix (0.4.2)
- method_source (1.1.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.25.1)
@@ -355,7 +322,6 @@ GEM
logger
rdoc (6.7.0)
psych (>= 4.0.0)
- redcarpet (3.6.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
@@ -368,7 +334,6 @@ GEM
railties (>= 5.2)
rexml (3.3.8)
rolify (6.0.1)
- rouge (4.4.0)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
@@ -415,7 +380,6 @@ GEM
sorbet-runtime (>= 0.5.10782)
ruby-lsp-rails (0.3.20)
ruby-lsp (>= 0.20.0, < 0.21.0)
- ruby-next-core (1.0.3)
ruby-progressbar (1.13.0)
ruby-vips (2.2.2)
ffi (~> 1.12)
@@ -487,13 +451,6 @@ GEM
vcr (6.3.1)
base64
version_gem (1.1.4)
- view_component (3.17.0)
- activesupport (>= 5.2.0, < 8.0)
- concurrent-ruby (~> 1.0)
- method_source (~> 1.0)
- view_component-contrib (0.2.3)
- ruby-next-core (>= 0.15.0)
- view_component
vite_rails (3.0.17)
railties (>= 5.1, < 8)
vite_ruby (~> 3.0, >= 3.2.2)
@@ -519,7 +476,6 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
- yard (0.9.37)
zeitwerk (2.7.0)
PLATFORMS
@@ -549,8 +505,6 @@ DEPENDENCIES
debug
devise
dotenv (>= 3.0)
- dry-initializer (~> 3.1)
- dry-types (~> 1.7, >= 1.7.2)
enumerize
factory_bot_rails
faker
@@ -558,7 +512,6 @@ DEPENDENCIES
image_processing
lefthook
letter_opener
- lookbook
omniauth-google-oauth2
omniauth-rails_csrf_protection
pagy
@@ -593,8 +546,6 @@ DEPENDENCIES
turbo-rails
tzinfo-data
vcr
- view_component (~> 3.17)
- view_component-contrib (~> 0.2.3)
vite_rails (~> 3.0)
web-console
webmock
diff --git a/README.md b/README.md
index 983ef3f..980ce12 100644
--- a/README.md
+++ b/README.md
@@ -106,9 +106,7 @@ To setup a development environment (MacOS):
### FE references
- DaisyUI:
-- Flowbite:
- For icons: lucide icon packages:
-- View_component (`TODO`): It is only in `beta` version, we advise you to avoid using it. With components from view_component, we can view them at
### Rspec
diff --git a/app/controllers/authentication/sessions_controller.rb b/app/controllers/authentication/sessions_controller.rb
index 9ac05df..2925a13 100644
--- a/app/controllers/authentication/sessions_controller.rb
+++ b/app/controllers/authentication/sessions_controller.rb
@@ -4,6 +4,7 @@ class SessionsController < Devise::SessionsController
def after_sign_in_path_for(resource)
return admin_root_path if resource.admin?
+ return employee_root_path if resource.employee?
stored_location_for(resource) || root_path
end
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index a0ac1f8..53afaa0 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -1,5 +1,8 @@
# frozen_string_literal: true
class HomeController < ApplicationController
- def index; end
+ layout 'application'
+ def index
+ # debugger
+ end
end
diff --git a/app/frontend/components/alert/component.rb b/app/frontend/components/alert/component.rb
deleted file mode 100644
index 183c8a9..0000000
--- a/app/frontend/components/alert/component.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-class Alert::Component < ApplicationViewComponent
- ALERT_TYPES = {
- info: 'alert-info',
- success: 'alert-success',
- warning: 'alert-warning',
- danger: 'alert-danger',
- error: 'alert-error'
- }.freeze
-
- param :text, default: proc { 'Hello!' }
- option :type, default: proc { 'info' }
- option :timer, default: proc { 5000 } # 5 seconds
-
- private
-
- def alert_type
- return 'alert-info' if type.nil?
-
- ALERT_TYPES[type.to_sym]
- end
-
- def alert_icon
- case type
- when 'info'
- 'alert-info.svg'
- when 'success'
- 'alert-check.svg'
- when 'warning'
- 'alert-warning.svg'
- when 'danger', 'error'
- 'alert-error.svg'
- end
- end
-end
diff --git a/app/frontend/components/alert/preview.rb b/app/frontend/components/alert/preview.rb
deleted file mode 100644
index 91f71a1..0000000
--- a/app/frontend/components/alert/preview.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-class Alert::Preview < ApplicationViewComponentPreview
- # You can specify the container class for the default template
- # self.container_class = "w-1/2 border border-gray-300"
-
- def default
- component('alert')
- end
-
- # @param text [String]
- # @param type [String]
- def custom(text: 'Hello!', type: 'error', timer: 3000)
- component('alert', text, type:, timer:)
- end
-end
diff --git a/app/frontend/components/application_view_component.rb b/app/frontend/components/application_view_component.rb
deleted file mode 100644
index 4320b2f..0000000
--- a/app/frontend/components/application_view_component.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-# frozen_string_literal: true
-
-class ApplicationViewComponent < ViewComponentContrib::Base
- extend Dry::Initializer
-
- include ApplicationHelper
- include ViewComponentContrib::StyleVariants
-
- attr_accessor :allow_db_queries, :attributes
- alias allow_db_queries? allow_db_queries
-
- # Move default attrs to a constants so we can re-use it
- EMPTY_ATTRS = {}.freeze
-
- class << self
- def html_option(name, default: nil, **opts)
- if default
- opts[:type] = proc { default.merge(_1) }
- end
-
- # Assuming you have `extend Dry::Initializer`
- option name, default: proc { EMPTY_ATTRS }, **opts
- end
- end
-
- def initialize(*, **options)
- super
- defined_option_keys = self.class.dry_initializer.options.map(&:source)
- self.attributes = options.except(*defined_option_keys)
- end
-
- def dots(opts)
- tag.attributes(**opts)
- end
-
- def klass
- attributes[:class] || ''
- end
-
- def data
- default_data.merge(attributes[:data] || {})
- end
-
- def html_attributes
- attributes.except(:class, :data)
- end
-
- def default_data
- {}
- end
-end
diff --git a/app/frontend/components/application_view_component_preview.rb b/app/frontend/components/application_view_component_preview.rb
deleted file mode 100644
index 64f8330..0000000
--- a/app/frontend/components/application_view_component_preview.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-class ApplicationViewComponentPreview < ViewComponentContrib::Preview::Base
- extend Dry::Initializer
- include ApplicationHelper
-
- self.abstract_class = true
-
- layout 'application'
-end
diff --git a/app/frontend/components/button/component.html.slim b/app/frontend/components/button/component.html.slim
deleted file mode 100644
index 7c0b2be..0000000
--- a/app/frontend/components/button/component.html.slim
+++ /dev/null
@@ -1,7 +0,0 @@
-- case button_kind
-- when :link
- = link_to(url, disabled: disabled, class: classes, **attributes.except(:class, :type), target: open_new?) { content }
-- when :button_to
- = button_to(url, disabled: disabled, method: method, class: classes, **attributes.except(:class, :type), target: open_new?) { content }
-- when :button
- = tag.button(type: type, disabled: disabled, class: classes, **attributes.except(:class, :type)) { content }
diff --git a/app/frontend/components/button/component.rb b/app/frontend/components/button/component.rb
deleted file mode 100644
index 5e1e0c0..0000000
--- a/app/frontend/components/button/component.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-# frozen_string_literal: true
-
-class Button::Component < ApplicationViewComponent
- param :text, default: proc {}
- option :url, optional: true
- option :method, optional: true
- option :variant, default: proc { :primary }
- option :size, default: proc { :md }
- option :block, default: proc { false }
- option :type, default: proc { :button }
- option :disabled, default: proc { false }
- option :outline, default: proc { false }
- option :new_tab, default: proc { false }
-
- style do
- base do
- ['btn']
- end
-
- variants do
- variant do
- primary { ['btn-primary'] }
- secondary { ['btn-secondary'] }
- accent { ['btn-accent'] }
- info { ['btn-info'] }
- success { ['btn-success'] }
- warning { ['btn-warning'] }
- error { ['btn-error'] }
- ghost { ['btn-ghost'] }
- link { ['btn-link'] }
- white { ['bg-white hover:bg-gray-100'] }
- end
-
- size do
- sm { ['btn-sm'] }
- md { ['btn-md'] }
- lg { ['btn-lg'] }
- end
-
- disabled do
- yes { ['btn-disabled'] }
- end
-
- block do
- yes { ['btn-block'] }
- end
-
- outline do
- yes { ['btn-outline'] }
- end
- end
- end
-
- private
-
- def classes
- style(variant:, disabled:, size:, outline:, block:) + klass
- end
-
- def content
- text.presence || super
- end
-
- def button_kind
- return :link if url.present? && default_method?
- return :button_to if url.present? && !default_method?
-
- :button
- end
-
- def default_method?
- method.blank? || method == :get
- end
-
- def open_new?
- new_tab ? '_blank' : false
- end
-end
diff --git a/app/frontend/components/button/preview.rb b/app/frontend/components/button/preview.rb
deleted file mode 100644
index 07d591a..0000000
--- a/app/frontend/components/button/preview.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-class Button::Preview < ApplicationViewComponentPreview
- # You can specify the container class for the default template
- # self.container_class = "w-1/2 border border-gray-300"
-
- # @param text [String]
- # @param url [String]
- # @param method [String]
- # @param variant select { choices: [primary, secondary, accent, info, success, warning, error, ghost, link, white] }
- # @param size select { choices: [sm, md, lg] }
- # @param block [Boolean]
- # @param disabled [Boolean]
- # @param outline [Boolean]
- # @param new_tab [Boolean]
-
- def primary(text: 'hahaha', url: nil, method: nil, variant: :primary,
- size: :sm, block: false, type: :button, disabled: false,
- outline: false, new_tab: false)
- component('button', text, url:, method:, variant:, size:, block:, type:, disabled:, outline:, new_tab:)
- end
-end
diff --git a/app/frontend/components/card/component.html.slim b/app/frontend/components/card/component.html.slim
deleted file mode 100644
index 4ec4069..0000000
--- a/app/frontend/components/card/component.html.slim
+++ /dev/null
@@ -1,9 +0,0 @@
-.card.bg-white.shadow-xl
- .card-body
- - if title
- h2.card-title
- = title
- = content
- - if actions?
- .card-actions.mt-6.flex.justify-end.gap-3
- = actions
diff --git a/app/frontend/components/card/component.rb b/app/frontend/components/card/component.rb
deleted file mode 100644
index 17b2f86..0000000
--- a/app/frontend/components/card/component.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-class Card::Component < ApplicationViewComponent
- option :title, default: proc {}
- renders_one :actions
-end
diff --git a/app/frontend/components/card/preview.rb b/app/frontend/components/card/preview.rb
deleted file mode 100644
index 31fca14..0000000
--- a/app/frontend/components/card/preview.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-class Ui::Card::Preview < ApplicationViewComponentPreview
- # You can specify the container class for the default template
- # self.container_class = "w-1/2 border border-gray-300"
-
- def default; end
-end
diff --git a/app/frontend/components/inputs/label/component.rb b/app/frontend/components/inputs/label/component.rb
deleted file mode 100644
index d70ef9e..0000000
--- a/app/frontend/components/inputs/label/component.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class Inputs::Label::Component < ApplicationViewComponent
- param :name
- option :form_builder
- option :text, optional: true
- option :required, optional: true, default: -> { false }
-
- def call
- form_builder.label(name, text, class: label_classes, **attributes, &content)
- end
-
- private
-
- def label_classes
- class_names('label-text', required:)
- end
-end
diff --git a/app/frontend/components/inputs/label/preview.rb b/app/frontend/components/inputs/label/preview.rb
deleted file mode 100644
index f9643c8..0000000
--- a/app/frontend/components/inputs/label/preview.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-class Inputs::Label::Preview < ApplicationViewComponentPreview
- # You can specify the container class for the default template
- # self.container_class = "w-1/2 border border-gray-300"
-
- def default
- component('Inputs::Label', text: 'Hello!')
- end
-end
diff --git a/app/frontend/components/inputs/select/component.html.slim b/app/frontend/components/inputs/select/component.html.slim
deleted file mode 100644
index ddcd30d..0000000
--- a/app/frontend/components/inputs/select/component.html.slim
+++ /dev/null
@@ -1,14 +0,0 @@
-div class=wrapper_classes
- - if label
- label.label
- = form_builder.label label, class: "label-text"
- = top_right_label
- = form_builder.select name, options, { selected: selected, include_blank: include_blank }, class: field_classes, **attributes
- - if errors
- .label-text.text-error
- = errors
- - elsif hint
- label.label
-
- .label-text
- = hint
diff --git a/app/frontend/components/inputs/select/component.rb b/app/frontend/components/inputs/select/component.rb
deleted file mode 100644
index c33b934..0000000
--- a/app/frontend/components/inputs/select/component.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-class Inputs::Select::Component < ApplicationViewComponent
- renders_one :top_right_label
-
- param :name, optional: true
- option :options, optional: true
- option :form_builder, optional: true
- option :label, optional: true
- option :error, optional: true
- option :hint, optional: true
- option :selected, optional: true
- option :wrapper_class, optional: true
- option :include_blank, optional: true
-
- private
-
- def selected
- return super unless form_builder&.object
-
- form_builder.object[name] || super
- end
-
- def field_classes
- classes = attributes.delete(:class)
- [class_names('select select-bordered w-full bg-white', 'select-error': errors), classes].compact.join(' ')
- end
-
- def wrapper_classes
- wrapper_class
- end
-
- def errors
- return error if error
- return unless form_builder&.object
-
- form_builder.object.errors[name]&.to_sentence&.presence
- end
-end
diff --git a/app/frontend/components/inputs/select/preview.rb b/app/frontend/components/inputs/select/preview.rb
deleted file mode 100644
index d6652b6..0000000
--- a/app/frontend/components/inputs/select/preview.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-class Inputs::Select::Preview < ApplicationViewComponentPreview
- # You can specify the container class for the default template
- # self.container_class = "w-1/2 border border-gray-300"
-
- def default; end
-end
diff --git a/app/frontend/components/inputs/text/component.html.slim b/app/frontend/components/inputs/text/component.html.slim
deleted file mode 100644
index f42dec9..0000000
--- a/app/frontend/components/inputs/text/component.html.slim
+++ /dev/null
@@ -1,14 +0,0 @@
-div class=wrapper_classes
- - if label
- label.label
- = form_builder.label label, class: "label-text"
- = top_right_label
- = form_builder.text_field name, class: field_classes, value: value, **attributes
- - if errors
- .label-text.text-error
- = errors
- - elsif hint
- label.label
-
- .label-text
- = hint
diff --git a/app/frontend/components/inputs/text/component.rb b/app/frontend/components/inputs/text/component.rb
deleted file mode 100644
index 0772d2e..0000000
--- a/app/frontend/components/inputs/text/component.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-class Inputs::Text::Component < ApplicationViewComponent
- renders_one :top_right_label
-
- param :name, optional: true
- option :form_builder, optional: true
- option :label, optional: true
- option :error, optional: true
- option :hint, optional: true
- option :value, optional: true
- option :wrapper_class, optional: true
-
- private
-
- def value
- return super unless form_builder&.object
-
- form_builder.object[name] || super
- end
-
- def field_classes
- classes = attributes.delete(:class)
- [class_names('input input-bordered w-full bg-white', 'input-error': errors), classes].compact.join(' ')
- end
-
- def wrapper_classes
- # attributes.delete(:wrapper_class)
- end
-
- def errors
- return error if error
- return unless form_builder&.object
-
- form_builder.object.errors[name]&.to_sentence&.presence
- end
-end
diff --git a/app/frontend/components/inputs/text/preview.rb b/app/frontend/components/inputs/text/preview.rb
deleted file mode 100644
index 26d2870..0000000
--- a/app/frontend/components/inputs/text/preview.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-class Inputs::Text::Preview < ApplicationViewComponentPreview
- # You can specify the container class for the default template
- # self.container_class = "w-1/2 border border-gray-300"
-
- def default; end
-end
diff --git a/app/frontend/components/inputs/textarea/component.html.slim b/app/frontend/components/inputs/textarea/component.html.slim
deleted file mode 100644
index 2861e9b..0000000
--- a/app/frontend/components/inputs/textarea/component.html.slim
+++ /dev/null
@@ -1,14 +0,0 @@
-div class=wrapper_classes
- - if label
- label.label
- = form_builder.label label, class: "label-text"
- = top_right_label
- = form_builder.text_area name, class: field_classes, value: value, **attributes
- - if error
- .text-error.mt-1
- = error
- - elsif hint
- label.label
-
- .label-text
- = hint
diff --git a/app/frontend/components/inputs/textarea/component.rb b/app/frontend/components/inputs/textarea/component.rb
deleted file mode 100644
index 558ba8b..0000000
--- a/app/frontend/components/inputs/textarea/component.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-class Inputs::Textarea::Component < ApplicationComponent
- renders_one :top_right_label
-
- param :name, optional: true
- option :form_builder, optional: true
- option :label, optional: true
- option :error, optional: true
- option :hint, optional: true
- option :value, optional: true
- option :wrapper_class, optional: true
-
- private
-
- def value
- return super unless form_builder&.object
-
- form_builder.object[name] || super
- end
-
- def field_classes
- classes = attributes.delete(:class)
- [class_names('textarea textarea-bordered w-full', 'input-error': errors), classes].compact.join(' ')
- end
-
- def wrapper_classes
- attributes.delete(:wrapper_class)
- end
-
- def errors
- return error if error
- return unless form_builder&.object
-
- form_builder.object.errors[name]&.to_sentence&.presence
- end
-end
diff --git a/app/frontend/components/inputs/textarea/preview.rb b/app/frontend/components/inputs/textarea/preview.rb
deleted file mode 100644
index 59c4fa5..0000000
--- a/app/frontend/components/inputs/textarea/preview.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-class Inputs::Textarea::Preview < ApplicationViewComponentPreview
- # You can specify the container class for the default template
- # self.container_class = "w-1/2 border border-gray-300"
-
- def default; end
-end
diff --git a/app/frontend/controllers/admin/index.js b/app/frontend/controllers/admin/index.js
index 040f6e5..0f0e98d 100644
--- a/app/frontend/controllers/admin/index.js
+++ b/app/frontend/controllers/admin/index.js
@@ -8,10 +8,6 @@ application.debug = false;
window.Stimulus = application;
const controllers = import.meta.glob('./**/*_controller.js', { eager: true });
-const compControllers = import.meta.glob('../../components/**/*_controller.js', {
- eager: true,
-});
// Register Stimulus controllers
registerControllers(application, controllers);
-registerControllers(application, compControllers);
diff --git a/app/frontend/controllers/application/index.js b/app/frontend/controllers/application/index.js
index 040f6e5..0f0e98d 100644
--- a/app/frontend/controllers/application/index.js
+++ b/app/frontend/controllers/application/index.js
@@ -8,10 +8,6 @@ application.debug = false;
window.Stimulus = application;
const controllers = import.meta.glob('./**/*_controller.js', { eager: true });
-const compControllers = import.meta.glob('../../components/**/*_controller.js', {
- eager: true,
-});
// Register Stimulus controllers
registerControllers(application, controllers);
-registerControllers(application, compControllers);
diff --git a/app/frontend/components/alert/component_controller.js b/app/frontend/controllers/shared/alert_controller.js
similarity index 99%
rename from app/frontend/components/alert/component_controller.js
rename to app/frontend/controllers/shared/alert_controller.js
index b0ddbbc..121d184 100644
--- a/app/frontend/components/alert/component_controller.js
+++ b/app/frontend/controllers/shared/alert_controller.js
@@ -19,6 +19,7 @@ export default class extends Controller {
'opacity-0',
);
}, timeout);
+
// Remove element from DOM after transition
setTimeout(() => {
this.element.remove();
diff --git a/app/frontend/entrypoints/admin.js b/app/frontend/entrypoints/admin.js
index 6bb182b..207199f 100644
--- a/app/frontend/entrypoints/admin.js
+++ b/app/frontend/entrypoints/admin.js
@@ -1,4 +1,4 @@
-import '~/stylesheets/index.scss';
+import '../stylesheets/admin/index.scss';
import '../controllers/admin';
import '../controllers/shared';
import '@hotwired/turbo-rails';
diff --git a/app/frontend/entrypoints/application.js b/app/frontend/entrypoints/application.js
index 43344bf..72ef6bb 100644
--- a/app/frontend/entrypoints/application.js
+++ b/app/frontend/entrypoints/application.js
@@ -1,4 +1,4 @@
-import '~/stylesheets/index.scss';
+import '~/stylesheets/application/index.scss';
import '../controllers/application';
import '../controllers/shared';
import '@hotwired/turbo-rails';
diff --git a/app/frontend/stylesheets/admin/index.scss b/app/frontend/stylesheets/admin/index.scss
new file mode 100644
index 0000000..d91784b
--- /dev/null
+++ b/app/frontend/stylesheets/admin/index.scss
@@ -0,0 +1,4 @@
+@import "../shared/application.tailwind";
+@import "../shared/reset";
+@import "../shared/base";
+@import "../shared/pagy";
diff --git a/app/frontend/stylesheets/application/index.scss b/app/frontend/stylesheets/application/index.scss
new file mode 100644
index 0000000..d91784b
--- /dev/null
+++ b/app/frontend/stylesheets/application/index.scss
@@ -0,0 +1,4 @@
+@import "../shared/application.tailwind";
+@import "../shared/reset";
+@import "../shared/base";
+@import "../shared/pagy";
diff --git a/app/frontend/stylesheets/index.scss b/app/frontend/stylesheets/index.scss
deleted file mode 100644
index d1ed979..0000000
--- a/app/frontend/stylesheets/index.scss
+++ /dev/null
@@ -1,4 +0,0 @@
-@import "./application.tailwind";
-@import "reset";
-@import "base";
-@import "pagy";
diff --git a/app/frontend/stylesheets/application.tailwind.scss b/app/frontend/stylesheets/shared/application.tailwind.scss
similarity index 100%
rename from app/frontend/stylesheets/application.tailwind.scss
rename to app/frontend/stylesheets/shared/application.tailwind.scss
diff --git a/app/frontend/stylesheets/base.scss b/app/frontend/stylesheets/shared/base.scss
similarity index 100%
rename from app/frontend/stylesheets/base.scss
rename to app/frontend/stylesheets/shared/base.scss
diff --git a/app/frontend/stylesheets/pagy.scss b/app/frontend/stylesheets/shared/pagy.scss
similarity index 100%
rename from app/frontend/stylesheets/pagy.scss
rename to app/frontend/stylesheets/shared/pagy.scss
diff --git a/app/frontend/stylesheets/reset.scss b/app/frontend/stylesheets/shared/reset.scss
similarity index 100%
rename from app/frontend/stylesheets/reset.scss
rename to app/frontend/stylesheets/shared/reset.scss
diff --git a/app/models/user.rb b/app/models/user.rb
index 6ef8e0e..a0f2cd3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -56,4 +56,8 @@ def self.from_google(google_params)
def admin?
has_role?(:admin)
end
+
+ def employee?
+ !admin? && has_role?(:employee)
+ end
end
diff --git a/app/views/admin/users/index.html.slim b/app/views/admin/users/index.html.slim
index 0facb7b..f66268e 100644
--- a/app/views/admin/users/index.html.slim
+++ b/app/views/admin/users/index.html.slim
@@ -1,5 +1,4 @@
- provide(:title, "User list")
-= component('alert', 'Hello Admin', type: 'success', timer: 10000)
// Just example
.overflow-x-auto
diff --git a/app/views/home/index.html.slim b/app/views/home/index.html.slim
index a9e12d4..7bbba7a 100644
--- a/app/views/home/index.html.slim
+++ b/app/views/home/index.html.slim
@@ -1,2 +1,2 @@
- provide(:title, "Home")
-= component('alert', 'Welcom to Rails Boilerplate', type: 'success', timer: 10000)
+p hello
diff --git a/app/views/layouts/devise.html.slim b/app/views/layouts/devise.html.slim
index ddc7d7e..bb3cae8 100644
--- a/app/views/layouts/devise.html.slim
+++ b/app/views/layouts/devise.html.slim
@@ -37,23 +37,3 @@ html.h-full.bg-base[lang="en"]
img class="absolute inset-0 w-full h-full bg-top bg-cover object-cover opacity-90 max-w-full" src="#{random_bg.sample}" alt=""
div class="absolute inset-0 bg-gradient-to-t md:bg-gradient-to-r from-base-100 to-transparent w-full" aria-hidden="true"
- .drawer-side
- label.drawer-overlay[for="my-drawer"]
- ul.menu.px-4.py-0.w-80.bg-base-200.text-base-content[data-controller="theme"]
- - themes.each do |theme|
- li
- a tabindex="0" class="after:absolute after:inset-0" data-action="click->theme#switch" data-theme-value="#{theme}"
- = theme.humanize
- div class="flex flex-wrap gap-1 ms-auto" data-theme="#{theme}"
- div class="bg-primary flex aspect-square w-5 items-center justify-center rounded lg:w-6"
- .text-primary-content.text-sm.font-bold
- | A
- div class="bg-secondary flex aspect-square w-5 items-center justify-center rounded lg:w-6"
- .text-secondary-content.text-sm.font-bold
- | A
- div class="bg-accent flex aspect-square w-5 items-center justify-center rounded lg:w-6"
- .text-accent-content.text-sm.font-bold
- | A
- div class="bg-neutral flex aspect-square w-5 items-center justify-center rounded lg:w-6"
- .text-neutral-content.text-sm.font-bold
- | A
diff --git a/app/frontend/components/alert/component.html.slim b/app/views/shared/_alert.html.slim
similarity index 72%
rename from app/frontend/components/alert/component.html.slim
rename to app/views/shared/_alert.html.slim
index f5c695e..b093d6c 100644
--- a/app/frontend/components/alert/component.html.slim
+++ b/app/views/shared/_alert.html.slim
@@ -1,8 +1,8 @@
-.alert[role="alert" class="#{alert_type} #{attributes[:class]}" data-controller="alert--component"]
+.alert[role="alert" class="#{alert_type} #{attributes[:class]}" data-controller="alert"]
= vite_image_tag("images/icons/#{alert_icon}", class: "")
span
= text
- button data-action="click->alert--component#remove" data-timer=timer type="button" class="-m-3 p-3 focus-visible:outline-offset-[-4px]"
+ button data-action="click->alert#remove" data-timer=timer type="button" class="-m-3 p-3 focus-visible:outline-offset-[-4px]"
span class="sr-only" x
svg data-timer=0 class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"
path d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
diff --git a/config/application.rb b/config/application.rb
index 5d61e80..72027b6 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -22,8 +22,6 @@
module RailsBoilerplate
class Application < Rails::Application
- config.autoload_paths << Rails.root.join('app/frontend/components')
- config.view_component.preview_paths << Rails.root.join('app/frontend/components')
# Prevents Rails from trying to eager-load the contents of app/frontend
config.javascript_path = 'frontend'
diff --git a/config/initializers/form_builder_extensions.rb b/config/initializers/form_builder_extensions.rb
deleted file mode 100644
index b87c612..0000000
--- a/config/initializers/form_builder_extensions.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-require 'ui_form_helpers'
-
-ActionView::Helpers::FormBuilder.include UiFormHelpers
diff --git a/config/initializers/view_component.rb b/config/initializers/view_component.rb
deleted file mode 100644
index c134452..0000000
--- a/config/initializers/view_component.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-ActiveSupport.on_load(:view_component) do
- # Extend your preview controller to support authentication and other
- # application-specific stuff
- #
- # Rails.application.config.to_prepare do
- # ViewComponentsController.class_eval do
- # include Authenticated
- # end
- # end
- #
- # Make it possible to store previews in sidecar folders
- # See https://github.com/palkan/view_component-contrib#organizing-components-or-sidecar-pattern-extended
- ViewComponent::Preview.extend ViewComponentContrib::Preview::Sidecarable
- # Enable `self.abstract_class = true` to exclude previews from the list
- ViewComponent::Preview.extend ViewComponentContrib::Preview::Abstract
-end
diff --git a/config/routes.rb b/config/routes.rb
index 0d7b35a..5d1144f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,8 +2,6 @@
Rails.application.routes.draw do
if Rails.env.development?
- mount Lookbook::Engine, at: '/lookbook'
- # ERD
get '/erd', to: 'docs#erd'
end
diff --git a/lib/generators/view_component/USAGE b/lib/generators/view_component/USAGE
deleted file mode 100644
index 2be0603..0000000
--- a/lib/generators/view_component/USAGE
+++ /dev/null
@@ -1,15 +0,0 @@
-Description:
-============
- Creates a new view component, test and preview files.
- Pass the component name, either CamelCased or under_scored, and an optional list of attributes as arguments.
-
-Example:
-========
- bin/rails generate view_component Profile name age
-
- creates a Profile component and test:
- Component: app/frontend/components/profile/component.rb
- Template: app/frontend/components/profile/component.html.slim
- Test: spec/frontend/components/profile_component_spec.rb
- System Test: spec/system/frontend/components/profile_component_spec.rb
- Preview: app/frontend/components/profile/component_preview.rb
diff --git a/lib/generators/view_component/templates/component.html.slim.tt b/lib/generators/view_component/templates/component.html.slim.tt
deleted file mode 100644
index fba820d..0000000
--- a/lib/generators/view_component/templates/component.html.slim.tt
+++ /dev/null
@@ -1 +0,0 @@
-div Add <%= class_name %> template here
diff --git a/lib/generators/view_component/templates/component.rb.tt b/lib/generators/view_component/templates/component.rb.tt
deleted file mode 100644
index 2a5d459..0000000
--- a/lib/generators/view_component/templates/component.rb.tt
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-class <%= class_name %>::Component < <%= parent_class %>
- with_collection_parameter :<%= singular_name %>
-<%- if initialize_signature -%>
- <%= initialize_signature %>
-<%- end -%>
-end
diff --git a/lib/generators/view_component/templates/component_spec.rb.tt b/lib/generators/view_component/templates/component_spec.rb.tt
deleted file mode 100644
index 2e7ff4d..0000000
--- a/lib/generators/view_component/templates/component_spec.rb.tt
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-require "rails_helper"
-
-describe <%= class_name %>::Component do
- let(:options) { {} }
- let(:component) { <%= class_name %>::Component.new(**options) }
-
- subject { rendered_content }
-
- it "renders" do
- render_inline(component)
-
- is_expected.to have_css "div"
- end
-end
diff --git a/lib/generators/view_component/templates/component_system_spec.rb.tt b/lib/generators/view_component/templates/component_system_spec.rb.tt
deleted file mode 100644
index 7051291..0000000
--- a/lib/generators/view_component/templates/component_system_spec.rb.tt
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-require "rails_helper"
-
-describe "<%= file_name %> component" do
- it "default preview" do
- visit("/rails/view_components<%= File.join(class_path, file_name) %>/default")
-
- # is_expected.to have_text "Hello!"
- # click_on "Click me"
- # is_expected.to have_text "Good-bye!"
- end
-end
diff --git a/lib/generators/view_component/templates/preview.rb.tt b/lib/generators/view_component/templates/preview.rb.tt
deleted file mode 100644
index da3a53e..0000000
--- a/lib/generators/view_component/templates/preview.rb.tt
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class <%= class_name %>::Preview < <%= preview_parent_class %>
- # You can specify the container class for the default template
- # self.container_class = "w-1/2 border border-gray-300"
-
- def default
- end
-end
diff --git a/lib/generators/view_component/view_component_generator.rb b/lib/generators/view_component/view_component_generator.rb
deleted file mode 100644
index 7192d62..0000000
--- a/lib/generators/view_component/view_component_generator.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails/generators'
-# Based on https://github.com/github/view_component/blob/master/lib/rails/generators/component/component_generator.rb
-module Generators
- module ViewComponent
- class ViewComponentGenerator < Rails::Generators::NamedBase
- source_root File.expand_path('templates', __dir__)
-
- class_option :skip_test, type: :boolean, default: false
- class_option :skip_system_test, type: :boolean, default: false
- class_option :skip_preview, type: :boolean, default: false
-
- argument :attributes, type: :array, default: [], banner: 'attribute'
-
- def create_component_file
- template 'component.rb', File.join('app/frontend/components', class_path, file_name, 'component.rb')
- end
-
- def create_template_file
- template 'component.html.slim',
- File.join('app/frontend/components', class_path, file_name, 'component.html.slim')
- end
-
- def create_test_file
- return if options[:skip_test]
-
- template 'component_spec.rb', File.join('spec/frontend/components', class_path, "#{file_name}_spec.rb")
- end
-
- # def create_system_test_file
- # return if options[:skip_system_test]
-
- # template 'component_system_spec.rb',
- # File.join('spec/system/frontend/components', class_path, "#{file_name}_spec.rb")
- # end
-
- def create_preview_file
- return if options[:skip_preview]
-
- template 'preview.rb', File.join('app/frontend/components', class_path, file_name, 'preview.rb')
- end
-
- private
-
- def parent_class
- 'ApplicationViewComponent'
- end
-
- def preview_parent_class
- 'ApplicationViewComponentPreview'
- end
-
- def initialize_signature
- return if attributes.blank?
-
- attributes.map { |attr| "option :#{attr.name}" }.join("\n ")
- end
- end
- end
-end
diff --git a/lib/ui_form_helpers.rb b/lib/ui_form_helpers.rb
deleted file mode 100644
index ccefe84..0000000
--- a/lib/ui_form_helpers.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-
-module UiFormHelpers
- def ui_text_field(field_name, attributes = {}, &)
- label = options.delete(:label) { field_name.to_s.humanize }
- type = options.delete(:type) { :text }
-
- @template.render Inputs::Text::Component.new(
- field_name,
- form_builder: self, type:, label:, **attributes,
- &
- )
- end
-
- def ui_email_field(field_name, attributes = {}, &)
- label = options.delete(:label) { field_name.to_s.humanize }
- type = options.delete(:type) { :email }
- @template.render Inputs::Text::Component.new(
- field_name,
- form_builder: self, type:, label:, autocomplete: 'email', **attributes,
- &
- )
- end
-
- def ui_password_field(field_name, attributes = {}, &)
- label = options.delete(:label) { field_name.to_s.humanize }
- type = options.delete(:type) { :password }
- @template.render(
- Inputs::Text::Component.new(field_name, form_builder: self, label:, type:, **attributes), &
- )
- end
-
- def ui_text_area(field_name, attributes = {}, &)
- label = options.delete(:label) { field_name.to_s.humanize }
- @template.render(Inputs::Textarea::Component.new(field_name, form_builder: self, label:, **attributes), &)
- end
-
- def ui_submit(value = nil, attributes = {})
- value ||= submit_default_value
- options.delete(:type)
- @template.render Button::Component.new(value, kind: :primary, type: :submit, **attributes)
- end
-end