basecoat 1.0.0 → 1.1.1

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: 7f0e95f47da5d59b6f37459c13aa840918f77d977be37d999b0d69601914a925
4
- data.tar.gz: e7e669105ff2d246223535996c94c7c103417462af0aeb59ae31ca993090f705
3
+ metadata.gz: 3273d016589877e63365f54753ec24490331270a14f2870024cf2c17e643d432
4
+ data.tar.gz: 48df591a8457651c29693b4a7430973146ca90b805307d99517da7525fdb9741
5
5
  SHA512:
6
- metadata.gz: 696dda706000f74e18239770381dc9899940f5713d84d5040306a4adccd1e89cdf47f6de18425826ce76934babc259af87769f4bac266f16c9eb7348304a3e48
7
- data.tar.gz: e8d9137fabcb2fcaf3d12809190ca5bb7c1e8f65ddd1144e1cbdff23adf06dce14d702fbc8a55ba6a5c931fa63e87c66a69c2c431da9f09f3d11c3464cf5c944
6
+ metadata.gz: 38950b35cb6a9e208f26876d42333ee6c48f08b2feb04f87af01696092b3ba414bf0a350ad55068ee93d42412e6cebc866c59cf5fe4428bc829a28159863187a
7
+ data.tar.gz: 5578532de781f2fc679a7742d407f0982eaa58f649b5d896b6bce361e19351173673bf889c1eef78790643d3a5ef2bb01f69d2e6fbd4bf5a6d0367502cd4cf7e
data/README.md CHANGED
@@ -1,26 +1,29 @@
1
- # All of the shadcn/ui styling, all of the Rails power, no React
1
+ # Basecoat (shadcn) powered views for Rails
2
2
 
3
- This gem provides you with amazing frontend based on [Basecoat CSS](https://basecoatui.com).
4
- It is especially powerful for admin applications with a lot of CRUD actions.
3
+ This gem provides you with amazing layouts, scaffolds, views and partials based on [Basecoat UI](https://basecoatui.com).
4
+ It is especially powerful for admin applications with a lot of CRUD actions.
5
5
 
6
- Experience beautiful Rails scaffolds, pages for authentication and Devise, and pagy styling.
7
- All responsive, all dark & light mode. See all the features below.
6
+ Beautiful responsive, dark & light mode Rails scaffolds, pages for authentication and Devise, and pagy styling.
7
+
8
+ Login:
9
+ ![Basecoat Login](basecoat-login.png)
10
+ Index:
11
+ ![Basecoat Index](basecoat-index.png)
12
+ Form, mobile dark mode:
13
+ ![Basecoat Dark Form](basecoat-dark-form.png)
8
14
 
9
15
  ## Why?
10
16
 
11
- There is a new default component library for the web; it's called shadcn.
12
- As a developer you are standing on the shoulders of a giant with every component they provide.
13
- However... in many (most?) applications you don't need complicated components -
14
- e.g. an input field can just be a html tag, not a separate component with its own shadow DOM.
17
+ Shadcn has quickly become the default ui for the web. However, sometimes we don't _really_ need all the React components.
18
+ Especially with backend applications - where Rails shines as full stack solution.
15
19
 
16
- This is where basecoat-css comes in.
20
+ This is where basecoat-ui comes in. The reason why I love basecoat is because it combines tailwind with clean css classes (like daisy-ui).
17
21
 
18
- You can still include complicated shadcn React components if you need them,
19
- but most of your application is just the simple rails views, leveraging the power of Rails.
22
+ If you need more complex components; enrich the views with https://railsblocks.com/ or https://shadcn.rails-components.com/ or just the shadcn React components themselves.
20
23
 
21
24
  ## Installation
22
25
 
23
- Add this line to your application's Gemfile:
26
+ Add this line to your application's Gemfile in the development group:
24
27
 
25
28
  ```ruby
26
29
  gem 'basecoat'
@@ -45,22 +48,7 @@ Install the Basecoat application layout and partials:
45
48
  ```bash
46
49
  rake basecoat:install
47
50
  ```
48
-
49
- This will:
50
- - Install `basecoat-css` via yarn/npm (if package.json exists) or importmap
51
- - Add basecoat-css import to `app/javascript/application.js`
52
- - Add view transition JavaScript for turbo frames
53
- - Add dark mode toggle functionality
54
- - Add view transition CSS animations and form validation styles
55
- - Copy application layout to `app/views/layouts/application.html.erb`
56
- - Copy layout partials (`_head.html.erb`, `_header.html.erb`, `_aside.html.erb`, `_notice.html.erb`, `_alert.html.erb`, `_form_errors.html.erb`)
57
- - Copy scaffold hook initializer to `config/initializers/scaffold_hook.rb`
58
-
59
- The scaffold templates are automatically available from the gem, so you can immediately generate scaffolds:
60
-
61
- ```bash
62
- rails generate scaffold Post title:string body:text published:boolean
63
- ```
51
+ NB: This could overwrite exising files!
64
52
 
65
53
  The generated views will include:
66
54
  * Basecoat CSS styling
@@ -72,43 +60,20 @@ The generated views will include:
72
60
  * Boolean fields styled as switches
73
61
  * Automatic sidebar navigation links
74
62
 
75
- ### Install Devise Views
76
-
77
- Install the Basecoat-styled Devise views and layout:
63
+ The scaffold templates are automatically available from the gem, so you can immediately generate scaffolds:
78
64
 
79
65
  ```bash
80
- rake basecoat:install:devise
66
+ rails generate scaffold Post title:string body:text published:boolean
81
67
  ```
82
68
 
83
- This will copy:
84
- - All Devise views to `app/views/devise/`
85
- - Devise layout to `app/views/layouts/devise.html.erb`
86
-
87
- The Devise views include:
88
- - Beautiful login/signup forms
89
- * Two-column layout with image placeholder
90
- * Dark mode toggle
91
- * Responsive design
92
- * Password reset flows
93
- * Email confirmation views
94
-
95
- ### Install Pagy Pagination Styles
69
+ ### Install Devise Views
96
70
 
97
- Install the Basecoat-styled Pagy pagination:
71
+ Install the Basecoat-styled Devise views and layout:
98
72
 
99
73
  ```bash
100
- rake basecoat:install:pagy
74
+ rake basecoat:install:devise
101
75
  ```
102
-
103
- This will copy:
104
- - Pagy styles to `app/assets/stylesheets/pagy.scss`
105
-
106
- The Pagy styles include:
107
-
108
- * Basecoat CSS button styling using `@apply`
109
- * Proper spacing and layout
110
- * Active page highlighting
111
- * Disabled state styling
76
+ NB: This will overwrite exising files!
112
77
 
113
78
  ### Install Authentication Views
114
79
 
@@ -117,78 +82,42 @@ Install the Basecoat-styled authentication views (for Rails built-in authenticat
117
82
  ```bash
118
83
  rake basecoat:install:authentication
119
84
  ```
85
+ NB: This will overwrite exising files!
120
86
 
121
- This will copy:
122
- - Sessions views to `app/views/sessions/`
123
- - Passwords views to `app/views/passwords/`
124
- - Sessions layout to `app/views/layouts/sessions.html.erb`
125
- - Adds `layout "sessions"` to `app/controllers/passwords_controller.rb`
126
-
127
- The authentication views include:
128
-
129
- * Beautiful sign in form
130
- * Password reset flows
131
- * Two-column layout with image placeholder
132
- * Dark mode toggle
133
- * Responsive design
134
- * Consistent styling with Devise views
135
-
136
- ## Features
137
-
138
- ### Application Layout
139
-
140
- - **Sidebar Navigation**: Collapsible sidebar with automatic active state detection
141
- - **Header**: User dropdown with sign out functionality
142
- - **Alerts & Notices**: Beautiful toast notifications for flash messages
143
- - **Form Errors**: Consistent error message styling
144
- - **Dark Mode**: Built-in theme toggle
145
-
146
- ### Scaffold Templates
147
-
148
- - **Modern UI**: Clean, professional design using Basecoat CSS
149
- - **Turbo Frames**: SPA-like navigation without full page reloads
150
- - **View Transitions**: Smooth slide animations between pages
151
- - **Smart Forms**: Automatic required field detection based on database schema
152
- - **Auto Sidebar Links**: New scaffolds automatically add navigation links to sidebar
153
- - **Dark Mode**: Built-in dark mode support
154
- - **Responsive**: Mobile-first responsive design
87
+ ### Install Pagy Pagination Styles
155
88
 
156
- ### Devise Views
89
+ Install the Basecoat-styled Pagy pagination:
157
90
 
158
- - **Professional Design**: Matches modern authentication UI patterns
159
- - **Two-Column Layout**: Image placeholder with form on desktop
160
- - **Complete Views**: All Devise views including confirmations, passwords, registrations
161
- - **Dark Mode**: Toggle between light and dark themes
162
- - **Accessible**: ARIA labels and semantic HTML
91
+ ```bash
92
+ rake basecoat:install:pagy
93
+ ```
163
94
 
164
95
  ## Requirements
165
96
 
166
97
  - Rails 8.0+
167
98
  - Tailwind CSS ([installation instructions](https://github.com/rails/tailwindcss-rails))
168
99
  - Basecoat CSS
169
- - Turbo Rails (for scaffold templates)
170
100
  - Stimulus (for the theme toggle, can be moved to something else if you desire...)
171
101
 
172
- ## How It Works
173
-
174
- The gem uses Rails' template resolution system to provide scaffold templates automatically. When you run `rails generate scaffold`, Rails will use the templates from the Basecoat gem instead of the default ones.
175
-
176
- The application layout and partials are copied to your application so you can customize them as needed.
177
-
178
102
  ## Discussion
179
103
 
180
- I tried not to be too opinionated with my scaffolds - they're very close to the original ones. With the exception of
181
- using a turbo frame main_content. I love this too much not to include it.
182
-
183
- However, I have my doubts with the index page reusing the show partial. Especially in admin applications you might want
184
- to have a (responsive) table in the index.
104
+ The scaffolds are more opinionated than the default - it includes a main turbo frame.
105
+ I also strongly feel that the index should not reuse the partial used in show - it defeats the purpose of the show page.
106
+ A responsive table was the best I could come up with - closer to the OG scaffolds before Hotwire.
185
107
 
186
- Also, the arguably ugliest part of the views are the svg tags which contains the lovely lucide icons.
108
+ Also, the (arguably) most messy part of the views are the svg tags which contain the lovely lucide icons.
187
109
  Since these icons are the default for shadcn I'm considering including https://github.com/heyvito/lucide-rails to clean up the views.
188
110
 
111
+ ## Issues
112
+
113
+ * The javascript included by basecoat needs some improvement. It's not automatically initialized on turbo:load - included is a hack that I hope is temporary.
114
+ * We include extra css for the definition list. Hopefully this will be part of basecoat-css someday.
115
+ * Rails adds class="field_with_errors", so we need extra css for this. I hope Rails will at some point have aria-invalid="true" on the input, basecoat will apply the correct styling.
116
+ * Can the views even be prettier? Probably! I'm more than happy to discuss improvements:
117
+
189
118
  ## Contributing
190
119
 
191
- Bug reports and pull requests are welcome on GitHub.
120
+ Bug reports and pull requests are more than welcome on GitHub!
192
121
 
193
122
  ## License
194
123
 
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Basecoat
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.1"
5
5
  end
@@ -4,6 +4,6 @@
4
4
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2"></rect><path d="M9 3v18"></path></svg>
5
5
  </button>
6
6
  <%= render "layouts/theme_toggle" %>
7
- <!-- DEVISE_USER_DROPDOWN -->
7
+ <!-- AUTHENTICATION_DROPDOWN -->
8
8
  </div>
9
9
  </header>
@@ -236,7 +236,7 @@ namespace :basecoat do
236
236
  </div>
237
237
  <% end %>
238
238
  HTML
239
- updated_content = header_content.sub("<!-- DEVISE_USER_DROPDOWN -->", user_dropdown)
239
+ updated_content = header_content.sub("<!-- AUTHENTICATION_DROPDOWN -->", user_dropdown)
240
240
  File.write(header_path, updated_content)
241
241
  puts " Added: User dropdown to app/views/layouts/_header.html.erb"
242
242
  end
@@ -317,6 +317,37 @@ namespace :basecoat do
317
317
  end
318
318
  end
319
319
 
320
+ # Add user dropdown to header partial
321
+ header_path = Rails.root.join("app/views/layouts/_header.html.erb")
322
+ if File.exist?(header_path)
323
+ header_content = File.read(header_path)
324
+ unless header_content.include?("dropdown-user")
325
+ user_dropdown = <<~HTML
326
+
327
+ <% if defined?(Current) && defined?(Current.user) && Current.user %>
328
+ <div id="dropdown-user" class="dropdown-menu">
329
+ <button type="button" id="dropdown-user-trigger" aria-haspopup="menu" aria-controls="dropdown-user-menu" aria-expanded="false" class="btn-icon-ghost rounded-full size-8">
330
+ <img alt="<%= Current.user.email_address %>" src="https://github.com/lafeber.png" class="size-8 shrink-0 rounded-full">
331
+ </button>
332
+ <div id="dropdown-user-popover" data-popover="" aria-hidden="true" data-align="end">
333
+ <div role="menu" id="dropdown-user-menu" aria-labelledby="dropdown-user-trigger">
334
+ <div class="px-1 py-1.5">
335
+ <%= button_to session_path, method: :delete, class: "btn-link" do %>
336
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path><polyline points="16 17 21 12 16 7"></polyline><line x1="21" y1="12" x2="9" y2="12"></line></svg>
337
+ Log out
338
+ <% end %>
339
+ </div>
340
+ </div>
341
+ </div>
342
+ </div>
343
+ <% end %>
344
+ HTML
345
+ updated_content = header_content.sub("<!-- AUTHENTICATION_DROPDOWN -->", user_dropdown)
346
+ File.write(header_path, updated_content)
347
+ puts " Added: User dropdown to app/views/layouts/_header.html.erb"
348
+ end
349
+ end
350
+
320
351
  puts "\n✓ Basecoat authentication views installed successfully!"
321
352
  puts " Make sure you have Rails authentication configured in your application."
322
353
  end
@@ -8,20 +8,20 @@
8
8
  <div class="overflow-x-auto" id="<%= plural_table_name %>">
9
9
  <table class="table">
10
10
  <thead>
11
- <tr class="bg-background hover:bg-muted">
11
+ <tr class="hover:bg-background">
12
12
  <% attributes.reject(&:password_digest?).each do |attribute| -%>
13
13
  <th>
14
14
  <%= attribute.human_name %>
15
15
  </th>
16
16
  <% end -%>
17
- <th class="sticky right-0">
17
+ <th class="bg-background sticky right-0">
18
18
  Actions
19
19
  </th>
20
20
  </tr>
21
21
  </thead>
22
22
  <tbody>
23
23
  <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
24
- <tr>
24
+ <tr class="hover:bg-background">
25
25
  <% attributes.reject(&:password_digest?).each do |attribute| -%>
26
26
  <td>
27
27
  <% if attribute.attachment? -%>
@@ -35,7 +35,7 @@
35
35
  <% end -%>
36
36
  </td>
37
37
  <% end -%>
38
- <td class="sticky right-0">
38
+ <td class="bg-background sticky right-0">
39
39
  <%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "btn-outline", data: { turbo_action: "advance" } %>
40
40
  </td>
41
41
  </tr>
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: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martijn Lafeber
@@ -40,6 +40,9 @@ files:
40
40
  - LICENSE.txt
41
41
  - README.md
42
42
  - Rakefile
43
+ - basecoat-dark-form.png
44
+ - basecoat-index.png
45
+ - basecoat-login.png
43
46
  - lib/basecoat.rb
44
47
  - lib/basecoat/railtie.rb
45
48
  - lib/basecoat/version.rb