f_components 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +144 -0
  3. data/Rakefile +20 -0
  4. data/app/components/f_components/avatar/component.html.erb +1 -0
  5. data/app/components/f_components/avatar/component.rb +30 -0
  6. data/app/components/f_components/avatar/component.scss +3 -0
  7. data/app/components/f_components/base.rb +14 -0
  8. data/app/components/f_components/button/component.html.erb +5 -0
  9. data/app/components/f_components/button/component.rb +68 -0
  10. data/app/components/f_components/button/component.scss +9 -0
  11. data/app/components/f_components/collapsible/component.html.erb +6 -0
  12. data/app/components/f_components/collapsible/component.rb +15 -0
  13. data/app/components/f_components/collapsible/component.scss +19 -0
  14. data/app/components/f_components/dropdown/component.html.erb +10 -0
  15. data/app/components/f_components/dropdown/component.rb +19 -0
  16. data/app/components/f_components/dropdown/component.scss +10 -0
  17. data/app/components/f_components/form_field/component.html.erb +25 -0
  18. data/app/components/f_components/form_field/component.rb +124 -0
  19. data/app/components/f_components/resource_table/component.html.erb +17 -0
  20. data/app/components/f_components/resource_table/component.rb +139 -0
  21. data/app/components/f_components/table/component.html.erb +23 -0
  22. data/app/components/f_components/table/component.rb +88 -0
  23. data/app/components/f_components/table/component_controller.js +84 -0
  24. data/app/components/f_components/table/desktop/component.html.erb +25 -0
  25. data/app/components/f_components/table/desktop/component.rb +71 -0
  26. data/app/components/f_components/table/mobile/component.html.erb +8 -0
  27. data/app/components/f_components/table/mobile/component.rb +102 -0
  28. data/app/frontend/f_components/stylesheets/blocks/_button.scss +189 -0
  29. data/app/frontend/f_components/stylesheets/f_components.scss +12 -0
  30. data/app/frontend/f_components/stylesheets/variables/_breakpoints.scss +3 -0
  31. data/app/frontend/f_components/stylesheets/variables/_colors.scss +19 -0
  32. data/app/helpers/f_components/application_helper.rb +13 -0
  33. data/app/helpers/f_components/components_helper.rb +33 -0
  34. data/app/helpers/f_components/icons_helper.rb +34 -0
  35. data/config/webpack/development.js +5 -0
  36. data/config/webpack/environment.js +3 -0
  37. data/config/webpack/production.js +7 -0
  38. data/config/webpacker.yml +89 -0
  39. data/lib/f_components/engine.rb +28 -0
  40. data/lib/f_components/railtie.rb +12 -0
  41. data/lib/f_components/version.rb +5 -0
  42. data/lib/f_components.rb +18 -0
  43. metadata +158 -0
@@ -0,0 +1,189 @@
1
+ $button-colors: (
2
+ "black": (
3
+ "base": $fc-clr-text,
4
+ "dark": #000,
5
+ ),
6
+ "primary": (
7
+ "base": $fc-clr-primary,
8
+ "dark": $fc-clr-primary--dk,
9
+ ),
10
+ "success": (
11
+ "base": $fc-clr-success,
12
+ ),
13
+ "secondary": (
14
+ "base": $fc-clr-secondary,
15
+ "dark": $fc-clr-secondary--dk,
16
+ ),
17
+ "error": (
18
+ "base": $fc-clr-error,
19
+ ),
20
+ "white": (
21
+ "base": #fff,
22
+ "dark": $fc-clr-border,
23
+ "text": $fc-clr-text,
24
+ ),
25
+ "warning": (
26
+ "base": $fc-clr-warning,
27
+ "text": $fc-clr-text,
28
+ ),
29
+ ) !default;
30
+
31
+ $button-sizes: (
32
+ "smr": (
33
+ "width": 90px,
34
+ "height": 30px,
35
+ ),
36
+ "sm": (
37
+ "width": 190px,
38
+ "height": 40px,
39
+ ),
40
+ "base": (
41
+ "width": 284px,
42
+ "height": 40px,
43
+ ),
44
+ "lg": (
45
+ "width": 308px,
46
+ "height": 40px,
47
+ ),
48
+ "fullWidth": (
49
+ "width": 100%,
50
+ "height": 40px,
51
+ ),
52
+ ) !default;
53
+
54
+ @mixin outlined($color) {
55
+ &.bt--outlined {
56
+ background-color: white;
57
+ color: $color;
58
+ border: solid 1px $color;
59
+
60
+ &-active,
61
+ &:hover {
62
+ background-color: rgba($color, $fc-opacity-button-hover);
63
+ }
64
+ }
65
+ }
66
+
67
+ // NOTE: Both min/max functions were added due to
68
+ // the lack of them in the rubysass implementation
69
+ //
70
+ // More info:
71
+ // https://github.com/sass/libsass/issues/2701
72
+ // https://github.com/sass/sass/issues/2378#issuecomment-433868712
73
+ @function f-max($numbers...) {
74
+ @return calc(min(#{$numbers}));
75
+ }
76
+
77
+ @function f-min($numbers...) {
78
+ @return calc(min(#{$numbers}));
79
+ }
80
+
81
+ @mixin generate-color-variants() {
82
+ @each $name, $colors in $button-colors {
83
+ $base: map-get($colors, "base");
84
+ $dark: map-get($colors, "dark") or darken($base, 10%);
85
+ $text: map-get($colors, "text") or white;
86
+
87
+ @include generate-color-variant($name, $base, $dark, $text);
88
+ }
89
+ }
90
+
91
+ @mixin generate-size-modifiers() {
92
+ @each $name, $sizes in $button-sizes {
93
+ $width: map-get($sizes, "width");
94
+ $height: map-get($sizes, "height");
95
+
96
+ &--#{$name} {
97
+ width: f-min($width, 100%);
98
+ max-width: f-min($width, 100%);
99
+ min-height: $height;
100
+ line-height: $height;
101
+ }
102
+ }
103
+ }
104
+
105
+ @mixin generate-color-variant($name, $color, $color--dk, $text-color) {
106
+ &--#{$name} {
107
+ background-color: $color;
108
+ color: $text-color;
109
+
110
+ &:hover {
111
+ background: $color--dk;
112
+ }
113
+
114
+ &:active,
115
+ &:hover,
116
+ &:visited {
117
+ color: $text-color;
118
+ }
119
+
120
+ @include outlined($color);
121
+ }
122
+ }
123
+
124
+ .bt {
125
+ text-decoration: none;
126
+ background: $fc-clr-primary;
127
+ border-radius: 2px;
128
+ color: white;
129
+ cursor: pointer;
130
+ display: block;
131
+ min-height: 40px;
132
+ line-height: 40px;
133
+ padding: 0 20px;
134
+ text-align: center;
135
+
136
+ @include generate-color-variants();
137
+ @include generate-size-modifiers();
138
+
139
+ &:hover {
140
+ background: $fc-clr-primary--dk;
141
+ text-decoration: none;
142
+ }
143
+
144
+ &--tertiary {
145
+ background-color: white;
146
+ color: $fc-clr-text-secondary;
147
+ border: 1px solid $fc-clr-text-secondary;
148
+
149
+ &:hover {
150
+ background-color: rgba($fc-clr-text-secondary, $fc-opacity-button-hover);
151
+ }
152
+
153
+ &:active {
154
+ background-color: rgba($fc-clr-primary, $fc-opacity-button-hover);
155
+ color: $fc-clr-primary;
156
+ border-color: $fc-clr-primary;
157
+ }
158
+ }
159
+
160
+ &--disabled,
161
+ &:disabled {
162
+ color: $fc-clr-text-secondary;
163
+ background-color: $fc-clr-disabled;
164
+ cursor: not-allowed !important;
165
+ border: none;
166
+
167
+ &:hover {
168
+ color: $fc-clr-text-secondary;
169
+ background-color: $fc-clr-disabled;
170
+ }
171
+ }
172
+
173
+ &--round {
174
+ border-radius: 40px;
175
+ }
176
+
177
+ &--icon {
178
+ padding: 0 15px;
179
+ }
180
+
181
+ &--rounded {
182
+ border-radius: 5px;
183
+ height: 40px;
184
+ }
185
+
186
+ &--fullWidth {
187
+ width: 100%;
188
+ }
189
+ }
@@ -0,0 +1,12 @@
1
+ // variables
2
+ @import "./variables/breakpoints";
3
+ @import "./variables/colors";
4
+
5
+ // blocks
6
+ @import "./blocks/button";
7
+
8
+ // components
9
+ @import "../../../components/f_components/avatar/component";
10
+ @import "../../../components/f_components/button/component";
11
+ @import "../../../components/f_components/collapsible/component";
12
+ @import "../../../components/f_components/dropdown/component";
@@ -0,0 +1,3 @@
1
+ $fc-desktop-width: 1170px !default;
2
+ $fc-tablet-width: 970px !default;
3
+ $fc-mobile-width: 750px !default;
@@ -0,0 +1,19 @@
1
+ $fc-clr-primary: #9c27b0 !default;
2
+ $fc-clr-primary--dk: #6a0080 !default;
3
+ $fc-clr-secondary: #f50057 !default;
4
+ $fc-clr-secondary--dk: #bb002f !default;
5
+
6
+ $fc-clr-text: #443344 !default;
7
+ $fc-clr-text-secondary: #6f5d6f !default;
8
+
9
+ $fc-clr-success: #33691e !default;
10
+ $fc-clr-warning: #c6a700 !default;
11
+ $fc-clr-error: #ab000d !default;
12
+
13
+ $fc-clr-disabled: #a4a4a4 !default;
14
+
15
+ $fc-clr-border: #ccc !default;
16
+
17
+ $fc-clr-background: #fafafa !default;
18
+
19
+ $fc-opacity-button-hover: 0.2 !default;
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'webpacker/helper'
4
+
5
+ module FComponents
6
+ module ApplicationHelper
7
+ include ::Webpacker::Helper
8
+
9
+ def current_webpacker_instance
10
+ FComponents.webpacker
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FComponents
4
+ module ComponentsHelper
5
+ # Shorthand for rendering view_components from FComponents
6
+ #
7
+ # Usage:
8
+ #
9
+ # <%= fcomponent :section, title: 'Greeting', classes: 'my--1' do %>
10
+ # <p class="Txt--center">Hello world</p>
11
+ # <% end %>
12
+ def fcomponent(name, *args, &block)
13
+ component_class = "FC::#{name.to_s.camelcase}::Component".constantize
14
+
15
+ render(component_class.new(*args), &block)
16
+ end
17
+ ruby2_keywords :fcomponent
18
+
19
+ # Shorthand for rendering view_components from your application
20
+ #
21
+ # Usage:
22
+ #
23
+ # <%= component :card, classes: 'my--1' do %>
24
+ # <p class="Txt--center">Hello world</p>
25
+ # <% end %>
26
+ def component(name, *args, &block)
27
+ component_class = "#{name.to_s.camelcase}::Component".constantize
28
+
29
+ render(component_class.new(*args), &block)
30
+ end
31
+ ruby2_keywords :component
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FComponents
4
+ module IconsHelper
5
+ # Public: Creates a icon tag
6
+ # Examples:
7
+ #
8
+ # fa_icon('eye')
9
+ # #=> <i class="fas fa-eye"></i>
10
+ #
11
+ # fa_icon('eye', prefix: 'far')
12
+ # <i class="far fa-eye"></i>
13
+ #
14
+ # fa_icon('eye', class: 'strong space-x-2')
15
+ # #=> <i class="fas fa-eye strong space-x-2"></i>
16
+ #
17
+ # fa_icon('eye', class: 'strong space-x-2', text: 'my text')
18
+ # #=> <i class="fas fa-eye strong space-x-2"></i> my text
19
+ def fa_icon(name, options = {})
20
+ fa_prefix = options.delete(:prefix) { 'fas' }
21
+ icon_name = "fa-#{name}"
22
+ custom_classes = options[:class].presence
23
+ options[:class] = [fa_prefix, icon_name, custom_classes].compact.join(' ')
24
+ f_icon(options)
25
+ end
26
+
27
+ def f_icon(options)
28
+ text = options.delete(:text)
29
+ tag = content_tag(:i, nil, options)
30
+ tag << " #{text}" if text.present?
31
+ tag
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development';
2
+
3
+ const environment = require('./environment');
4
+
5
+ module.exports = environment.toWebpackConfig();
@@ -0,0 +1,3 @@
1
+ const {environment} = require('@rails/webpacker');
2
+
3
+ module.exports = environment;
@@ -0,0 +1,7 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+
3
+ const environment = require('./environment')
4
+
5
+ console.log('environment: ', environment)
6
+
7
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,89 @@
1
+ default: &default
2
+ source_path: app/frontend/f_components
3
+ source_entry_path: packs
4
+ public_root_path: public
5
+ public_output_path: f-components-packs
6
+ resolved_paths: ['app/components/f_components']
7
+ webpack_compile_output: true
8
+
9
+ # Reload manifest.json on all requests so we reload latest compiled packs
10
+ cache_manifest: false
11
+
12
+ # Extract and emit a css file
13
+ extract_css: false
14
+
15
+ static_assets_extensions:
16
+ - .jpg
17
+ - .jpeg
18
+ - .png
19
+ - .gif
20
+ - .tiff
21
+ - .ico
22
+ - .svg
23
+ - .eot
24
+ - .otf
25
+ - .ttf
26
+ - .woff
27
+ - .woff2
28
+
29
+ extensions:
30
+ - .mjs
31
+ - .js
32
+ - .sass
33
+ - .scss
34
+ - .css
35
+ - .module.sass
36
+ - .module.scss
37
+ - .module.css
38
+ - .png
39
+ - .svg
40
+ - .gif
41
+ - .jpeg
42
+ - .jpg
43
+
44
+ development:
45
+ <<: *default
46
+ compile: true
47
+
48
+ # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
49
+ check_yarn_integrity: true
50
+
51
+ # Reference: https://webpack.js.org/configuration/dev-server/
52
+ dev_server:
53
+ env_prefix: 'f_components'
54
+ https: false
55
+ host: 0.0.0.0
56
+ port: 3999
57
+ public: 0.0.0.0:3999
58
+ hmr: true
59
+ # Inline should be set to true if using HMR
60
+ inline: true
61
+ overlay: true
62
+ compress: true
63
+ disable_host_check: true
64
+ use_local_ip: false
65
+ quiet: false
66
+ pretty: false
67
+ headers:
68
+ 'Access-Control-Allow-Origin': '*'
69
+ watch_options:
70
+ ignored: '**/node_modules/**'
71
+
72
+ test:
73
+ <<: *default
74
+ compile: true
75
+
76
+ # Compile test packs to a separate directory
77
+ public_output_path: packs-test
78
+
79
+ production:
80
+ <<: *default
81
+
82
+ # Production depends on precompilation of packs prior to booting for performance.
83
+ compile: true
84
+
85
+ # Extract and emit a css file
86
+ extract_css: true
87
+
88
+ # Cache manifest.json for performance
89
+ cache_manifest: true
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FComponents
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace FComponents
6
+
7
+ config.autoload_once_paths << "#{root}/app/helpers" if Rails.version.start_with?('7')
8
+
9
+ config.app_middleware.use(
10
+ Rack::Static,
11
+ urls: ['/f-components-packs'], root: FComponents::Engine.root.join('public')
12
+ )
13
+
14
+ initializer 'webpacker.proxy' do |app|
15
+ next if FComponents.webpacker&.config&.dev_server&.blank?
16
+
17
+ app.middleware.insert_before(
18
+ 0, Webpacker::DevServerProxy, # "Webpacker::DevServerProxy" if Rails version < 5
19
+ ssl_verify_none: true,
20
+ webpacker: FComponents.webpacker
21
+ )
22
+ end
23
+
24
+ config.generators do |g|
25
+ g.test_framework :rspec
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FComponents
4
+ class Railtie < ::Rails::Railtie
5
+ initializer 'f-components.view_helpers' do
6
+ ActiveSupport.on_load(:action_view) do
7
+ include FComponents::ComponentsHelper
8
+ include FComponents::IconsHelper
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FComponents
4
+ VERSION = '0.2.1'
5
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'f_components/version'
4
+ require 'f_components/engine'
5
+ require 'f_components/railtie' if defined?(Rails::Railtie)
6
+
7
+ module FComponents
8
+ class << self
9
+ def webpacker
10
+ @webpacker ||= ::Webpacker::Instance.new(
11
+ root_path: FComponents::Engine.root,
12
+ config_path: FComponents::Engine.root.join('config', 'webpacker.yml')
13
+ )
14
+ end
15
+ end
16
+ end
17
+
18
+ FC = FComponents
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: f_components
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Fretadao tech
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sass
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sass-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: view_component
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.27'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.27'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webpacker
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.3'
83
+ description: Library of view_components
84
+ email:
85
+ - tech@fretadao.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - README.md
91
+ - Rakefile
92
+ - app/components/f_components/avatar/component.html.erb
93
+ - app/components/f_components/avatar/component.rb
94
+ - app/components/f_components/avatar/component.scss
95
+ - app/components/f_components/base.rb
96
+ - app/components/f_components/button/component.html.erb
97
+ - app/components/f_components/button/component.rb
98
+ - app/components/f_components/button/component.scss
99
+ - app/components/f_components/collapsible/component.html.erb
100
+ - app/components/f_components/collapsible/component.rb
101
+ - app/components/f_components/collapsible/component.scss
102
+ - app/components/f_components/dropdown/component.html.erb
103
+ - app/components/f_components/dropdown/component.rb
104
+ - app/components/f_components/dropdown/component.scss
105
+ - app/components/f_components/form_field/component.html.erb
106
+ - app/components/f_components/form_field/component.rb
107
+ - app/components/f_components/resource_table/component.html.erb
108
+ - app/components/f_components/resource_table/component.rb
109
+ - app/components/f_components/table/component.html.erb
110
+ - app/components/f_components/table/component.rb
111
+ - app/components/f_components/table/component_controller.js
112
+ - app/components/f_components/table/desktop/component.html.erb
113
+ - app/components/f_components/table/desktop/component.rb
114
+ - app/components/f_components/table/mobile/component.html.erb
115
+ - app/components/f_components/table/mobile/component.rb
116
+ - app/frontend/f_components/stylesheets/blocks/_button.scss
117
+ - app/frontend/f_components/stylesheets/f_components.scss
118
+ - app/frontend/f_components/stylesheets/variables/_breakpoints.scss
119
+ - app/frontend/f_components/stylesheets/variables/_colors.scss
120
+ - app/helpers/f_components/application_helper.rb
121
+ - app/helpers/f_components/components_helper.rb
122
+ - app/helpers/f_components/icons_helper.rb
123
+ - config/webpack/development.js
124
+ - config/webpack/environment.js
125
+ - config/webpack/production.js
126
+ - config/webpacker.yml
127
+ - lib/f_components.rb
128
+ - lib/f_components/engine.rb
129
+ - lib/f_components/railtie.rb
130
+ - lib/f_components/version.rb
131
+ homepage: https://gitlab.com/fretadao/libs/f_components
132
+ licenses:
133
+ - MIT
134
+ metadata:
135
+ homepage_uri: https://gitlab.com/fretadao/libs/f_components
136
+ source_code_uri: https://gitlab.com/fretadao/libs/f_components
137
+ changelog_uri: https://gitlab.com/fretadao/libs/f_components
138
+ rubygems_mfa_required: 'false'
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 2.7.0
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubygems_version: 3.1.2
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Library of view_components
158
+ test_files: []