basecoat 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 745c8eb3926d13292445d2d4fbd0b7550bfe5573ef3888ed27c19fc8018fe9c4
4
- data.tar.gz: 321640c46d3f61ee0b87beb7214be8f4cd82ed31f10f4291a26d99a9cb455430
3
+ metadata.gz: 1ec22802652367bcd30144e5e34a1df474e3d52b5943a35c21013d63284e46a1
4
+ data.tar.gz: 5aa8e17dc9669ff89072f3bb51ef8a4316410f448117406e5a64e18a96dafbfd
5
5
  SHA512:
6
- metadata.gz: 8a415461f36459cca8d34235c3939c51b8aa754bc68c5691ebc65f083bc8e2c6a086f600309c326127cb38e3a45f3b3a61dcc0c3684936b4641a2ba0ffc8a566
7
- data.tar.gz: d021c20201711920476b6985174c60d27a8e4fa9d5faaaadb473196a15c9b7407000ad903e584b200df122ef9d69b2d0366302eef25b52078a4d6076d32eee47
6
+ metadata.gz: 89b9cabbb20c51b45aefdea591f85ccdbe55dcb73c08363f24a8907b0be88886a7c99c19c68a73eef27e47270415e8756ad4a03318963a450f2013e7c422c8bc
7
+ data.tar.gz: 1aa2c47cb3737cd0e7bd9a4143d4cd8fbc7943e2c9d52e065c7f71042ad6a147963a9891408ca56037f8aa14740807d8818b115f6677fa92ca494e7a3ca5f234
data/README.md CHANGED
@@ -13,6 +13,7 @@ Try it from scratch:
13
13
 
14
14
  rails new myproject -c tailwind
15
15
  cd myproject
16
+ yarn
16
17
  bundle add basecoat
17
18
  rails basecoat:install
18
19
  rails g scaffold Post title:string! description:text posted_at:datetime active:boolean rating:integer
@@ -165,7 +166,7 @@ Options:
165
166
  - `except`: Array of country codes to exclude
166
167
  - All `basecoat_select_tag` options (placeholder, scrollable, etc.)
167
168
 
168
- **Note:** This helper requires the `countries` gem, which is automatically installed with `rake basecoat:install`.
169
+ **Note:** This helper requires the `countries` gem.
169
170
 
170
171
  ## Rake tasks
171
172
 
@@ -223,7 +224,7 @@ rake basecoat:install:pagy
223
224
  - Rails 8.0+
224
225
  - Tailwind CSS ([installation instructions](https://github.com/rails/tailwindcss-rails))
225
226
  - Basecoat CSS
226
- - Stimulus (for the theme toggle, can be moved to something else if you desire...)
227
+ - Stimulus (for the search helper)
227
228
 
228
229
  ## Issues
229
230
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Basecoat
4
- VERSION = "2.2.2"
4
+ VERSION = "2.3.0"
5
5
  end
@@ -5,7 +5,7 @@
5
5
  <%= render 'layouts/notice', notice: notice if notice %>
6
6
  <div class="grid min-h-svh lg:grid-cols-2">
7
7
  <div class="flex flex-col gap-4 p-6 md:p-10">
8
- <div class="flex justify-between items-center gap-2" data-controller="theme">
8
+ <div class="flex justify-between items-center gap-2">
9
9
  <a href="#" class="flex items-center gap-2 font-medium">
10
10
  <div class="bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md">
11
11
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" class="h-4 w-4"><rect width="256" height="256" fill="none"></rect><line x1="208" y1="128" x2="128" y2="208" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"></line><line x1="192" y1="40" x2="40" y2="192" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"></line></svg>
@@ -7,7 +7,7 @@
7
7
  </div>
8
8
  <div class="grid flex-1 text-left text-sm leading-tight">
9
9
  <span class="truncate font-medium">Basecoat</span>
10
- <span class="truncate text-xs">v0.3.9</span>
10
+ <span class="truncate text-xs">v0.3.10</span>
11
11
  </div>
12
12
  </a>
13
13
  </header>
@@ -18,4 +18,27 @@
18
18
  <%# Includes all stylesheet files in app/assets/stylesheets %>
19
19
  <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
20
20
  <%= javascript_importmap_tags %>
21
+ <script>
22
+ (() => {
23
+ try {
24
+ const stored = localStorage.getItem('themeMode');
25
+ if (stored ? stored === 'dark'
26
+ : matchMedia('(prefers-color-scheme: dark)').matches) {
27
+ document.documentElement.classList.add('dark');
28
+ }
29
+ } catch (_) {}
30
+
31
+ const apply = dark => {
32
+ document.documentElement.classList.toggle('dark', dark);
33
+ try { localStorage.setItem('themeMode', dark ? 'dark' : 'light'); } catch (_) {}
34
+ };
35
+
36
+ document.addEventListener('basecoat:theme', (event) => {
37
+ const mode = event.detail?.mode;
38
+ apply(mode === 'dark' ? true
39
+ : mode === 'light' ? false
40
+ : !document.documentElement.classList.contains('dark'));
41
+ });
42
+ })();
43
+ </script>
21
44
  </head>
@@ -1,4 +1,4 @@
1
- <header class="bg-background sticky inset-x-0 top-0 isolate flex shrink-0 items-center gap-2 border-b z-10 px-4" data-controller="theme">
1
+ <header class="bg-background sticky inset-x-0 top-0 isolate flex shrink-0 items-center gap-2 border-b z-10 px-4">
2
2
  <div class="flex h-14 flex-1 items-center gap-2">
3
3
  <button type="button" onclick="document.dispatchEvent(new CustomEvent('basecoat:sidebar'))" aria-label="Toggle sidebar" data-tooltip="Toggle sidebar" data-side="bottom" data-align="start" class="btn-sm-icon-ghost mr-auto size-7 -ml-1.5">
4
4
  <%= lucide_icon "panel-left" %>
@@ -1,4 +1,4 @@
1
- <button type="button" aria-label="Toggle dark mode" data-tooltip="Toggle dark mode" data-side="left" data-action="click->theme#toggle" class="btn-ghost size-8">
1
+ <button type="button" aria-label="Toggle dark mode" data-tooltip="Toggle dark mode" data-side="left" onclick="document.dispatchEvent(new CustomEvent('basecoat:theme'))" class="btn-ghost size-8">
2
2
  <span class="hidden dark:block"><%= lucide_icon "sun" %></span>
3
3
  <span class="block dark:hidden"><%= lucide_icon "moon" %></span>
4
4
  </button>
@@ -5,7 +5,7 @@
5
5
  <%= render 'layouts/notice', notice: notice if notice %>
6
6
  <div class="grid min-h-svh lg:grid-cols-2">
7
7
  <div class="flex flex-col gap-4 p-6 md:p-10">
8
- <div class="flex justify-between items-center gap-2" data-controller="theme">
8
+ <div class="flex justify-between items-center gap-2">
9
9
  <a href="#" class="flex items-center gap-2 font-medium">
10
10
  <div class="bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md">
11
11
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" class="h-4 w-4"><rect width="256" height="256" fill="none"></rect><line x1="208" y1="128" x2="128" y2="208" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"></line><line x1="192" y1="40" x2="40" y2="192" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"></line></svg>
@@ -51,7 +51,7 @@ namespace :basecoat do
51
51
 
52
52
  unless importmap_content.include?("basecoat-css")
53
53
  File.open(importmap_path, "a") do |f|
54
- f.puts "\npin \"basecoat-css/all\", to: \"https://cdn.jsdelivr.net/npm/basecoat-css@0.3.9/dist/js/all.js\""
54
+ f.puts "\npin \"basecoat-css/all\", to: \"https://cdn.jsdelivr.net/npm/basecoat-css@0.3.10/dist/js/all.js\""
55
55
  end
56
56
  puts " Added: basecoat-css to config/importmap.rb"
57
57
  end
@@ -89,18 +89,6 @@ namespace :basecoat do
89
89
  puts " Added: cool view transition to app/javascript/application.js"
90
90
  end
91
91
 
92
- # Copy theme_controller.js
93
- theme_controller_source = File.expand_path("../generators/basecoat/templates/theme_controller.js", __dir__)
94
- theme_controller_destination = Rails.root.join("app/javascript/controllers/theme_controller.js")
95
-
96
- FileUtils.mkdir_p(File.dirname(theme_controller_destination))
97
- if prompt_overwrite(theme_controller_destination, overwrite_all)
98
- FileUtils.cp(theme_controller_source, theme_controller_destination)
99
- puts " Created: app/javascript/controllers/theme_controller.js"
100
- else
101
- puts " Skipped: app/javascript/controllers/theme_controller.js"
102
- end
103
-
104
92
  # Copy search_controller.js
105
93
  search_controller_source = File.expand_path("../generators/basecoat/templates/search_controller.js", __dir__)
106
94
  search_controller_destination = Rails.root.join("app/javascript/controllers/search_controller.js")
@@ -248,7 +236,7 @@ namespace :basecoat do
248
236
  head_content = File.read(head_path)
249
237
  unless head_content.include?("basecoat.cdn.min.css")
250
238
  cdn_link = ' <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
251
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/basecoat-css@0.3.9/dist/basecoat.cdn.min.css">'
239
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/basecoat-css@0.3.10/dist/basecoat.cdn.min.css">'
252
240
  # Insert before the closing </head> tag
253
241
  updated_content = head_content.sub(/(<\/head>)/, "#{cdn_link}\n\\1")
254
242
  File.write(head_path, updated_content)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basecoat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martijn Lafeber
@@ -92,7 +92,6 @@ files:
92
92
  - lib/generators/basecoat/templates/sessions.html.erb
93
93
  - lib/generators/basecoat/templates/sessions/new.html.erb
94
94
  - lib/generators/basecoat/templates/shared/_empty.html.erb
95
- - lib/generators/basecoat/templates/theme_controller.js
96
95
  - lib/tasks/basecoat.rake
97
96
  - lib/templates/erb/scaffold/_form.html.erb.tt
98
97
  - lib/templates/erb/scaffold/edit.html.erb.tt
@@ -1,29 +0,0 @@
1
- import { Controller } from "@hotwired/stimulus"
2
-
3
- export default class extends Controller {
4
- connect() {
5
- // Apply theme on initial load (runs immediately to prevent flash)
6
- this.applyStoredTheme()
7
- }
8
-
9
- toggle() {
10
- const isDark = !document.documentElement.classList.contains('dark')
11
- this.apply(isDark)
12
- }
13
-
14
- apply(dark) {
15
- document.documentElement.classList.toggle('dark', dark)
16
- try {
17
- localStorage.setItem('themeMode', dark ? 'dark' : 'light')
18
- } catch (_) {}
19
- }
20
-
21
- applyStoredTheme() {
22
- try {
23
- const stored = localStorage.getItem('themeMode')
24
- if (stored ? stored === 'dark' : matchMedia('(prefers-color-scheme: dark)').matches) {
25
- document.documentElement.classList.add('dark')
26
- }
27
- } catch (_) {}
28
- }
29
- }