alveole 0.0.1 → 1.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -0
- data/README.md +21 -26
- data/Rakefile +6 -8
- data/app/assets/config/alveole_manifest.js +5 -0
- data/app/assets/images/alveole/icons/favicon-150.png +0 -0
- data/app/assets/javascripts/alveole/application.js +10 -0
- data/app/assets/stylesheets/alveole/application.css +15 -0
- data/app/assets/stylesheets/application.tailwind.css +13 -0
- data/app/components/alveole/button_component.html.erb +10 -0
- data/app/components/alveole/button_component.rb +46 -0
- data/app/components/alveole/chip_component.html.erb +3 -0
- data/app/components/alveole/chip_component.rb +23 -0
- data/app/components/alveole/dropdown/menu_item_component.html.erb +2 -0
- data/app/components/alveole/dropdown/menu_item_component.rb +5 -0
- data/app/components/alveole/dropdown_component.html.erb +27 -0
- data/app/components/alveole/dropdown_component.rb +21 -0
- data/app/components/alveole/footer/link_component.html.erb +6 -0
- data/app/components/alveole/footer/link_component.rb +8 -0
- data/app/components/alveole/footer_component.html.erb +14 -0
- data/app/components/alveole/footer_component.rb +9 -0
- data/app/components/alveole/form_layout_component.html.erb +32 -0
- data/app/components/alveole/form_layout_component.rb +43 -0
- data/app/components/alveole/icon_component.html.erb +1 -0
- data/app/components/alveole/icon_component.rb +20 -0
- data/app/components/alveole/input/avatar_component.html.erb +16 -0
- data/app/components/alveole/input/avatar_component.rb +4 -0
- data/app/components/alveole/input/base_component.rb +16 -0
- data/app/components/alveole/input/comment_component.html.erb +153 -0
- data/app/components/alveole/input/comment_component.rb +5 -0
- data/app/components/alveole/input/counter_component.html.erb +16 -0
- data/app/components/alveole/input/counter_component.rb +4 -0
- data/app/components/alveole/input/email_component.html.erb +17 -0
- data/app/components/alveole/input/email_component.rb +4 -0
- data/app/components/alveole/input/file_component.html.erb +4 -0
- data/app/components/alveole/input/file_component.rb +4 -0
- data/app/components/alveole/input/search_component.html.erb +7 -0
- data/app/components/alveole/input/search_component.rb +5 -0
- data/app/components/alveole/input/select_component.html.erb +4 -0
- data/app/components/alveole/input/select_component.rb +12 -0
- data/app/components/alveole/input/text_component.html.erb +17 -0
- data/app/components/alveole/input/text_component.rb +4 -0
- data/app/components/alveole/input/textarea_component.html.erb +16 -0
- data/app/components/alveole/input/textarea_component.rb +4 -0
- data/app/components/alveole/mega_menu_component.html.erb +107 -0
- data/app/components/alveole/mega_menu_component.rb +6 -0
- data/app/components/alveole/sidebar/divider_component.html.erb +5 -0
- data/app/components/alveole/sidebar/divider_component.rb +5 -0
- data/app/components/alveole/sidebar/group_component.html.erb +7 -0
- data/app/components/alveole/sidebar/group_component.rb +37 -0
- data/app/components/alveole/sidebar/heading_component.html.erb +3 -0
- data/app/components/alveole/sidebar/heading_component.rb +8 -0
- data/app/components/alveole/sidebar/item_component.html.erb +14 -0
- data/app/components/alveole/sidebar/item_component.rb +17 -0
- data/app/components/alveole/sidebar_component.html.erb +13 -0
- data/app/components/alveole/sidebar_component.rb +40 -0
- data/app/controllers/alveole/application_controller.rb +4 -0
- data/app/helpers/alveole/application_helper.rb +4 -0
- data/app/jobs/alveole/application_job.rb +4 -0
- data/app/mailers/alveole/application_mailer.rb +6 -0
- data/app/models/alveole/application_record.rb +5 -0
- data/app/views/layouts/alveole/application.html.erb +28 -0
- data/config/importmap.rb +7 -0
- data/config/routes.rb +2 -0
- data/config/tailwind.config.js +42 -0
- data/lib/alveole/engine.rb +18 -21
- data/lib/alveole/version.rb +1 -1
- data/lib/alveole.rb +2 -12
- data/lib/tasks/alveole_tasks.rake +14 -0
- metadata +110 -110
- data/.gitignore +0 -8
- data/.gitlab-ci.yml +0 -55
- data/.rubocop.yml +0 -63
- data/.rubocop_todo.yml +0 -12
- data/.travis.yml +0 -6
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -7
- data/Gemfile.lock +0 -171
- data/LICENSE.txt +0 -21
- data/alveole.gemspec +0 -35
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/alveole/components/avatar_component/avatar_component.html.slim +0 -6
- data/lib/alveole/components/avatar_component.rb +0 -9
- data/lib/alveole/components/badge_component/badge_component.html.slim +0 -2
- data/lib/alveole/components/badge_component.rb +0 -8
- data/lib/alveole/components/breadcrumb_component/breadcrumb_component.html.slim +0 -2
- data/lib/alveole/components/breadcrumb_component.rb +0 -8
- data/lib/alveole/components/breadcrumbs_component.rb +0 -7
- data/lib/alveole/components/button_component/button_component.html.slim +0 -5
- data/lib/alveole/components/button_component.rb +0 -15
- data/lib/alveole/components/definition_component/definition_component.html.slim +0 -4
- data/lib/alveole/components/definition_component.rb +0 -13
- data/lib/alveole/components/form_component/form_component.html.slim +0 -3
- data/lib/alveole/components/form_component.rb +0 -3
- data/lib/alveole/components/form_submit_component/form_submit_component.html.slim +0 -1
- data/lib/alveole/components/form_submit_component.rb +0 -7
- data/lib/alveole/components/heading_component/heading_component.html.slim +0 -4
- data/lib/alveole/components/heading_component.rb +0 -8
- data/lib/alveole/components/input_component/input_component.html.slim +0 -17
- data/lib/alveole/components/input_component.rb +0 -42
- data/lib/alveole/components/notice_component/notice_component.html.slim +0 -5
- data/lib/alveole/components/notice_component.rb +0 -15
- data/lib/alveole/components/page_component/page_component.html.slim +0 -10
- data/lib/alveole/components/page_component.rb +0 -4
- data/lib/alveole/components/sidebar_component/sidebar_component.html.slim +0 -7
- data/lib/alveole/components/sidebar_component.rb +0 -4
- data/lib/alveole/components/table_column_component/table_column_component.html.slim +0 -3
- data/lib/alveole/components/table_column_component.rb +0 -12
- data/lib/alveole/components/table_component/table_component.html.slim +0 -7
- data/lib/alveole/components/table_component.rb +0 -3
- data/lib/alveole/components/table_header_component/table_header_component.html.slim +0 -2
- data/lib/alveole/components/table_header_component.rb +0 -8
- data/lib/alveole/components/table_row_component/table_row_component.html.slim +0 -4
- data/lib/alveole/components/table_row_component.rb +0 -3
- data/lib/alveole/components/toolbar_component/toolbar_component.html.slim +0 -7
- data/lib/alveole/components/toolbar_component.rb +0 -4
- data/lib/alveole/concerns/bem.rb +0 -21
- data/lib/alveole/helpers/method_helper.rb +0 -31
- data/lib/alveole/javascript/components.js +0 -5
- data/lib/alveole/previews/avatar_component_preview.rb +0 -11
- data/lib/alveole/previews/badge_component_preview.rb +0 -11
- data/lib/alveole/previews/breadcrumb_component_preview.rb +0 -15
- data/lib/alveole/previews/button_component_preview.rb +0 -7
- data/lib/alveole/previews/definition_component_preview.rb +0 -33
- data/lib/alveole/previews/form_component_preview.rb +0 -18
- data/lib/alveole/previews/form_submit_component_preview.rb +0 -7
- data/lib/alveole/previews/heading_component_preview.rb +0 -11
- data/lib/alveole/previews/input_component_preview.rb +0 -32
- data/lib/alveole/previews/notice_component_preview.rb +0 -15
- data/lib/alveole/previews/page_component_preview.rb +0 -33
- data/lib/alveole/previews/sidebar_component_preview.rb +0 -33
- data/lib/alveole/previews/table_column_component_preview.rb +0 -36
- data/lib/alveole/previews/table_component_preview.rb +0 -12
- data/lib/alveole/previews/table_header_component_preview.rb +0 -27
- data/lib/alveole/previews/table_row_component_preview.rb +0 -18
- data/lib/alveole/previews/toolbar_component_preview.rb +0 -33
- data/lib/generators/alveole/config_generator.rb +0 -17
- data/lib/generators/alveole/templates/alveole_config.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e1b25c361ee735c0d5cf7db902bd9fa45c836e6607af048327878f7a5b7db89
|
4
|
+
data.tar.gz: 32841b85098794702e59ba252df533e05fcfc8ec06ec5f38e287fdc9617bc9c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95c1d0109eb0653dcdcb7aef5bda335117469fc52d05dea852c6859c3d0b51a9cdc67ae9d3b51437de7dbc50aeb67c797fe4b3ad16328721d3204b311256aa55
|
7
|
+
data.tar.gz: 9d4737460a4be0bf32ae8fc58553dcb7426f9742c58b80b557b575b330cc26b080cddd8e326387810a903f8131a72ae50165e222ee80eb17ffa783d6906c9442
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright Clément Prod'homme
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,44 +1,39 @@
|
|
1
1
|
# Alveole
|
2
2
|
|
3
|
-
|
3
|
+
Alveole is a versatile gem designed to enhance your web development experience by providing powerful components through the gem's view_component framework. With Alveole, building dynamic and modular user interfaces becomes a seamless process.
|
4
4
|
|
5
|
-
|
5
|
+
Key Features:
|
6
6
|
|
7
|
-
|
7
|
+
- **View Components:** Leverage the strength of view components to create reusable and encapsulated UI elements, promoting cleaner and more maintainable code.
|
8
|
+
- **Modularity:** Alveole encourages modular design, allowing developers to effortlessly organize and manage complex interfaces by breaking them down into manageable components.
|
9
|
+
- **Flexibility:** Easily integrate Alveole into your Ruby on Rails application, unlocking the potential to streamline your frontend development workflow.
|
10
|
+
- **Community-Driven:** Benefit from a growing community of developers contributing to and supporting Alveole, ensuring continuous improvement and updates.
|
8
11
|
|
9
|
-
|
12
|
+
Whether you're a seasoned developer or just starting, Alveole empowers you to build web applications with efficiency and elegance. Elevate your development experience with Alveole's view components, bringing simplicity and clarity to your codebase.
|
10
13
|
|
11
|
-
|
12
|
-
gem 'alveole'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
14
|
+
## Usage
|
20
15
|
|
21
|
-
|
16
|
+
How to use my plugin.
|
22
17
|
|
23
|
-
##
|
18
|
+
## Installation
|
24
19
|
|
25
|
-
|
20
|
+
1. Add this line to your application's Gemfile:
|
26
21
|
|
27
|
-
|
22
|
+
```ruby
|
23
|
+
gem "alveole"
|
24
|
+
```
|
28
25
|
|
29
|
-
|
26
|
+
And then execute:
|
27
|
+
```bash
|
28
|
+
$ bundle
|
29
|
+
```
|
30
30
|
|
31
|
-
|
31
|
+
2. Install Flowbite : https://flowbite.com/docs/getting-started/rails/
|
32
32
|
|
33
33
|
## Contributing
|
34
|
+
Contribution directions go here.
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
Pour lancer le projet, il faut utiliser la commande `bin/rails app:tailwind_engine_watch` pour compiler le css
|
37
37
|
|
38
38
|
## License
|
39
|
-
|
40
39
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
-
|
42
|
-
## Code of Conduct
|
43
|
-
|
44
|
-
Everyone interacting in the Alveole project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/alveole/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require 'rake/testtask'
|
1
|
+
require "bundler/setup"
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
t.libs << 'lib'
|
7
|
-
t.test_files = FileList['test/**/*_test.rb']
|
8
|
-
end
|
3
|
+
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
|
4
|
+
load "rails/tasks/engine.rake"
|
9
5
|
|
10
|
-
|
6
|
+
load "rails/tasks/statistics.rake"
|
7
|
+
|
8
|
+
require "bundler/gem_tasks"
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<alv-button class="inline-flex">
|
2
|
+
<%= link_to(@href, class: "flex items-center justify-center w-1/2 px-5 py-2 font-medium text-sm transition-colors duration-200 rounded-md w-auto gap-x-2 #{@base_class}") do %>
|
3
|
+
<% if @icon %>
|
4
|
+
<%= render(@icon) %>
|
5
|
+
<span><%= content %></span>
|
6
|
+
<% else %>
|
7
|
+
<% content %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
</alv-button>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Alveole::ButtonComponent < ViewComponent::Base
|
4
|
+
CLASS_BY_TYPE = {
|
5
|
+
primary: {
|
6
|
+
base: "border",
|
7
|
+
colors: {
|
8
|
+
primary: "text-white bg-primary-500 hover:bg-primary-600 dark:hover:bg-primary-500 dark:bg-primary-600",
|
9
|
+
green: "text-white bg-green-500 hover:bg-green-600 dark:hover:bg-green-500 dark:bg-green-600",
|
10
|
+
dark: "text-white bg-gray-800 hover:bg-gray-900 dark:hover:bg-gray-500 dark:bg-gray-600",
|
11
|
+
}
|
12
|
+
},
|
13
|
+
secondary: {
|
14
|
+
base: "border",
|
15
|
+
colors: {
|
16
|
+
primary: "text-gray-700 bg-white hover:bg-gray-100 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800",
|
17
|
+
green: "text-gray-700 border-green-500 bg-white hover:bg-gray-100 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800",
|
18
|
+
dark: "text-gray-800 border-gray-800 bg-white hover:bg-gray-100 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800",
|
19
|
+
}
|
20
|
+
},
|
21
|
+
tertiary: {
|
22
|
+
base: "hover:bg-gray-50 focus:bg-gray-100",
|
23
|
+
colors: {
|
24
|
+
primary: "text-primary-700 dark:text-gray-200 dark:focus:bg-gray-800",
|
25
|
+
green: "text-green-700 dark:text-gray-200 dark:focus:bg-gray-800",
|
26
|
+
dark: "text-gray-800 dark:text-gray-200 dark:focus:bg-gray-800",
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
TYPES = [:primary, :secondary, :tertiary]
|
31
|
+
|
32
|
+
def initialize(href: "#", disabled: false, type: :default, color: :primary, icon: nil)
|
33
|
+
@href = href
|
34
|
+
@color = color
|
35
|
+
@base_class = get_class(type, color)
|
36
|
+
@icon = IconComponent.new(icon, class: "-ml-0.5 w-5 h-5") if icon
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def get_class(type, color)
|
42
|
+
raise "Type invalide" unless TYPES.include?(type)
|
43
|
+
|
44
|
+
CLASS_BY_TYPE[type][:base] + " " + CLASS_BY_TYPE[type][:colors][color]
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Alveole::ChipComponent < ViewComponent::Base
|
4
|
+
def initialize(label:, color: :default, size: :sm)
|
5
|
+
@label = label
|
6
|
+
@color = color
|
7
|
+
@class_color = CLASS_COLOR[color.to_sym]
|
8
|
+
@class_size = CLASS_SIZE[size.to_sym]
|
9
|
+
end
|
10
|
+
|
11
|
+
CLASS_COLOR = {
|
12
|
+
default: "bg-gray-50 ring-gray-500/10 text-gray-600",
|
13
|
+
error: "bg-red-50 text-red-700 ring-red-600/10",
|
14
|
+
warning: "bg-yellow-50 text-yellow-800 ring-yellow-600/20",
|
15
|
+
success: "bg-green-50 text-green-700 ring-green-600/20",
|
16
|
+
info: "bg-blue-50 text-blue-700 ring-blue-700/10",
|
17
|
+
primary: "bg-primary-50 text-primary-700 ring-primary-700/10",
|
18
|
+
}
|
19
|
+
CLASS_SIZE = {
|
20
|
+
sm: "text-sm gap-x-2",
|
21
|
+
xs: "text-xs"
|
22
|
+
}
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<alv-dropdown>
|
2
|
+
<button id="dropdownDividerButton" data-dropdown-toggle="dropdownDivider" class="text-white bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800" type="button">
|
3
|
+
Dropdown divider
|
4
|
+
<svg class="w-2.5 h-2.5 ms-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
5
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
6
|
+
</svg>
|
7
|
+
</button>
|
8
|
+
|
9
|
+
<!-- Dropdown menu -->
|
10
|
+
<div id="dropdownDivider" class="z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700 dark:divide-gray-600">
|
11
|
+
<ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownDividerButton">
|
12
|
+
<li>
|
13
|
+
<a href="#" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Dashboard</a>
|
14
|
+
</li>
|
15
|
+
<li>
|
16
|
+
<a href="#" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Settings</a>
|
17
|
+
</li>
|
18
|
+
<li>
|
19
|
+
<a href="#" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Earnings</a>
|
20
|
+
</li>
|
21
|
+
</ul>
|
22
|
+
<div class="py-2">
|
23
|
+
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">Separated link</a>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
</alv-dropdown>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Alveole::DropdownComponent < ViewComponent::Base
|
4
|
+
# renders_many :items, types: {
|
5
|
+
# item: {
|
6
|
+
# renders: lambda { |**system_arguments, &block|
|
7
|
+
# Alveole::Sidebar::ItemComponent.new(
|
8
|
+
# **system_arguments,
|
9
|
+
# &block
|
10
|
+
# )
|
11
|
+
# },
|
12
|
+
|
13
|
+
# as: :item
|
14
|
+
# },
|
15
|
+
|
16
|
+
# divider: {
|
17
|
+
# renders: Alveole::Sidebar::DividerComponent,
|
18
|
+
# as: :divider
|
19
|
+
# }
|
20
|
+
# }
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<alv-footer class="block">
|
2
|
+
<div class="mx-auto max-w-7xl px-6 py-12 md:flex md:items-center md:justify-between lg:px-8">
|
3
|
+
<div class="flex justify-center space-x-6 md:order-2">
|
4
|
+
<% links.each do |link| %>
|
5
|
+
<%= link %>
|
6
|
+
<% end %>
|
7
|
+
</div>
|
8
|
+
<div class="mt-8 md:order-1 md:mt-0">
|
9
|
+
<p class="text-center text-xs leading-5 text-gray-500">
|
10
|
+
<%= @copyright_notice %>
|
11
|
+
</p>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
</alv-footer>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<alv-form-layout>
|
2
|
+
<%= simple_form_for @form_record, html: { enctype: "multipart/form-data" }, data: { turbo: false } do |f| %>
|
3
|
+
<% @f = f %>
|
4
|
+
|
5
|
+
<div class="space-y-12">
|
6
|
+
<div class="border-b border-gray-900/10 pb-8">
|
7
|
+
<% if @title %>
|
8
|
+
<h2 class="text-base font-semibold leading-7 text-gray-900"><%= @title %></h2>
|
9
|
+
<% end %>
|
10
|
+
<% if @description %>
|
11
|
+
<p class="mt-1 text-sm leading-6 text-gray-600"><%= @description %></p>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6 <%= @description || @title ? "mt-10" : "" %>">
|
15
|
+
<%= content %>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<div class="mt-6 flex items-center justify-end gap-x-6">
|
21
|
+
<%
|
22
|
+
cancel_url = if @record.persisted?
|
23
|
+
show_path_for(@record, prefix: :admin)
|
24
|
+
else
|
25
|
+
index_path_for(@record, prefix: :admin)
|
26
|
+
end
|
27
|
+
%>
|
28
|
+
<%= link_to "Cancel", cancel_url, class: "text-sm font-semibold leading-6 text-gray-900" %>
|
29
|
+
<%= f.button :submit, class: "cursor-pointer rounded-md bg-primary-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600" %>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
</alv-form-layout>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Alveole::FormLayoutComponent < ViewComponent::Base
|
4
|
+
include AutoUrlHelper
|
5
|
+
|
6
|
+
def initialize(record, title: nil, description: nil)
|
7
|
+
@record = record&.last
|
8
|
+
@form_record = record
|
9
|
+
@title = title
|
10
|
+
@description = description
|
11
|
+
end
|
12
|
+
|
13
|
+
INPUT_CLASS = {
|
14
|
+
string: Alveole::Input::TextComponent,
|
15
|
+
email: Alveole::Input::EmailComponent,
|
16
|
+
text: Alveole::Input::TextareaComponent,
|
17
|
+
search: Alveole::Input::SearchComponent,
|
18
|
+
comment: Alveole::Input::CommentComponent,
|
19
|
+
avatar: Alveole::Input::AvatarComponent,
|
20
|
+
file: Alveole::Input::FileComponent,
|
21
|
+
counter: Alveole::Input::CounterComponent,
|
22
|
+
select: Alveole::Input::SelectComponent,
|
23
|
+
}
|
24
|
+
def input(attribute, **args)
|
25
|
+
input_component = input_component(attribute, args[:as])
|
26
|
+
render(input_component.new(@f, attribute, args))
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def input_component(attribute, as)
|
32
|
+
as ||= default_input_type(attribute, as)
|
33
|
+
|
34
|
+
INPUT_CLASS[as].presence || Input::TextComponent
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_input_type(attribute, as)
|
38
|
+
as = :avatar if attribute.to_sym == :avatar
|
39
|
+
as = :email if attribute.to_sym == :email
|
40
|
+
as = :counter if [:quantity].include?(attribute.to_sym)
|
41
|
+
as ||= :string
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<div>Add Icon template here</div>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# require 'inline_svg'
|
4
|
+
|
5
|
+
class Alveole::IconComponent < ViewComponent::Base
|
6
|
+
include InlineSvg::ActionView
|
7
|
+
|
8
|
+
def initialize(name, **args)
|
9
|
+
@name = format_name(name.to_s)
|
10
|
+
@options = args
|
11
|
+
end
|
12
|
+
|
13
|
+
def format_name(name)
|
14
|
+
base_folder = "icons/"
|
15
|
+
name = base_folder + name
|
16
|
+
return name if name.end_with?(".svg")
|
17
|
+
|
18
|
+
name + ".svg"
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<alv-input-avatar>
|
2
|
+
<%= f.label @attribute, class: "block text-sm font-medium leading-6 text-gray-900" %>
|
3
|
+
<div class="mt-2 flex items-center gap-x-3">
|
4
|
+
<%
|
5
|
+
url = if f.object.send(@attribute).attached?
|
6
|
+
url_for(f.object.send(@attribute))
|
7
|
+
end
|
8
|
+
%>
|
9
|
+
<%= render(AvatarComponent.new(src: url))%>
|
10
|
+
<label for="utilisateur_avatar">
|
11
|
+
<div class="inline-block cursor-pointer rounded-md bg-white px-2.5 py-1.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50">Change</div>
|
12
|
+
<label>
|
13
|
+
</div>
|
14
|
+
<%= f.input_field @attribute, as: :hidden, type: :file, accept: "image/*" %>
|
15
|
+
|
16
|
+
</alv-input-avatar>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Alveole::Input::BaseComponent < ViewComponent::Base
|
2
|
+
attr_reader :f
|
3
|
+
|
4
|
+
def initialize(form, attribute, args = {})
|
5
|
+
@f = form
|
6
|
+
@attribute = attribute
|
7
|
+
@args = args
|
8
|
+
resource_name = form.object.class.to_s.underscore
|
9
|
+
@id = "#{resource_name}_#{attribute.to_s.underscore}"
|
10
|
+
@required = args[:required].presence || false
|
11
|
+
end
|
12
|
+
|
13
|
+
def errors?
|
14
|
+
f.object.errors[@attribute].present?
|
15
|
+
end
|
16
|
+
end
|