Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using importmap in rails7, datepicker does not work in dark mode. #24

Open
d6rkaiz opened this issue Nov 4, 2023 · 4 comments
Open

Comments

@d6rkaiz
Copy link

d6rkaiz commented Nov 4, 2023

I am trying to use datepicker in rails 7 with importmap, but it does not work when in dark mode.

/config/importmap.rb

# Pin npm packages by running ./bin/importmap

pin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin_all_from "app/javascript/controllers", under: "controllers"
pin "flowbite", to: "https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.0.0/flowbite.turbo.min.js"
pin "flowbite-datepicker", to: "https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.0.0/datepicker.turbo.min.js"

/app/javascript/application.js

// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"
import 'flowbite'
import 'flowbite-datepicker'

I am using the flowbit official date range picker as a sample, at which point it looks like this attachment.
cf: https://flowbite.com/docs/plugins/datepicker/#date-range-picker

スクリーンショット 2023-11-04 23 03 04

Although it is not mentioned in the documentation for using importmap, the following is what it looks like after introducing flowbite.min.css.

/app/view/layoouts/application.html.haml

     = csp_meta_tag
     = stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload"
     = stylesheet_link_tag "application", "data-turbo-track": "reload"
+    %link{:href => "https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.0.0/flowbite.min.css", :rel => "stylesheet"}/
     = javascript_importmap_tags
   %body.bg-white-200.dark:bg-slate-900.dark:text-white

スクリーンショット 2023-11-04 23 04 07

It works, however, the behavior in dark mode is not right with this method.

If I change the loading position of the css, I get the following.

     = csp_meta_tag
+    %link{:href => "https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.0.0/flowbite.min.css", :rel => "stylesheet"}/
     = stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload"
     = stylesheet_link_tag "application", "data-turbo-track": "reload"
     = javascript_importmap_tags
   %body.bg-white-200.dark:bg-slate-900.dark:text-white

スクリーンショット 2023-11-04 23 03 43

The dialog that appears when the year and month are clicked is not correct.

What is the correct way to do this?

@d6rkaiz
Copy link
Author

d6rkaiz commented Nov 4, 2023

I posted the above source to https://github.com/d6rkaiz/flowbite_datepicker

@mickeymarse
Copy link

I'm encountering a similar issue, so I'm following this thread in case there are updates.

@itsyoshio
Copy link

+1

@samuelasselin
Copy link

samuelasselin commented Oct 15, 2024

Same issue using 2.5.2 using import map with rails 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants