diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index eab12e73..98610852 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['3.2', '3.3', '3.4'] + ruby: ['3.2', '3.3', '3.4', '4.0'] appraisal: ['rails-7.1', 'rails-7.2', 'rails-8.0', 'rails-8.1'] runs-on: ubuntu-latest @@ -29,7 +29,8 @@ jobs: - name: Install dependencies for Appraisal run: | - bundle install --jobs 4 --retry 3 --path vendor/bundle + bundle config set path 'vendor/bundle' + bundle install --jobs 4 --retry 3 bundle exec appraisal install - name: Precompile assets diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 2da3e88c..34e27e08 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -9,7 +9,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.4.7 + ruby-version: 4.0.0 - name: Checkout repository uses: actions/checkout@v3 diff --git a/app/components/tailwinds/badge_component.rb b/app/components/tailwinds/badge_component.rb index ec889790..4e03647b 100644 --- a/app/components/tailwinds/badge_component.rb +++ b/app/components/tailwinds/badge_component.rb @@ -10,8 +10,8 @@ class BadgeComponent < Tailwinds::BaseComponent def classes [ - 'flex', 'px-3', 'py-1', 'text-sm', 'font-semibold', 'text-white', "bg-#{resolved_color}-500", - "dark:bg-#{resolved_color}-600", 'rounded-full', 'w-fit', 'h-fit' + 'flex', 'px-3', 'py-1', 'text-sm', 'font-semibold', 'text-white', + "bg-#{resolved_color}-600", 'rounded-full', 'w-fit', 'h-fit' ] end end diff --git a/app/components/tailwinds/button_component.rb b/app/components/tailwinds/button_component.rb index 726688a5..207d59e4 100644 --- a/app/components/tailwinds/button_component.rb +++ b/app/components/tailwinds/button_component.rb @@ -24,8 +24,7 @@ def size_classes def classes (default_classes + - light_mode_classes + - dark_mode_classes + + color_classes + (link ? %w[px-1 h-fit] : ['cursor-pointer'])).compact.join(' ') end @@ -36,19 +35,11 @@ def default_classes ] end - def light_mode_classes + def color_classes [ - "bg-#{resolved_color}-500", - "hover:bg-#{resolved_color}-700", - 'text-white' - ] - end - - def dark_mode_classes - [ - "dark:bg-#{resolved_color}-600", - "dark:hover:bg-#{resolved_color}-800", - 'dark:text-gray-300' + "bg-#{resolved_color}-600", + "hover:bg-#{resolved_color}-800", + 'text-gray-300' ] end end diff --git a/app/components/tailwinds/containers/narrow_component.html.haml b/app/components/tailwinds/containers/narrow_component.html.haml index 19665af4..c1e4713a 100644 --- a/app/components/tailwinds/containers/narrow_component.html.haml +++ b/app/components/tailwinds/containers/narrow_component.html.haml @@ -1,3 +1,3 @@ -.container.p-4.flex.align-center.justify-center.w-full.mx-auto.bg-gray-100.dark:bg-gray-900.text-gray-900.dark:text-white{ id: } - .flex.flex-col.justify-center.w-full.dark:text-white +.container.p-4.flex.align-center.justify-center.w-full.mx-auto.bg-gray-900.text-white{ id: } + .flex.flex-col.justify-center.w-full = content diff --git a/app/components/tailwinds/form/date_field_component.html.haml b/app/components/tailwinds/form/date_field_component.html.haml index 04edd965..6e76c879 100644 --- a/app/components/tailwinds/form/date_field_component.html.haml +++ b/app/components/tailwinds/form/date_field_component.html.haml @@ -2,7 +2,6 @@ - if @label = component('tailwinds/form/label', for: @for) do = @label - - base_classes = 'w-full bg-white border border-gray-300 rounded focus:outline-none focus:border-red-500 ' - - base_classes += 'dark:bg-gray-800 dark:border-gray-600 dark:text-white dark:focus:border-red-400 dark:placeholder-white' + - base_classes = 'w-full border rounded focus:outline-none bg-gray-800 border-gray-600 text-white focus:border-red-400 placeholder-white' - classes = "#{size_class(:text_input)} #{base_classes}" = @input.call @attribute, **@options.merge(class: classes), value: @value diff --git a/app/components/tailwinds/form/file_field_component.html.haml b/app/components/tailwinds/form/file_field_component.html.haml index be8e45cc..4cf8fe54 100644 --- a/app/components/tailwinds/form/file_field_component.html.haml +++ b/app/components/tailwinds/form/file_field_component.html.haml @@ -1,7 +1,6 @@ .mb-4 - if @label - - base_classes = 'inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold rounded cursor-pointer mt-4 ' - - base_classes += 'dark:bg-blue-600 dark:hover:bg-blue-500' + - base_classes = 'inline-block text-white font-bold rounded cursor-pointer mt-4 bg-blue-600 hover:bg-blue-500' - classes = "#{size_class(:file_button)} #{base_classes}" %label{ for: @for, class: classes } = @label diff --git a/app/components/tailwinds/form/label_component.html.haml b/app/components/tailwinds/form/label_component.html.haml index 94829e04..20a30bf5 100644 --- a/app/components/tailwinds/form/label_component.html.haml +++ b/app/components/tailwinds/form/label_component.html.haml @@ -1,2 +1,2 @@ -%label.block.text-gray-700.text-sm.font-bold.mb-2.dark:text-white{ for: } +%label.block.text-sm.font-bold.mb-2.text-white{ for: } = content diff --git a/app/components/tailwinds/form/multiselect/dropdown_container.html.haml b/app/components/tailwinds/form/multiselect/dropdown_container.html.haml index 8c752569..29f73b25 100644 --- a/app/components/tailwinds/form/multiselect/dropdown_container.html.haml +++ b/app/components/tailwinds/form/multiselect/dropdown_container.html.haml @@ -1,3 +1,3 @@ -#dropdown.absolute.shadow.top-11.bg-white.z-40.w-full.lef-0.rounded.max-h-select.overflow-y-auto.dark:bg-gray-800.dark:shadow-lg.dark:ring-1.dark:ring-gray-700{ data: { action: "click@window->multiselect#closeOnClickOutside" } } +#dropdown.absolute.shadow.top-11.z-40.w-full.lef-0.rounded.max-h-select.overflow-y-auto.bg-gray-800.shadow-lg.ring-1.ring-gray-700{ data: { action: "click@window->multiselect#closeOnClickOutside" } } .flex.flex-col.w-full {{content}} diff --git a/app/components/tailwinds/form/multiselect/item_container.html.haml b/app/components/tailwinds/form/multiselect/item_container.html.haml index 83da7f2f..be9a600c 100644 --- a/app/components/tailwinds/form/multiselect/item_container.html.haml +++ b/app/components/tailwinds/form/multiselect/item_container.html.haml @@ -1,5 +1,5 @@ -.cursor-pointer.w-full.border-gray-100.rounded-t.border-b.hover:bg-teal-100.dark:border-gray-700.dark:hover:bg-gray-700{ data: { action: "click->multiselect#toggleItem", text: "{{text}}", value: "{{value}}" } } - .flex.w-full.items-center.p-2.pl-2.border-transparent.border-l-2.relative.hover:border-teal-100.dark:hover:border-gray-600 +.cursor-pointer.w-full.rounded-t.border-b.border-gray-700.hover:bg-gray-700{ data: { action: "click->multiselect#toggleItem", text: "{{text}}", value: "{{value}}" } } + .flex.w-full.items-center.p-2.pl-2.border-transparent.border-l-2.relative.hover:border-gray-600 .w-full.items-center.flex.dark:text-gray-100 .mx-2.leading-6 {{text}} diff --git a/app/components/tailwinds/form/multiselect/select_as_input.html.haml b/app/components/tailwinds/form/multiselect/select_as_input.html.haml index beace7c0..83bfd35a 100644 --- a/app/components/tailwinds/form/multiselect/select_as_input.html.haml +++ b/app/components/tailwinds/form/multiselect/select_as_input.html.haml @@ -1,5 +1,4 @@ .flex-1 - - base_classes = 'bg-transparent appearance-none outline-none h-full w-full text-gray-800 hidden ' - - base_classes += 'dark:text-white dark:placeholder-white' + - base_classes = 'bg-transparent appearance-none outline-none h-full w-full hidden text-white placeholder-white' - classes = "#{@size_class} #{base_classes}" = @input.call(@attribute, @options.merge(placeholder: "{{placeholder}}", class: classes, data: { 'multiselect-target' => 'hiddenInput' })) diff --git a/app/components/tailwinds/form/multiselect/selected_item_template.html.haml b/app/components/tailwinds/form/multiselect/selected_item_template.html.haml index 3e274ea8..f199b353 100644 --- a/app/components/tailwinds/form/multiselect/selected_item_template.html.haml +++ b/app/components/tailwinds/form/multiselect/selected_item_template.html.haml @@ -1,4 +1,4 @@ -.flex.justify-center.items-center.m-1.font-medium.py-1.px-2.bg-white.rounded-full.text-teal-700.bg-teal-100.border.border-teal-300.dark:bg-teal-900.dark:text-teal-100.dark:border-teal-700 +.flex.justify-center.items-center.m-1.font-medium.py-1.px-2.rounded-full.border.bg-teal-900.text-teal-100.border-teal-700 .text-xs.font-normal.leading-none.max-w-full.flex-initial {{text}} .flex.flex-auto.flex-row-reverse diff --git a/app/components/tailwinds/form/multiselect_component.html.haml b/app/components/tailwinds/form/multiselect_component.html.haml index f81d4300..ff44c1c2 100644 --- a/app/components/tailwinds/form/multiselect_component.html.haml +++ b/app/components/tailwinds/form/multiselect_component.html.haml @@ -2,9 +2,9 @@ - if @label = component('tailwinds/form/label', for: @for) do = @label - .flex.flex-col.relative.dark:text-gray-100{ data: multiselect_hash, id: "#{@for}_multiselect" } + .flex.flex-col.relative.text-gray-100{ data: multiselect_hash, id: "#{@for}_multiselect" } .min-w-96.w-fit - .p-1.flex.border.border-gray-200.bg-white.rounded.dark:border-gray-600.dark:bg-gray-800{ data: { "multiselect-target" => "dropdown" } } + .p-1.flex.border.rounded.border-gray-600.bg-gray-800{ data: { "multiselect-target" => "dropdown" } } .flex.flex-auto.flex-wrap{ data: { "multiselect-target" => "showSelectedArea" } } - .text-gray-300.w-8.py-1.pl-2.pr-1.border-l.flex.items-center.border-gray-200.dark:text-gray-500.dark:border-gray-600 + .w-8.py-1.pl-2.pr-1.border-l.flex.items-center.text-gray-500.border-gray-600 ^ diff --git a/app/components/tailwinds/form/number_field_component.html.haml b/app/components/tailwinds/form/number_field_component.html.haml index 04edd965..6ccda732 100644 --- a/app/components/tailwinds/form/number_field_component.html.haml +++ b/app/components/tailwinds/form/number_field_component.html.haml @@ -2,7 +2,7 @@ - if @label = component('tailwinds/form/label', for: @for) do = @label - - base_classes = 'w-full bg-white border border-gray-300 rounded focus:outline-none focus:border-red-500 ' - - base_classes += 'dark:bg-gray-800 dark:border-gray-600 dark:text-white dark:focus:border-red-400 dark:placeholder-white' + - base_classes = 'w-full border rounded focus:outline-none ' + - base_classes += 'bg-gray-800 border-gray-600 text-white focus:border-red-400 placeholder-white' - classes = "#{size_class(:text_input)} #{base_classes}" = @input.call @attribute, **@options.merge(class: classes), value: @value diff --git a/app/components/tailwinds/form/select_component.html.haml b/app/components/tailwinds/form/select_component.html.haml index f984d46c..7eb61078 100644 --- a/app/components/tailwinds/form/select_component.html.haml +++ b/app/components/tailwinds/form/select_component.html.haml @@ -2,8 +2,8 @@ - if @label = component('tailwinds/form/label', for: @for) do = @label - - base_classes = 'w-full bg-white border border-gray-300 text-gray-700 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 ' - - base_classes += 'focus:border-transparent disabled:bg-gray-100 disabled:text-gray-400 disabled:cursor-not-allowed ' - - base_classes += 'dark:bg-gray-800 dark:border-gray-600 dark:text-gray-100 dark:focus:ring-red-400 dark:disabled:bg-gray-800 dark:disabled:text-gray-500' + - base_classes = 'w-full border rounded focus:outline-none focus:ring-2 ' + - base_classes += 'focus:border-transparent disabled:cursor-not-allowed ' + - base_classes += 'bg-gray-800 border-gray-600 text-gray-100 focus:ring-red-400 disabled:bg-gray-800 disabled:text-gray-500' - classes = "#{size_class(:select_input)} #{base_classes}" = @input.call(@attribute, @collection, { selected: @value }, @options.merge(class: classes)) diff --git a/app/components/tailwinds/form/submit_button_component.html.haml b/app/components/tailwinds/form/submit_button_component.html.haml index d9dc5d74..86bfb905 100644 --- a/app/components/tailwinds/form/submit_button_component.html.haml +++ b/app/components/tailwinds/form/submit_button_component.html.haml @@ -1,6 +1,6 @@ .flex.items-center.justify-between - - base_classes = 'bg-red-500 hover:bg-red-700 text-white font-bold rounded focus:outline-none focus:shadow-outline cursor-pointer ' - - base_classes += 'dark:text-white dark:bg-red-600 dark:hover:bg-red-500 dark:focus:ring-2 dark:focus:ring-red-400' + - base_classes = 'hover:bg-red-700 font-bold rounded focus:outline-none focus:shadow-outline cursor-pointer ' + - base_classes += 'text-white bg-red-600 hover:bg-red-500 focus:ring-2 focus:ring-red-400' - classes = "#{size_class(:submit_button)} #{base_classes}" = helpers.tramway_button text: @text, diff --git a/app/components/tailwinds/form/text_area_component.html.haml b/app/components/tailwinds/form/text_area_component.html.haml index 04edd965..6ccda732 100644 --- a/app/components/tailwinds/form/text_area_component.html.haml +++ b/app/components/tailwinds/form/text_area_component.html.haml @@ -2,7 +2,7 @@ - if @label = component('tailwinds/form/label', for: @for) do = @label - - base_classes = 'w-full bg-white border border-gray-300 rounded focus:outline-none focus:border-red-500 ' - - base_classes += 'dark:bg-gray-800 dark:border-gray-600 dark:text-white dark:focus:border-red-400 dark:placeholder-white' + - base_classes = 'w-full border rounded focus:outline-none ' + - base_classes += 'bg-gray-800 border-gray-600 text-white focus:border-red-400 placeholder-white' - classes = "#{size_class(:text_input)} #{base_classes}" = @input.call @attribute, **@options.merge(class: classes), value: @value diff --git a/app/components/tailwinds/form/text_field_component.html.haml b/app/components/tailwinds/form/text_field_component.html.haml index 04edd965..6ccda732 100644 --- a/app/components/tailwinds/form/text_field_component.html.haml +++ b/app/components/tailwinds/form/text_field_component.html.haml @@ -2,7 +2,7 @@ - if @label = component('tailwinds/form/label', for: @for) do = @label - - base_classes = 'w-full bg-white border border-gray-300 rounded focus:outline-none focus:border-red-500 ' - - base_classes += 'dark:bg-gray-800 dark:border-gray-600 dark:text-white dark:focus:border-red-400 dark:placeholder-white' + - base_classes = 'w-full border rounded focus:outline-none ' + - base_classes += 'bg-gray-800 border-gray-600 text-white focus:border-red-400 placeholder-white' - classes = "#{size_class(:text_input)} #{base_classes}" = @input.call @attribute, **@options.merge(class: classes), value: @value diff --git a/app/components/tailwinds/nav/item_component.rb b/app/components/tailwinds/nav/item_component.rb index cff5a4f8..b3de722f 100644 --- a/app/components/tailwinds/nav/item_component.rb +++ b/app/components/tailwinds/nav/item_component.rb @@ -7,8 +7,7 @@ module Nav class ItemComponent < TailwindComponent def style @style ||= [ - 'text-white', 'hover:bg-gray-300', 'hover:text-gray-800', 'px-4', 'py-2', 'rounded', 'whitespace-nowrap', - 'dark:hover:bg-gray-700', 'dark:hover:text-gray-400', 'dark:text-white' + 'px-4', 'py-2', 'rounded', 'whitespace-nowrap', 'hover:bg-gray-700', 'hover:text-gray-400', 'text-white' ].join(' ') end end diff --git a/app/components/tailwinds/navbar_component.html.haml b/app/components/tailwinds/navbar_component.html.haml index 9ae48e37..69627763 100644 --- a/app/components/tailwinds/navbar_component.html.haml +++ b/app/components/tailwinds/navbar_component.html.haml @@ -1,10 +1,10 @@ -%nav.py-2.px-4.sm:px-8.flex.justify-between.items-center.dark:bg-gray-800{ class: "bg-#{@color}" } +%nav.py-2.px-4.sm:px-8.flex.justify-between.items-center.bg-gray-800 .flex.justify-between.w-full - if @title[:text].present? || @left_items.present? .flex.items-center - if @title[:text].present? = link_to @title[:link] do - .text-xl.text-white.font-bold.dark:text-white + .text-xl.font-bold.text-white = @title[:text] - if @left_items.present? %ul.flex-row.items-center.space-x-4.ml-4.hidden.md:flex @@ -20,7 +20,7 @@ - @right_items.each do |item| = item -#mobile-menu.hidden.flex-col.sm:hidden.dark:bg-gray-800 +#mobile-menu.hidden.flex-col.sm:hidden.bg-gray-800 - if @left_items.present? %ul.flex.flex-col.space-y-2 - @left_items.each do |item| diff --git a/app/components/tailwinds/navbar_component.rb b/app/components/tailwinds/navbar_component.rb index 951ae3e9..3e08df76 100644 --- a/app/components/tailwinds/navbar_component.rb +++ b/app/components/tailwinds/navbar_component.rb @@ -1,42 +1,12 @@ # frozen_string_literal: true module Tailwinds - # Background helper module - # - module BackgroundHelper - CSS_COLORS = %i[aqua black blue fuchsia gray green lime maroon navy olive orange purple red - silver teal white yellow].freeze - MIN_INTENSITY = 100 - MAX_INTENSITY = 950 - DEFAULT_BACKGROUND_COLOR = :purple - DEFAULT_BACKGROUND_INTENSITY = 700 - - def self.background(options) - color = options.dig(:background, :color) || DEFAULT_BACKGROUND_COLOR - intensity = options.dig(:background, :intensity) || DEFAULT_BACKGROUND_INTENSITY - - unless (MIN_INTENSITY..MAX_INTENSITY).cover?(intensity) - raise "Navigation Background Color intensity should be between #{MIN_INTENSITY} and #{MAX_INTENSITY}" - end - - if color.in? CSS_COLORS - "#{color}-#{intensity}" - else - "[#{color}]" - end - end - end - - # Navbar class main class - # + # Navbar component class NavbarComponent < TailwindComponent - include Tailwinds::BackgroundHelper - def initialize(**options) @title = { text: options[:title], link: options[:title_link] || '/' } @left_items = options[:left_items] @right_items = options[:right_items] - @color = BackgroundHelper.background(options) end end end diff --git a/app/components/tailwinds/pagination/base.rb b/app/components/tailwinds/pagination/base.rb index 565e3f38..40ef6f22 100644 --- a/app/components/tailwinds/pagination/base.rb +++ b/app/components/tailwinds/pagination/base.rb @@ -8,15 +8,14 @@ class Base < Tramway::BaseComponent option :url option :remote - # :reek:UtilityFunction { enabled: false } def pagination_classes(klass: nil) - default_classes = ['cursor-pointer', 'px-3', 'py-2', 'font-medium', 'text-purple-700', 'bg-white', - 'rounded-md', 'hover:bg-purple-100', 'dark:text-white', 'dark:bg-gray-800', - 'dark:hover:bg-gray-700'] + default_classes = [ + 'cursor-pointer', 'px-3', 'py-2', 'font-medium', 'rounded-md', 'text-white', 'bg-gray-800', + 'hover:bg-gray-700' + ] (default_classes + [klass]).join(' ') end - # :reek:UtilityFunction { enabled: true } end end end diff --git a/app/components/tailwinds/pagination/gap_component.html.haml b/app/components/tailwinds/pagination/gap_component.html.haml index bfcb72cc..f521a571 100644 --- a/app/components/tailwinds/pagination/gap_component.html.haml +++ b/app/components/tailwinds/pagination/gap_component.html.haml @@ -1,3 +1,3 @@ %div.flex.justify-end.mt-2 - %span.page.gap.px-3.py-2.text-sm.font-medium.text-purple-700.dark:text-white.sm:flex.hidden - = helpers.t('views.pagination.truncate').html_safe \ No newline at end of file + %span.page.gap.px-3.py-2.text-sm.font-medium.text-white.sm:flex.hidden + = helpers.t('views.pagination.truncate').html_safe diff --git a/app/components/tailwinds/pagination/page_component.html.haml b/app/components/tailwinds/pagination/page_component.html.haml index 1fbeafeb..2fd1d9ca 100644 --- a/app/components/tailwinds/pagination/page_component.html.haml +++ b/app/components/tailwinds/pagination/page_component.html.haml @@ -1,5 +1,5 @@ - if page.current? - %span.px-3.py-2.font-medium.rounded-md.bg-purple-500.text-white.dark:text-gray-800.dark:bg-white + %span.px-3.py-2.font-medium.rounded-md.text-gray-800.bg-white = page - else = link_to page, diff --git a/app/components/tailwinds/table/cell_component.html.haml b/app/components/tailwinds/table/cell_component.html.haml index a5bb07ee..02a78851 100644 --- a/app/components/tailwinds/table/cell_component.html.haml +++ b/app/components/tailwinds/table/cell_component.html.haml @@ -1,2 +1,2 @@ -.div-table-cell.md:block.first:block.hidden.px-6.py-4.font-medium.text-gray-900.dark:text-white.text-base +.div-table-cell.md:block.first:block.hidden.px-6.py-4.font-medium.text-white.text-base = content diff --git a/app/components/tailwinds/table/header_component.html.haml b/app/components/tailwinds/table/header_component.html.haml index 889797a9..bcaf935c 100644 --- a/app/components/tailwinds/table/header_component.html.haml +++ b/app/components/tailwinds/table/header_component.html.haml @@ -1,4 +1,4 @@ -.div-table-row.grid.text-white.text-small.gap-4.bg-purple-700.dark:bg-gray-700.dark:text-gray-400.grid-cols-1{ class: "md:grid-cols-#{columns_count}", aria: { label: "Table Header" }, role: "row" } +.div-table-row.grid.text-small.gap-4.bg-gray-700.text-gray-400.grid-cols-1{ class: "md:grid-cols-#{columns_count}", aria: { label: "Table Header" }, role: "row" } - if headers.any? - headers.each do |header| .div-table-cell.py-4.px-6.first:block.hidden.md:block diff --git a/app/components/tailwinds/table/row/preview_component.html.haml b/app/components/tailwinds/table/row/preview_component.html.haml index d4055965..a261a7f1 100644 --- a/app/components/tailwinds/table/row/preview_component.html.haml +++ b/app/components/tailwinds/table/row/preview_component.html.haml @@ -13,6 +13,6 @@ animation: roll-up 0.5s ease-in-out; } -#roll-up.fixed.hidden.inset-x-0.bottom-0.bg-purple-700.shadow-lg.z-50.dark:bg-gray-800.animate-roll-up{ class: 'h-1/2' } - %button.absolute.top-4.text-white.right-4.hover:text-gray-700.dark:text-gray-400.dark:hover:text-gray-200{ "data-action" => "click->preview#close", "data-controller" => "preview" } +#roll-up.fixed.hidden.inset-x-0.bottom-0.shadow-lg.z-50.bg-gray-800.animate-roll-up{ class: 'h-1/2' } + %button.absolute.top-4.right-4.text-gray-400.hover:text-gray-200{ "data-action" => "click->preview#close", "data-controller" => "preview" } ✕ diff --git a/app/components/tailwinds/table/row_component.html.haml b/app/components/tailwinds/table/row_component.html.haml index ce4eed16..2163e3cd 100644 --- a/app/components/tailwinds/table/row_component.html.haml +++ b/app/components/tailwinds/table/row_component.html.haml @@ -1,7 +1,7 @@ - if cells.any? = row_tag class: desktop_row_classes(cells.count), **options do - cells.each do |(_, value)| - .div-table-cell.px-6.py-4.font-medium.text-gray-900.dark:text-white.text-xs.sm:text-base + .div-table-cell.px-6.py-4.font-medium.text-white.text-xs.sm:text-base = value - else diff --git a/app/components/tailwinds/table/row_component.rb b/app/components/tailwinds/table/row_component.rb index 10e7945d..5fcf6e75 100644 --- a/app/components/tailwinds/table/row_component.rb +++ b/app/components/tailwinds/table/row_component.rb @@ -24,13 +24,13 @@ def row_tag(**options, &) def desktop_row_classes(cells_count) [ - 'div-table-row', 'grid', 'gap-4', 'bg-white', 'border-b', 'last:border-b-0', 'dark:bg-gray-800', - 'dark:border-gray-700', "md:grid-cols-#{cells_count}", 'grid-cols-1' + 'div-table-row', 'grid', 'gap-4', 'border-b', 'last:border-b-0', 'bg-gray-800', + 'border-gray-700', "md:grid-cols-#{cells_count}", 'grid-cols-1' ].join(' ') end def link_row_classes - 'cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700' + 'cursor-pointer hover:bg-gray-700' end end end diff --git a/app/components/tailwinds/table_component.html.haml b/app/components/tailwinds/table_component.html.haml index 5ba6243f..344c9c9b 100644 --- a/app/components/tailwinds/table_component.html.haml +++ b/app/components/tailwinds/table_component.html.haml @@ -2,5 +2,5 @@ - width_class = options[:class]&.include?('w-') ? '' : 'w-full' -.div-table.text-left.rtl:text-right.text-gray-500.dark:text-gray-400{ class: "#{options[:class]} #{width_class}", **options.except(:class) } +.div-table.text-left.rtl:text-right.text-gray-400{ class: "#{options[:class]} #{width_class}", **options.except(:class) } = content diff --git a/app/components/tailwinds/title_component.html.haml b/app/components/tailwinds/title_component.html.haml index d9e7c331..79399925 100644 --- a/app/components/tailwinds/title_component.html.haml +++ b/app/components/tailwinds/title_component.html.haml @@ -1,4 +1,4 @@ -%h1.font-bold.text-4xl.dark:text-white +%h1.font-bold.text-4xl.text-white - if text.present? = text - else diff --git a/app/views/tramway/layouts/application.html.haml b/app/views/tramway/layouts/application.html.haml index 7f6903b8..7010cb98 100644 --- a/app/views/tramway/layouts/application.html.haml +++ b/app/views/tramway/layouts/application.html.haml @@ -19,7 +19,7 @@ / Includes all stylesheet files in app/assets/stylesheets = stylesheet_link_tag "tailwind", "data-turbo-track": "reload" - %body.bg-gray-100.dark:bg-gray-900.text-gray-900.dark:text-white + %body.bg-gray-900.text-white = tramway_navbar title: 'Tramway' - if flash.any? diff --git a/config/tailwind.config.js b/config/tailwind.config.js index 8ab7a405..1f2a5343 100644 --- a/config/tailwind.config.js +++ b/config/tailwind.config.js @@ -98,14 +98,14 @@ module.exports = { 'hover:text-gray-800', // === Dark mode pagination styles === - 'dark:text-white', - 'dark:bg-gray-800', - 'dark:hover:bg-gray-700', - 'dark:bg-gray-900', - 'dark:bg-gray-700', - 'dark:text-gray-400', - 'dark:hover:text-gray-400', - 'dark:placeholder-gray-400', + 'text-white', + 'bg-gray-800', + 'hover:bg-gray-700', + 'bg-gray-900', + 'bg-gray-700', + 'text-gray-400', + 'hover:text-gray-400', + 'placeholder-gray-400', // === Button and badge helpers === 'bg-purple-700', @@ -122,40 +122,40 @@ module.exports = { // === Button color presets === 'bg-gray-500', 'hover:bg-gray-700', - 'dark:bg-gray-600', - 'dark:hover:bg-gray-800', + 'bg-gray-600', + 'hover:bg-gray-800', 'bg-blue-500', 'hover:bg-blue-700', - 'dark:bg-blue-600', - 'dark:hover:bg-blue-800', + 'bg-blue-600', + 'hover:bg-blue-800', 'bg-zinc-500', 'hover:bg-zinc-700', - 'dark:bg-zinc-600', - 'dark:hover:bg-zinc-800', + 'bg-zinc-600', + 'hover:bg-zinc-800', 'bg-green-500', 'hover:bg-green-700', - 'dark:bg-green-600', - 'dark:hover:bg-green-800', + 'bg-green-600', + 'hover:bg-green-800', 'bg-orange-500', 'hover:bg-orange-700', - 'dark:bg-orange-600', - 'dark:hover:bg-orange-800', + 'bg-orange-600', + 'hover:bg-orange-800', 'bg-red-500', 'hover:bg-red-700', - 'dark:bg-red-600', - 'dark:hover:bg-red-800', + 'bg-red-600', + 'hover:bg-red-800', 'bg-violet-500', 'hover:bg-violet-700', - 'dark:bg-violet-600', - 'dark:hover:bg-violet-800', + 'bg-violet-600', + 'hover:bg-violet-800', 'bg-indigo-500', 'hover:bg-indigo-700', - 'dark:bg-indigo-600', - 'dark:hover:bg-indigo-800', + 'bg-indigo-600', + 'hover:bg-indigo-800', 'bg-yellow-500', 'hover:bg-yellow-700', - 'dark:bg-yellow-600', - 'dark:hover:bg-yellow-800', + 'bg-yellow-600', + 'hover:bg-yellow-800', // === Form state helpers === 'disabled:bg-gray-100', @@ -175,8 +175,8 @@ module.exports = { 'max-h-select', 'overflow-y-auto', 'cursor-pointer', - 'dark:border-gray-600', - 'dark:text-gray-100', + 'border-gray-600', + 'text-gray-100', // === Multiselect option styling === 'border-b', diff --git a/spec/components/tailwinds/badge_component_spec.rb b/spec/components/tailwinds/badge_component_spec.rb index a4089859..cf1f4e44 100644 --- a/spec/components/tailwinds/badge_component_spec.rb +++ b/spec/components/tailwinds/badge_component_spec.rb @@ -7,7 +7,7 @@ render_inline(described_class.new(text: 'Active')) expect(page).to have_css( - 'span.flex.px-3.py-1.text-sm.font-semibold.text-white.bg-gray-500.dark\\:bg-gray-600.rounded-full.w-fit', + 'span.flex.px-3.py-1.text-sm.font-semibold.bg-gray-600.rounded-full.w-fit', text: 'Active' ) end @@ -17,7 +17,7 @@ render_inline(described_class.new(text: 'Approved', type: :success)) expect(page).to have_css( - 'span.bg-green-500.dark\\:bg-green-600', + 'span.bg-green-600', text: 'Approved' ) end @@ -28,7 +28,7 @@ render_inline(described_class.new(text: 'Alert', color: :red)) expect(page).to have_css( - 'span.bg-red-500.dark\\:bg-red-600', + 'span.bg-red-600', text: 'Alert' ) end diff --git a/spec/components/tailwinds/button_component_spec.rb b/spec/components/tailwinds/button_component_spec.rb index bae1eadf..87c52357 100644 --- a/spec/components/tailwinds/button_component_spec.rb +++ b/spec/components/tailwinds/button_component_spec.rb @@ -10,8 +10,8 @@ render_inline(component) expect(page).to have_css( - "form[action='/projects'] button.btn.btn-primary.flex.flex-row.py-2.px-4.cursor-pointer.bg-gray-500." \ - 'hover\\:bg-gray-700.text-white.dark\\:bg-gray-600.dark\\:hover\\:bg-gray-800.dark\\:text-gray-300', + "form[action='/projects'] button.btn.btn-primary.flex.flex-row.py-2.px-4.cursor-pointer." \ + 'bg-gray-600.hover\\:bg-gray-800.text-gray-300', text: 'View projects' ) end @@ -33,7 +33,7 @@ render_inline(component) expect(page).to have_css( - "form[action='/projects/1'] button.bg-red-500.hover\\:bg-red-700.text-sm.py-1.px-2." \ + "form[action='/projects/1'] button.text-sm.py-1.px-2." \ "extra-class[data-turbo-confirm='Are you sure?']", text: 'Delete' ) @@ -55,8 +55,8 @@ render_inline(component) expect(page).to have_css( - "a[href='/projects'].btn.btn-primary.flex.flex-row.py-2.px-4.bg-gray-500.hover\\:bg-gray-700.text-white." \ - 'dark\\:bg-gray-600.dark\\:hover\\:bg-gray-800.dark\\:text-gray-300.px-1.h-fit', + "a[href='/projects'].btn.btn-primary.flex.flex-row.py-2.px-4." \ + 'bg-gray-600.hover\\:bg-gray-800.text-gray-300.px-1.h-fit', text: 'View projects' ) end @@ -69,8 +69,7 @@ render_inline(component) expect(page).to have_css( - "form[action='/projects'] button.bg-violet-500.hover\\:bg-violet-700.dark\\:bg-violet-600" \ - '.dark\\:hover\\:bg-violet-800', + "form[action='/projects'] button.bg-violet-600.hover\\:bg-violet-800", text: 'Celebrate' ) end diff --git a/spec/components/tailwinds/form/builder_spec.rb b/spec/components/tailwinds/form/builder_spec.rb index 490ee95d..0efcfe31 100644 --- a/spec/components/tailwinds/form/builder_spec.rb +++ b/spec/components/tailwinds/form/builder_spec.rb @@ -13,8 +13,8 @@ let(:output) { builder.text_field :email } it 'gets default value' do - expect(output).to have_selector 'label.block.text-gray-700.text-sm.font-bold.mb-2' - expect(output).to have_selector 'input.text-base.px-3.py-2.w-full.border.border-gray-300.rounded' + expect(output).to have_selector 'label.block.text-sm.font-bold.mb-2' + expect(output).to have_selector 'input.text-base.px-3.py-2.w-full.border.rounded' end end @@ -73,8 +73,8 @@ let(:output) { builder.email_field :email } it 'renders email input with tailwind classes' do - expect(output).to have_selector 'label.block.text-gray-700.text-sm.font-bold.mb-2' - expect(output).to have_selector 'input[type="email"].text-base.px-3.py-2.w-full.border.border-gray-300.rounded' + expect(output).to have_selector 'label.block.text-sm.font-bold.mb-2' + expect(output).to have_selector 'input[type="email"].text-base.px-3.py-2.w-full.border.rounded' end end @@ -82,8 +82,8 @@ let(:output) { builder.number_field :id } it 'renders number input with tailwind classes' do - expect(output).to have_selector 'label.block.text-gray-700.text-sm.font-bold.mb-2' - expect(output).to have_selector 'input[type="number"].text-base.px-3.py-2.w-full.border.border-gray-300.rounded' + expect(output).to have_selector 'label.block.text-sm.font-bold.mb-2' + expect(output).to have_selector 'input[type="number"].text-base.px-3.py-2.w-full.border.rounded' end end @@ -91,8 +91,8 @@ let(:output) { builder.date_field :remember_created_at } it 'renders date input with tailwind classes' do - expect(output).to have_selector 'label.block.text-gray-700.text-sm.font-bold.mb-2' - expect(output).to have_selector 'input[type="date"].text-base.px-3.py-2.w-full.border.border-gray-300.rounded' + expect(output).to have_selector 'label.block.text-sm.font-bold.mb-2' + expect(output).to have_selector 'input[type="date"].text-base.px-3.py-2.w-full.border.rounded' end context 'with value from object' do @@ -112,8 +112,8 @@ end it do - expect(output).to have_selector 'label.block.text-gray-700.text-sm.font-bold.mb-2' - expect(output).to have_selector 'input.text-base.px-3.py-2.w-full.border.border-gray-300.rounded' + expect(output).to have_selector 'label.block.text-sm.font-bold.mb-2' + expect(output).to have_selector 'input.text-base.px-3.py-2.w-full.border.rounded' end end @@ -123,7 +123,7 @@ end it do - expect(output).to have_selector 'label.inline-block.text-base.px-4.py-2.bg-blue-500.text-white.font-bold.rounded' + expect(output).to have_selector 'label.inline-block.text-base.px-4.py-2.font-bold.rounded' end context 'with small size' do @@ -162,11 +162,11 @@ let(:output) { builder.select :role, %i[admin user] } it 'has the label' do - expect(output).to have_selector 'label.block.text-gray-700.text-sm.font-bold.mb-2' + expect(output).to have_selector 'label.block.text-sm.font-bold.mb-2' end it 'has the select' do - expect(output).to have_selector 'select.text-base.bg-white.border.border-gray-300.text-gray-700' + expect(output).to have_selector 'select.text-base.border' expect(output).to have_selector 'option[value="admin"]' expect(output).to have_selector 'option[value="user"]' end diff --git a/spec/components/tailwinds/navbar_component_spec.rb b/spec/components/tailwinds/navbar_component_spec.rb index e82f6ff8..4cf3472c 100644 --- a/spec/components/tailwinds/navbar_component_spec.rb +++ b/spec/components/tailwinds/navbar_component_spec.rb @@ -32,52 +32,4 @@ expect(page).to have_css 'nav' end end - - context 'with background checks' do - it 'renders navbar with default colors' do - render_inline(described_class.new) - - expect(page).to have_css 'nav.bg-purple-700' - end - - it 'renders navbar with named color and default intensity' do - color = Tailwinds::NavbarComponent::CSS_COLORS.sample - - render_inline(described_class.new(background: { color: })) - - expect(page).to have_css "nav.bg-#{color}-700" - end - - it 'renders navbar with named color and intensity' do - color = Tailwinds::NavbarComponent::CSS_COLORS.sample - intensity = rand(Tailwinds::NavbarComponent::MIN_INTENSITY..Tailwinds::NavbarComponent::MAX_INTENSITY) - - render_inline(described_class.new(background: { color:, intensity: })) - - expect(page).to have_css "nav.bg-#{color}-#{intensity}" - end - - it 'renders navbar with hex color' do - color = "##{SecureRandom.hex(3)}" - - render_inline(described_class.new(background: { color: })) - - # NOTE: we need it because this line returns error, `[` is not expected in selectors - # expect(page).to have_css "nav.bg-[#{color}]" - - navbar_class = page.native.children[1].children[0].children[0].attribute_nodes[0].value - expect(navbar_class).to include("bg-[#{color}]") - end - - it 'raises error with not suitable intensity' do - color = Tailwinds::NavbarComponent::CSS_COLORS.sample - intensity = 951 - - expect do - render_inline(described_class.new(background: { color:, intensity: })) - end.to raise_error( - 'Navigation Background Color intensity should be between 100 and 950' - ) - end - end end diff --git a/spec/features/form_for/base_spec.rb b/spec/features/form_for/base_spec.rb index 850f2277..2bf9c5f3 100644 --- a/spec/features/form_for/base_spec.rb +++ b/spec/features/form_for/base_spec.rb @@ -7,19 +7,19 @@ end scenario 'check text_field' do - expect(page).to have_selector('input.text-base.px-3.py-2.w-full.bg-white.border.border-gray-300.rounded.focus\\:outline-none.focus\\:border-red-500.dark\\:bg-gray-800.dark\\:border-gray-600.dark\\:text-white.dark\\:focus\\:border-red-400.dark\\:placeholder-white') # rubocop:disable Layout/LineLength + expect(page).to have_selector('input.text-base.px-3.py-2.w-full.border.rounded.focus\\:outline-none.bg-gray-800.border-gray-600.text-white.focus\\:border-red-400.placeholder-white') # rubocop:disable Layout/LineLength end scenario 'check file_field' do expect(page).to have_selector("input[type='file']", visible: false) - expect(page).to have_selector('label.inline-block.bg-blue-500.hover\\:bg-blue-700.text-white.font-bold.py-2.px-4.rounded.cursor-pointer.mt-4') # rubocop:disable Layout/LineLength + expect(page).to have_selector('label.inline-block.font-bold.py-2.px-4.rounded.cursor-pointer.mt-4') end scenario 'check select' do - expect(page).to have_selector('select.bg-white.border.border-gray-300.text-gray-700.rounded.focus\\:outline-none.focus\\:ring-2.focus\\:ring-blue-500.focus\\:border-transparent.py-2.px-3') # rubocop:disable Layout/LineLength + expect(page).to have_selector('select.border.rounded.focus\\:outline-none.focus\\:ring-2.focus\\:border-transparent.py-2.px-3') # rubocop:disable Layout/LineLength end scenario 'check text_area' do - expect(page).to have_selector('textarea.text-base.px-3.py-2.w-full.bg-white.border.border-gray-300.rounded.focus\\:outline-none.focus\\:border-red-500.dark\\:bg-gray-800.dark\\:border-gray-600.dark\\:text-white.dark\\:focus\\:border-red-400.dark\\:placeholder-white') # rubocop:disable Layout/LineLength + expect(page).to have_selector('textarea.text-base.px-3.py-2.w-full.border.rounded.focus\\:outline-none.bg-gray-800.border-gray-600.text-white.focus\\:border-red-400.placeholder-white') # rubocop:disable Layout/LineLength end end diff --git a/spec/features/table/base_spec.rb b/spec/features/table/base_spec.rb index 10fae2bb..85cff3ec 100644 --- a/spec/features/table/base_spec.rb +++ b/spec/features/table/base_spec.rb @@ -11,21 +11,20 @@ end scenario 'check table' do - expect(page).to have_selector('.div-table.text-left.rtl\\:text-right.text-gray-500.dark\\:text-gray-400.w-full') + expect(page).to have_selector('.div-table.text-left.rtl\\:text-right.text-gray-400.w-full') end scenario 'check rows' do selector = [ - 'div-table-row', 'grid', 'gap-4', 'bg-white', 'border-b', 'last\\:border-b-0', 'dark\\:bg-gray-800', - 'dark\\:border-gray-700', 'grid-cols-1' + 'div-table-row', 'grid', 'gap-4', 'border-b', 'last\\:border-b-0', 'bg-gray-800', 'border-gray-700', 'grid-cols-1' ].join('.') expect(page).to have_selector(".#{selector}", count: User.count) end scenario 'check cells' do - selector = [ - 'div-table-cell', 'px-6', 'py-4', 'font-medium', 'text-gray-900', 'dark\\:text-white', 'text-base' + selector = %w[ + div-table-cell px-6 py-4 font-medium text-white text-base ].join('.') expect(page).to have_selector(".#{selector}", count: User.count) diff --git a/spec/pagination/laptop_spec.rb b/spec/pagination/laptop_spec.rb index d4b71c0c..1190a24f 100644 --- a/spec/pagination/laptop_spec.rb +++ b/spec/pagination/laptop_spec.rb @@ -13,7 +13,7 @@ end it 'displays 1..5 pages links and next/last buttons' do - expect(page).to have_css('span', text: '1', class: 'bg-purple-500') + expect(page).to have_css('span', text: '1') (2..5).each do |i| expect(page).to have_link(i.to_s, href: users_path(page: i)) diff --git a/spec/pagination/mobile_spec.rb b/spec/pagination/mobile_spec.rb index 19ddd082..da2eda3a 100644 --- a/spec/pagination/mobile_spec.rb +++ b/spec/pagination/mobile_spec.rb @@ -19,7 +19,7 @@ end it 'displays 1..3 pages links and next/last buttons for a smaller viewport' do - expect(page).to have_css('span', text: '1', class: 'bg-purple-500') + expect(page).to have_css('span', text: '1') (2..3).each do |i| expect(page).to have_link(i.to_s, href: users_path(page: i))