administrate_tailwind_theme 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/README.md +32 -10
- data/app/views/admin/application/_default_sidebar.html.erb +31 -0
- data/app/views/admin/application/_flowbite_sidebar.html.erb +59 -0
- data/app/views/admin/application/_navigation.html.erb +6 -30
- data/app/views/administrate/application/index.html.erb +1 -1
- data/app/views/administrate/navigation/icons/_main.html.erb +3 -0
- data/app/views/fields/has_many/_show.html.erb +14 -12
- data/app/views/fields/polymorphic/_show.html.erb +9 -7
- data/app/views/layouts/admin/application.html.erb +3 -0
- data/docs/upgrade_to_0.0.4.md +60 -0
- data/images/screenshot.png +0 -0
- data/lib/administrate_tailwind_theme/configuration.rb +13 -0
- data/lib/administrate_tailwind_theme/version.rb +1 -1
- data/lib/administrate_tailwind_theme/view_helper.rb +28 -0
- data/lib/administrate_tailwind_theme.rb +1 -0
- data/lib/generators/administrate_tailwind_theme/install/install_generator.rb +43 -0
- data/lib/generators/administrate_tailwind_theme/views/navigation_generator.rb +2 -0
- metadata +9 -3
- /data/app/views/administrate/navigation/icons/{_users.erb → _users.html.erb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0a6927b2d3d38ece3b4041b212a0f327bcc694f5599b4124a3996d674688522
|
4
|
+
data.tar.gz: 151998dd3381f1e0f8b63e66903d7e3859287f4fe14dbe99da1aeb1170a864c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6f61e6582f5e25904128ea134ea1fd78e03edced665c5f0b24af489cf94e458ccdea7f1b95e81125a910e25b3a1f1b641b2235e9fde49267ff89cbe03ebfc5f
|
7
|
+
data.tar.gz: f13562a2e762f9de51df24605b87e056fc5f317d25e535de33344099b08810805b1838c03ae1f9b5f21de643d6906108c344d4da009c4f0eeaa7cd43203783f6
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/), and this project adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
|
5
|
+
## [0.0.4] - 2024-01-31
|
6
|
+
### Added
|
7
|
+
- Integration of Flowbite, including configuration and installer (`Add Flowbite config and installer`).
|
8
|
+
- Flowbite framework to enhance UI/UX design (`Add Flowbite`).
|
9
|
+
- Horizontal scrolling for tables to improve UI (`Feature: Add overflow scroll x on tables`).
|
10
|
+
|
11
|
+
### Upgrade
|
12
|
+
- Add [documentation](docs/upgrade_to_0.0.4.md) to upgrade from previous versions
|
13
|
+
|
14
|
+
## [0.0.3] - 2024-01-31
|
15
|
+
### Changed
|
16
|
+
- Update to generator tool or script (`Update generator`).
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
- Improvements to project specifications or tests (`Fix specs`).
|
20
|
+
|
21
|
+
## [0.0.2] - 2024-01-24
|
22
|
+
### Added
|
23
|
+
- GitHub Actions workflow for automated gem pushing (`Add GitHub Actions for gem push`).
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
- Update to `.gitignore` to refine project configuration.
|
27
|
+
|
28
|
+
## [0.0.1] - 2024-01-17
|
29
|
+
### Added
|
30
|
+
- Initial release with basic theme setup.
|
31
|
+
|
32
|
+
## [0.0.0] - 2024-01-10
|
33
|
+
### Fixed
|
34
|
+
- Minor bug fixes and performance improvements.
|
35
|
+
|
36
|
+
### Changed
|
37
|
+
- Adjustments to `.gitignore` and initial project setup.
|
38
|
+
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# administrate_tailwind_theme Gem
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/administrate_tailwind_theme.svg)](https://badge.fury.io/rb/administrate_tailwind_theme)
|
2
3
|
[![AdministrateTailwindTheme CI](https://github.com/Eth3rnit3/administrate-tailwind-theme/actions/workflows/main.yml/badge.svg)](https://github.com/Eth3rnit3/administrate-tailwind-theme/actions/workflows/main.yml)
|
3
4
|
[![Publish on RubyGems](https://github.com/Eth3rnit3/administrate-tailwind-theme/actions/workflows/gem-push.yml/badge.svg)](https://github.com/Eth3rnit3/administrate-tailwind-theme/actions/workflows/gem-push.yml)
|
4
5
|
|
@@ -11,6 +12,7 @@
|
|
11
12
|
- **Additional Fields:** Adds BooleanEmoji and CountryEmoji fields to your Administrate dashboard.
|
12
13
|
- **Easy Setup:** Automatic initializer creation and configuration.
|
13
14
|
- **Rails 7, Rails-Tailwind, and Administrate Compatibility:** Seamlessly works with the latest versions of these key gems.
|
15
|
+
- **Flowbite** Bringing a comprehensive suite of Tailwind CSS
|
14
16
|
|
15
17
|
## Installation
|
16
18
|
### Prerequisites
|
@@ -19,26 +21,33 @@
|
|
19
21
|
- Administrate 0.15 or higher.
|
20
22
|
- Tailwind CSS Rails 2.0 or higher.
|
21
23
|
|
24
|
+
### Flowbite Integration
|
25
|
+
administrate_tailwind_theme now comes with Flowbite integration by default, bringing a rich set of Tailwind CSS components to your Administrate dashboard. For those who prefer not to use Flowbite, it can be easily disabled during the installation of the gem by setting the `FLOWBITE=false` environment variable.
|
26
|
+
|
22
27
|
### Setup
|
23
28
|
1. Add this line to your application's Gemfile:
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
```ruby
|
31
|
+
gem 'administrate_tailwind_theme'
|
32
|
+
```
|
28
33
|
|
29
34
|
2. Execute:
|
30
35
|
|
31
|
-
|
32
|
-
|
33
|
-
|
36
|
+
```
|
37
|
+
bundle install
|
38
|
+
```
|
34
39
|
|
35
40
|
3. After installing the gem, run the installer:
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
```shell
|
43
|
+
# With flowbite integration (default since 0.0.4)
|
44
|
+
rails generate administrate_tailwind_theme:install
|
45
|
+
|
46
|
+
# Without flowbite integration
|
47
|
+
FLOWBITE=false rails generate administrate_tailwind_theme:install
|
48
|
+
```
|
40
49
|
|
41
|
-
|
50
|
+
This will create an initializer and modify your `tailwind.config.js` to ensure proper compilation of the gem's view styles.
|
42
51
|
|
43
52
|
## Usage
|
44
53
|
|
@@ -70,6 +79,19 @@ AdministrateTailwindTheme:
|
|
70
79
|
./bin/rails g administrate_tailwind_theme:views:kaminari
|
71
80
|
```
|
72
81
|
|
82
|
+
### Navigations
|
83
|
+
#### Icons
|
84
|
+
For customizing the navigation menu with icons, you can include SVG files for each resource. Here's an example for adding an icon for `User` model:
|
85
|
+
|
86
|
+
```html
|
87
|
+
<!-- app/views/administrate/navigation/icons/_users.html.erb -->
|
88
|
+
<svg class="w-5 h-5 text-gray-500 transition duration-75 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
89
|
+
<!-- SVG path for user icon -->
|
90
|
+
</svg>
|
91
|
+
```
|
92
|
+
|
93
|
+
Place this SVG file in the specified directory, and it will automatically be displayed next to the corresponding resource in the navigation menu.
|
94
|
+
|
73
95
|
### Custom Fields
|
74
96
|
#### BooleanEmoji Field
|
75
97
|
The `BooleanEmoji` field can be used to display boolean values with emojis for a more intuitive representation.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!-- Default Sidebar -->
|
2
|
+
<aside id="default-sidebar" class="fixed top-0 left-0 z-40 w-64 h-screen transition-transform -translate-x-full sm:translate-x-0" aria-label="Sidebar">
|
3
|
+
<div class="h-full px-3 py-4 overflow-y-auto bg-gray-50 dark:bg-gray-800">
|
4
|
+
<ul class="space-y-2 font-medium">
|
5
|
+
<% if defined?(root_path) %>
|
6
|
+
<li>
|
7
|
+
<%= link_to(root_path, class: "flex items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700 group") do %>
|
8
|
+
<svg class="w-5 h-5 text-gray-500 transition duration-75 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 22 21">
|
9
|
+
<path d="M4 10L3.29289 10.7071L2.58579 10L3.29289 9.29289L4 10ZM21 18C21 18.5523 20.5523 19 20 19C19.4477 19 19 18.5523 19 18L21 18ZM8.29289 15.7071L3.29289 10.7071L4.70711 9.29289L9.70711 14.2929L8.29289 15.7071ZM3.29289 9.29289L8.29289 4.29289L9.70711 5.70711L4.70711 10.7071L3.29289 9.29289ZM4 9L14 9L14 11L4 11L4 9ZM21 16L21 18L19 18L19 16L21 16ZM14 9C17.866 9 21 12.134 21 16L19 16C19 13.2386 16.7614 11 14 11L14 9Z" fill="#33363F"/>
|
10
|
+
</svg>
|
11
|
+
<span class="ms-3">
|
12
|
+
<%= t("administrate.navigation.back_to_app") %>
|
13
|
+
</span>
|
14
|
+
<% end %>
|
15
|
+
</li>
|
16
|
+
<% end %>
|
17
|
+
<% Administrate::Namespace.new(namespace).resources_with_index_route.each do |resource| %>
|
18
|
+
<% if accessible_action?(model_from_resource(resource), :index) %>
|
19
|
+
<%= link_to(resource_index_route(resource), class: "flex items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700 group #{'bg-gray-100' if nav_link_state(resource)&.to_sym == :active }") do %>
|
20
|
+
<% if icon?(resource) %>
|
21
|
+
<%= render partial: "administrate/navigation/icons/#{resource}" %>
|
22
|
+
<% end %>
|
23
|
+
<span class="ms-3">
|
24
|
+
<%= display_resource_name(resource) %>
|
25
|
+
</span>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
</ul>
|
30
|
+
</div>
|
31
|
+
</aside>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<!-- Flowbite Sidebar -->
|
2
|
+
<button data-drawer-target="default-sidebar" data-drawer-toggle="default-sidebar" aria-controls="default-sidebar" type="button" class="inline-flex items-center p-2 mt-2 ml-3 text-sm text-gray-500 rounded-lg sm:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600">
|
3
|
+
<button data-drawer-target="sidebar-multi-level-sidebar" data-drawer-toggle="sidebar-multi-level-sidebar" aria-controls="sidebar-multi-level-sidebar" type="button" class="inline-flex items-center p-2 mt-2 ms-3 text-sm text-gray-500 rounded-lg sm:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600">
|
4
|
+
<span class="sr-only">Open sidebar</span>
|
5
|
+
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
6
|
+
<path clip-rule="evenodd" fill-rule="evenodd" d="M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zm0 10.5a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5a.75.75 0 01-.75-.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10z"></path>
|
7
|
+
</svg>
|
8
|
+
</button>
|
9
|
+
|
10
|
+
<aside id="sidebar-multi-level-sidebar" class="fixed top-0 left-0 z-40 w-64 h-screen transition-transform -translate-x-full sm:translate-x-0" aria-label="Sidebar">
|
11
|
+
<div class="h-full px-3 py-4 overflow-y-auto bg-gray-50 dark:bg-gray-800">
|
12
|
+
<ul class="space-y-2 font-medium">
|
13
|
+
<% if defined?(root_path) %>
|
14
|
+
<li>
|
15
|
+
<%= link_to(root_path, class: "flex items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700 group") do %>
|
16
|
+
<svg class="w-5 h-5 text-gray-500 transition duration-75 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 22 21">
|
17
|
+
<path d="M4 10L3.29289 10.7071L2.58579 10L3.29289 9.29289L4 10ZM21 18C21 18.5523 20.5523 19 20 19C19.4477 19 19 18.5523 19 18L21 18ZM8.29289 15.7071L3.29289 10.7071L4.70711 9.29289L9.70711 14.2929L8.29289 15.7071ZM3.29289 9.29289L8.29289 4.29289L9.70711 5.70711L4.70711 10.7071L3.29289 9.29289ZM4 9L14 9L14 11L4 11L4 9ZM21 16L21 18L19 18L19 16L21 16ZM14 9C17.866 9 21 12.134 21 16L19 16C19 13.2386 16.7614 11 14 11L14 9Z" fill="#33363F"/>
|
18
|
+
</svg>
|
19
|
+
<span class="ms-3">
|
20
|
+
<%= t("administrate.navigation.back_to_app") %>
|
21
|
+
</span>
|
22
|
+
<% end %>
|
23
|
+
</li>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<% grouped_resources.map do |group_name, resources| %>
|
27
|
+
<li>
|
28
|
+
<button type="button" class="flex items-center w-full p-2 text-base text-gray-900 transition duration-75 rounded-lg group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700" aria-controls="dropdown-example-<%= group_name %>" data-collapse-toggle="dropdown-example-<%= group_name %>">
|
29
|
+
<% if icon?(group_name) %>
|
30
|
+
<%= render partial: "administrate/navigation/icons/#{group_name}" %>
|
31
|
+
<% end %>
|
32
|
+
<span class="flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">
|
33
|
+
<%= group_name.to_s.capitalize %>
|
34
|
+
</span>
|
35
|
+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
36
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
37
|
+
</svg>
|
38
|
+
</button>
|
39
|
+
<ul id="dropdown-example-<%= group_name %>" class="hidden py-2 space-y-2">
|
40
|
+
<% resources.map do |resource| %>
|
41
|
+
<% if accessible_action?(model_from_resource(resource), :index) %>
|
42
|
+
<li>
|
43
|
+
<%= link_to(resource_index_route(resource), class: "flex items-center w-full p-2 text-gray-900 transition duration-75 rounded-lg pl-11 group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700 #{'bg-gray-200' if nav_link_state(resource)&.to_sym == :active }") do %>
|
44
|
+
<% if icon?(resource) %>
|
45
|
+
<%= render partial: "administrate/navigation/icons/#{resource}" %>
|
46
|
+
<% end %>
|
47
|
+
<span class="ms-3">
|
48
|
+
<%= display_resource_name(resource) %>
|
49
|
+
</span>
|
50
|
+
<% end %>
|
51
|
+
</li>
|
52
|
+
<% end %>
|
53
|
+
<% end %>
|
54
|
+
</ul>
|
55
|
+
</li>
|
56
|
+
<% end %>
|
57
|
+
</ul>
|
58
|
+
</div>
|
59
|
+
</aside>
|
@@ -7,33 +7,9 @@ for all resources in the admin dashboard,
|
|
7
7
|
as defined by the routes in the `admin/` namespace
|
8
8
|
%>
|
9
9
|
<!-- Navigation Sidebar -->
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<svg class="w-5 h-5 text-gray-500 transition duration-75 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 22 21">
|
17
|
-
<path d="M4 10L3.29289 10.7071L2.58579 10L3.29289 9.29289L4 10ZM21 18C21 18.5523 20.5523 19 20 19C19.4477 19 19 18.5523 19 18L21 18ZM8.29289 15.7071L3.29289 10.7071L4.70711 9.29289L9.70711 14.2929L8.29289 15.7071ZM3.29289 9.29289L8.29289 4.29289L9.70711 5.70711L4.70711 10.7071L3.29289 9.29289ZM4 9L14 9L14 11L4 11L4 9ZM21 16L21 18L19 18L19 16L21 16ZM14 9C17.866 9 21 12.134 21 16L19 16C19 13.2386 16.7614 11 14 11L14 9Z" fill="#33363F"/>
|
18
|
-
</svg>
|
19
|
-
<span class="ms-3">
|
20
|
-
<%= t("administrate.navigation.back_to_app") %>
|
21
|
-
</span>
|
22
|
-
<% end %>
|
23
|
-
</li>
|
24
|
-
<% end %>
|
25
|
-
<% Administrate::Namespace.new(namespace).resources_with_index_route.each do |resource| %>
|
26
|
-
<% if accessible_action?(model_from_resource(resource), :index) %>
|
27
|
-
<%= link_to(resource_index_route(resource), class: "flex items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700 group #{'bg-gray-100' if nav_link_state(resource)&.to_sym == :active }") do %>
|
28
|
-
<% if icon?(resource) %>
|
29
|
-
<%= render partial: "administrate/navigation/icons/#{resource}" %>
|
30
|
-
<% end %>
|
31
|
-
<span class="ms-3">
|
32
|
-
<%= display_resource_name(resource) %>
|
33
|
-
</span>
|
34
|
-
<% end %>
|
35
|
-
<% end %>
|
36
|
-
<% end %>
|
37
|
-
</ul>
|
38
|
-
</div>
|
39
|
-
</aside>
|
10
|
+
|
11
|
+
<% if flowbite? %>
|
12
|
+
<%= render partial: 'admin/application/flowbite_sidebar' %>
|
13
|
+
<% else %>
|
14
|
+
<%= render partial: 'admin/application/default_sidebar' %>
|
15
|
+
<% end %>
|
@@ -32,7 +32,7 @@ It renders the `_table` partial to display details about the resources.
|
|
32
32
|
)
|
33
33
|
%>
|
34
34
|
|
35
|
-
<section class="m-5 bg-white shadow overflow-hidden rounded-lg">
|
35
|
+
<section class="m-5 bg-white shadow overflow-hidden overflow-x-scroll rounded-lg">
|
36
36
|
<%= render(
|
37
37
|
"collection",
|
38
38
|
collection_presenter: page,
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<svg class="w-5 h-5 text-gray-500 transition duration-75 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 22 21">
|
2
|
+
<path d="M21.66,10.25l-9-8a1,1,0,0,0-1.32,0l-9,8a1,1,0,0,0-.27,1.11A1,1,0,0,0,3,12H4v9a1,1,0,0,0,1,1H19a1,1,0,0,0,1-1V12h1a1,1,0,0,0,.93-.64A1,1,0,0,0,21.66,10.25ZM13,20H11V17a1,1,0,0,1,2,0Zm5,0H15V17a3,3,0,0,0-6,0v3H6V12H18ZM5.63,10,12,4.34,18.37,10Z"/>
|
3
|
+
</svg>
|
@@ -21,18 +21,20 @@ from the associated resource class's dashboard.
|
|
21
21
|
<% if field.resources.any? %>
|
22
22
|
<% order = field.order_from_params(params.fetch(field.name, {})) %>
|
23
23
|
<% page_number = params.fetch(field.name, {}).fetch(:page, nil) %>
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
<section class="mt-1 mb-1 pb-2 bg-white shadow overflow-hidden overflow-x-scroll rounded-lg">
|
25
|
+
<%= render(
|
26
|
+
"collection",
|
27
|
+
collection_presenter: field.associated_collection(order),
|
28
|
+
collection_field_name: field.name,
|
29
|
+
page: page,
|
30
|
+
resources: field.resources(page_number, order),
|
31
|
+
table_title: field.name,
|
32
|
+
resource_class: field.associated_class,
|
33
|
+
) %>
|
34
|
+
<% if field.more_than_limit? %>
|
35
|
+
<%= render("pagination", resources: field.resources(page_number), param_name: "#{field.name}[page]") %>
|
36
|
+
<% end %>
|
37
|
+
</section>
|
36
38
|
|
37
39
|
<% else %>
|
38
40
|
<%= t("administrate.fields.has_many.none", default: "–") %>
|
@@ -18,15 +18,17 @@ By default, the relationship is rendered as a link to the associated object.
|
|
18
18
|
|
19
19
|
<% if field.data %>
|
20
20
|
<% if accessible_action?(field.data, :show) %>
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
<div class="bg-gray-50 p-3 rounded-md shadow-sm">
|
22
|
+
<%= link_to(
|
23
|
+
field.display_associated_resource,
|
24
|
+
[namespace, field.data],
|
25
|
+
class: "text-blue-600 hover:text-blue-800 visited:text-purple-600"
|
26
|
+
) %>
|
27
|
+
</div>
|
26
28
|
<% else %>
|
27
|
-
<
|
29
|
+
<div class="bg-gray-50 p-3 rounded-md shadow-sm">
|
28
30
|
<%= field.display_associated_resource %>
|
29
|
-
</
|
31
|
+
</div>
|
30
32
|
<% end %>
|
31
33
|
<% end %>
|
32
34
|
|
@@ -24,6 +24,9 @@ By default, it renders:
|
|
24
24
|
<%= stylesheet_link_tag 'tailwind', 'data-turbo-track': 'reload' %>
|
25
25
|
<%= stylesheet_link_tag 'administrate-tailwind-theme', 'data-turbo-track': 'reload' %>
|
26
26
|
<%= javascript_include_tag 'administrate-tailwind-theme', 'data-turbo-track': 'reload', defer: true %>
|
27
|
+
<%- if flowbite? %>
|
28
|
+
<%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.js', defer: true %>
|
29
|
+
<% end %>
|
27
30
|
|
28
31
|
</head>
|
29
32
|
<body class="bg-gray-100">
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# How to Upgrade to Include Flowbite
|
2
|
+
|
3
|
+
Upgrading from a version prior to 0.0.4 to include Flowbite in your project involves several key steps. Follow this guide to ensure a smooth transition and to leverage the enhancements offered by Flowbite within your administrate-tailwind-theme setup.
|
4
|
+
|
5
|
+
## Step 1: Upgrade the Gem
|
6
|
+
|
7
|
+
First, ensure that you update the `administrate-tailwind-theme` gem to the latest version. Modify your Gemfile to specify the new version:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'administrate-tailwind-theme', '~> 0.4.0'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then, run `bundle update administrate-tailwind-theme` to update the gem in your project.
|
14
|
+
|
15
|
+
## Step 2: Install Flowbite
|
16
|
+
|
17
|
+
Flowbite must be installed manually using npm to ensure it's properly integrated into your project. Navigate to the root of your project and run the following command:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
npm install flowbite --save
|
21
|
+
```
|
22
|
+
|
23
|
+
This command adds Flowbite to your project's dependencies, ensuring you have the latest version compatible with the administrate-tailwind-theme.
|
24
|
+
|
25
|
+
## Step 3: Update Tailwind Configuration
|
26
|
+
|
27
|
+
Modify your `tailwind.config.js` file to include the necessary configurations for Flowbite. You should add Flowbite as a plugin in your Tailwind configuration. Here is an example modification:
|
28
|
+
|
29
|
+
```javascript
|
30
|
+
module.exports = {
|
31
|
+
// Existing configuration...
|
32
|
+
content: [
|
33
|
+
// Other content...
|
34
|
+
'./node_modules/flowbite/**/*.js',
|
35
|
+
],
|
36
|
+
plugins: [
|
37
|
+
// Other plugins...
|
38
|
+
require('flowbite/plugin')
|
39
|
+
],
|
40
|
+
};
|
41
|
+
```
|
42
|
+
|
43
|
+
Ensure you merge this snippet with your existing Tailwind configuration, paying special attention not to overwrite any existing settings.
|
44
|
+
|
45
|
+
## Step 4: Enable Flowbite in the Initializer
|
46
|
+
|
47
|
+
After installing the gem, an initializer file is generated for the administrate-tailwind-theme. You'll need to modify this initializer to enable Flowbite within your project. Open the initializer (typically found at `config/initializers/administrate_tailwind_theme.rb`) and add or modify the following line:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
AdministrateTailwindTheme.config.flowbite = true
|
51
|
+
```
|
52
|
+
|
53
|
+
This line ensures that Flowbite is enabled and that the administrate-tailwind-theme will utilize its components and styling.
|
54
|
+
|
55
|
+
## Final Steps
|
56
|
+
```shell
|
57
|
+
./bin/dev
|
58
|
+
```
|
59
|
+
|
60
|
+
After completing these steps, ensure that you test your application thoroughly to confirm that the upgrade has been successful and that Flowbite components are correctly integrated and functioning as expected.
|
data/images/screenshot.png
CHANGED
Binary file
|
@@ -18,5 +18,33 @@ module AdministrateTailwindTheme
|
|
18
18
|
def icon?(resource)
|
19
19
|
lookup_context.find_all("administrate/navigation/icons/_#{resource}").any?
|
20
20
|
end
|
21
|
+
|
22
|
+
def flowbite?
|
23
|
+
AdministrateTailwindTheme::Configuration.flowbite
|
24
|
+
end
|
25
|
+
|
26
|
+
def grouped_resources
|
27
|
+
resources = Administrate::Namespace.new(namespace).resources_with_index_route.map do |resource|
|
28
|
+
[group(resource), resource]
|
29
|
+
end
|
30
|
+
|
31
|
+
resources = resources.group_by { |group, _resource| group }
|
32
|
+
resources.map do |group_name, g_resources|
|
33
|
+
[
|
34
|
+
group_name,
|
35
|
+
g_resources.map(&:last)
|
36
|
+
]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def group(resource)
|
41
|
+
dashboard(resource).try(:group) || :main
|
42
|
+
end
|
43
|
+
|
44
|
+
def dashboard(resource)
|
45
|
+
"#{resource.singularize.capitalize}Dashboard".constantize.new
|
46
|
+
rescue ::NameError
|
47
|
+
nil
|
48
|
+
end
|
21
49
|
end
|
22
50
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'administrate_tailwind_theme/version'
|
4
|
+
require 'administrate_tailwind_theme/configuration'
|
4
5
|
require 'administrate_tailwind_theme/engine'
|
5
6
|
require 'administrate/field/boolean_emoji'
|
6
7
|
require 'administrate/field/country_emoji'
|
@@ -4,10 +4,23 @@ module AdministrateTailwindTheme
|
|
4
4
|
class InstallGenerator < Rails::Generators::Base
|
5
5
|
source_root File.expand_path('templates', __dir__)
|
6
6
|
|
7
|
+
def install_flowbite
|
8
|
+
return unless flowbite?
|
9
|
+
|
10
|
+
validate_npm
|
11
|
+
install_flowbite_package
|
12
|
+
end
|
13
|
+
|
7
14
|
def create_initializer
|
8
15
|
initializer 'administrate_tailwind_theme.rb', <<~FILE
|
16
|
+
# frozen_string_literal: true
|
17
|
+
|
9
18
|
require 'administrate'
|
10
19
|
Administrate::Engine.stylesheets.clear # required to remove Administrate base styles
|
20
|
+
|
21
|
+
AdministrateTailwindTheme::Configuration.configure do |config|
|
22
|
+
config.flowbite = #{flowbite?}
|
23
|
+
end
|
11
24
|
FILE
|
12
25
|
end
|
13
26
|
|
@@ -15,6 +28,7 @@ module AdministrateTailwindTheme
|
|
15
28
|
tailwind_config_path = 'config/tailwind.config.js'
|
16
29
|
|
17
30
|
insert_tailwind_config(tailwind_config_path)
|
31
|
+
insert_flowbite_config(tailwind_config_path) if flowbite?
|
18
32
|
end
|
19
33
|
|
20
34
|
private
|
@@ -31,5 +45,34 @@ module AdministrateTailwindTheme
|
|
31
45
|
insert_into_file file_path, config,
|
32
46
|
after: 'content: ['
|
33
47
|
end
|
48
|
+
|
49
|
+
def flowbite?
|
50
|
+
flowbite = true
|
51
|
+
flowbite = false if ENV['FLOWBITE']&.downcase == 'false'
|
52
|
+
|
53
|
+
flowbite
|
54
|
+
end
|
55
|
+
|
56
|
+
def install_flowbite_package
|
57
|
+
`npm install flowbite`
|
58
|
+
end
|
59
|
+
|
60
|
+
def insert_flowbite_config(file_path)
|
61
|
+
flowbite = "\n './node_modules/flowbite/**/*.js',"
|
62
|
+
flowbite_plug = "\n require('flowbite/plugin'),"
|
63
|
+
|
64
|
+
insert_into_file file_path, flowbite,
|
65
|
+
after: "{erb,haml,html,rb}',"
|
66
|
+
insert_into_file file_path, flowbite_plug,
|
67
|
+
after: "require('@tailwindcss/container-queries'),"
|
68
|
+
end
|
69
|
+
|
70
|
+
def validate_npm
|
71
|
+
require 'mkmf'
|
72
|
+
return if find_executable 'npm'
|
73
|
+
|
74
|
+
raise ArgumentError,
|
75
|
+
'npm command was not found! Install npm or use "FLOWBITE=false rails g administrate_tailwind_theme:install"'
|
76
|
+
end
|
34
77
|
end
|
35
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate_tailwind_theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eth3rnit3
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- ".rubocop.yml"
|
85
85
|
- ".ruby-version"
|
86
86
|
- ".rubycritic.yml"
|
87
|
+
- CHANGELOG.md
|
87
88
|
- CODE_OF_CONDUCT.md
|
88
89
|
- LICENSE.txt
|
89
90
|
- README.md
|
@@ -102,7 +103,9 @@ files:
|
|
102
103
|
- app/models/.keep
|
103
104
|
- app/models/concerns/.keep
|
104
105
|
- app/views/.keep
|
106
|
+
- app/views/admin/application/_default_sidebar.html.erb
|
105
107
|
- app/views/admin/application/_flashes.html.erb
|
108
|
+
- app/views/admin/application/_flowbite_sidebar.html.erb
|
106
109
|
- app/views/admin/application/_icons.html.erb
|
107
110
|
- app/views/admin/application/_javascript.html.erb
|
108
111
|
- app/views/admin/application/_navigation.html.erb
|
@@ -124,8 +127,9 @@ files:
|
|
124
127
|
- app/views/administrate/application/new.html.erb
|
125
128
|
- app/views/administrate/application/show.html.erb
|
126
129
|
- app/views/administrate/navigation/icons/_comments.html.erb
|
130
|
+
- app/views/administrate/navigation/icons/_main.html.erb
|
127
131
|
- app/views/administrate/navigation/icons/_messages.html.erb
|
128
|
-
- app/views/administrate/navigation/icons/_users.erb
|
132
|
+
- app/views/administrate/navigation/icons/_users.html.erb
|
129
133
|
- app/views/fields/belongs_to/_form.html.erb
|
130
134
|
- app/views/fields/belongs_to/_index.html.erb
|
131
135
|
- app/views/fields/belongs_to/_show.html.erb
|
@@ -186,10 +190,12 @@ files:
|
|
186
190
|
- app/views/kaminari/_prev_page.html.erb
|
187
191
|
- app/views/layouts/admin/application.html.erb
|
188
192
|
- config/routes.rb
|
193
|
+
- docs/upgrade_to_0.0.4.md
|
189
194
|
- images/screenshot.png
|
190
195
|
- lib/administrate/field/boolean_emoji.rb
|
191
196
|
- lib/administrate/field/country_emoji.rb
|
192
197
|
- lib/administrate_tailwind_theme.rb
|
198
|
+
- lib/administrate_tailwind_theme/configuration.rb
|
193
199
|
- lib/administrate_tailwind_theme/engine.rb
|
194
200
|
- lib/administrate_tailwind_theme/version.rb
|
195
201
|
- lib/administrate_tailwind_theme/view_generator.rb
|
File without changes
|