amber_component 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -1
- data/CONTRIBUTING.md +87 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +16 -91
- data/README.md +25 -42
- data/Rakefile +17 -1
- data/amber_component.gemspec +4 -2
- data/banner.png +0 -0
- data/docs/.bundle/config +2 -0
- data/docs/.gitignore +5 -0
- data/docs/404.html +25 -0
- data/docs/Gemfile +37 -0
- data/docs/Gemfile.lock +89 -0
- data/docs/README.md +19 -0
- data/docs/_config.yml +148 -0
- data/docs/_data/amber_component.yml +3 -0
- data/docs/_sass/_variables.scss +2 -0
- data/docs/_sass/color_schemes/amber_component.scss +11 -0
- data/docs/_sass/custom/custom.scss +60 -0
- data/docs/api/index.md +8 -0
- data/docs/assets/images/logo_wide.png +0 -0
- data/docs/changelog/index.md +8 -0
- data/docs/favicon.ico +0 -0
- data/docs/getting_started/index.md +8 -0
- data/docs/getting_started/installation.md +7 -0
- data/docs/getting_started/ruby_support.md +7 -0
- data/docs/getting_started/wireframes.md +7 -0
- data/docs/index.md +17 -0
- data/docs/introduction/basic_usage.md +7 -0
- data/docs/introduction/index.md +8 -0
- data/docs/introduction/why_amber_component.md +7 -0
- data/docs/resources/index.md +8 -0
- data/docs/styles/index.md +8 -0
- data/docs/styles/usage.md +7 -0
- data/docs/views/index.md +8 -0
- data/docs/views/usage.md +7 -0
- data/icon.png +0 -0
- data/lib/amber_component/assets.rb +59 -0
- data/lib/amber_component/base.rb +66 -434
- data/lib/amber_component/helpers/class_helper.rb +22 -0
- data/lib/amber_component/helpers/component_helper.rb +18 -0
- data/lib/amber_component/helpers/css_helper.rb +25 -0
- data/lib/amber_component/helpers.rb +11 -0
- data/lib/amber_component/railtie.rb +21 -0
- data/lib/amber_component/rendering.rb +53 -0
- data/lib/amber_component/template_handler/erb.rb +17 -0
- data/lib/amber_component/template_handler.rb +26 -0
- data/lib/amber_component/version.rb +1 -1
- data/lib/amber_component/views.rb +198 -0
- data/lib/amber_component.rb +6 -2
- data/lib/generators/amber_component/install_generator.rb +23 -0
- data/lib/generators/amber_component/templates/application_component.rb +13 -0
- data/lib/generators/amber_component_generator.rb +24 -0
- data/lib/generators/templates/component.rb.erb +9 -0
- data/lib/generators/templates/component_test.rb.erb +9 -0
- data/lib/generators/templates/style.css.erb +3 -0
- data/lib/generators/templates/view.html.erb +3 -0
- metadata +85 -19
- data/.kanbn/index.md +0 -23
- data/.kanbn/tasks/add-instance-variables-to-view-when-block-given-markdown.md +0 -9
- data/.kanbn/tasks/bind-clas-to-action-view-method-call-example-component-data-data-without-calling-any-method.md +0 -9
- data/.kanbn/tasks/bind-scoped-css-to-head-of-doc.md +0 -10
- data/.kanbn/tasks/check-if-we-need-full-rails-gem-pack.md +0 -9
- data/.kanbn/tasks/simple-proto.md +0 -10
- data/.kanbn/tasks/verify-if-template-is-haml-or-erb.md +0 -9
- data/PLANS.md +0 -17
- data/lib/amber_component/helper.rb +0 -8
- data/lib/amber_component/style_injector.rb +0 -52
- data/sig/amber_components.rbs +0 -4
data/docs/_config.yml
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
# Welcome to Jekyll!
|
2
|
+
#
|
3
|
+
# This config file is meant for settings that affect your whole site, values
|
4
|
+
# which you are expected to set up once and rarely edit after that. If you find
|
5
|
+
# yourself editing these this file very often, consider using Jekyll's data files
|
6
|
+
# feature for the data you need to update frequently.
|
7
|
+
#
|
8
|
+
# For technical reasons, this file is *NOT* reloaded automatically when you use
|
9
|
+
# 'jekyll serve'. If you change this file, please restart the server process.
|
10
|
+
|
11
|
+
# Site settings
|
12
|
+
# These are used to personalize your new site. If you look in the HTML files,
|
13
|
+
# you will see them accessed via {{ site.title }}, {{ site.github_repo }}, and so on.
|
14
|
+
# You can create any custom variable you would like, and they will be accessible
|
15
|
+
# in the templates via {{ site.myvariable }}.
|
16
|
+
title: Amber Component
|
17
|
+
baseurl: '/amber-doc-test' # the subpath of your site, e.g. /blog
|
18
|
+
# url: https://ambercomponent.com # the base hostname & protocol for your site, e.g. http://example.com
|
19
|
+
url: https://garbusbeach.com/ # the base hostname & protocol for your site, e.g. http://example.com
|
20
|
+
|
21
|
+
theme: just-the-docs
|
22
|
+
# Color scheme currently only supports "dark", "light"/nil (default), or a custom scheme that you define
|
23
|
+
# color_scheme: "dark"
|
24
|
+
color_scheme: "amber_component"
|
25
|
+
|
26
|
+
permalink: pretty
|
27
|
+
exclude: [
|
28
|
+
"node_modules/",
|
29
|
+
"*.gemspec",
|
30
|
+
"*.gem",
|
31
|
+
"Gemfile",
|
32
|
+
"Gemfile.lock",
|
33
|
+
"package.json",
|
34
|
+
"package-lock.json",
|
35
|
+
"script/",
|
36
|
+
"LICENSE.txt",
|
37
|
+
"lib/",
|
38
|
+
"bin/",
|
39
|
+
"README.md",
|
40
|
+
"Rakefile" ,
|
41
|
+
"docs/tests/"
|
42
|
+
]
|
43
|
+
|
44
|
+
# Regression tests
|
45
|
+
# By default, the pages in /docs/tests are excluded when the ste is built.
|
46
|
+
# To include them, comment-out the relevant line above.
|
47
|
+
# Uncommenting the following line doesn't work - see https://github.com/jekyll/jekyll/issues/4791
|
48
|
+
# include: ["docs/tests/"]
|
49
|
+
|
50
|
+
# Set a path/url to a logo that will be displayed instead of the title
|
51
|
+
logo: /assets/images/logo_wide.png
|
52
|
+
|
53
|
+
# Enable or disable the site search
|
54
|
+
# Supports true (default) or false
|
55
|
+
search_enabled: true
|
56
|
+
search:
|
57
|
+
# Split pages into sections that can be searched individually
|
58
|
+
# Supports 1 - 6, default: 2
|
59
|
+
heading_level: 2
|
60
|
+
# Maximum amount of previews per search result
|
61
|
+
# Default: 3
|
62
|
+
previews: 2
|
63
|
+
# Maximum amount of words to display before a matched word in the preview
|
64
|
+
# Default: 5
|
65
|
+
preview_words_before: 3
|
66
|
+
# Maximum amount of words to display after a matched word in the preview
|
67
|
+
# Default: 10
|
68
|
+
preview_words_after: 3
|
69
|
+
# Set the search token separator
|
70
|
+
# Default: /[\s\-/]+/
|
71
|
+
# Example: enable support for hyphenated search words
|
72
|
+
tokenizer_separator: /[\s/]+/
|
73
|
+
# Display the relative url in search results
|
74
|
+
# Supports true (default) or false
|
75
|
+
rel_url: true
|
76
|
+
# Enable or disable the search button that appears in the bottom right corner of every page
|
77
|
+
# Supports true or false (default)
|
78
|
+
button: false
|
79
|
+
|
80
|
+
# Enable or disable heading anchors
|
81
|
+
heading_anchors: true
|
82
|
+
|
83
|
+
# Aux links for the upper right navigation
|
84
|
+
aux_links:
|
85
|
+
AmberComponent on GitHub:
|
86
|
+
- https://github.com/amber-ruby/amber_component
|
87
|
+
|
88
|
+
# Makes Aux links open in a new tab. Default is false
|
89
|
+
aux_links_new_tab: true
|
90
|
+
|
91
|
+
# Sort order for navigation links
|
92
|
+
# nav_sort: case_insensitive # default, equivalent to nil
|
93
|
+
nav_sort: case_sensitive # Capital letters sorted before lowercase
|
94
|
+
|
95
|
+
# Footer content
|
96
|
+
# appears at the bottom of every page's main content
|
97
|
+
|
98
|
+
# Back to top link
|
99
|
+
back_to_top: true
|
100
|
+
back_to_top_text: "Back to top"
|
101
|
+
|
102
|
+
footer_content: >-
|
103
|
+
Copyright ©
|
104
|
+
<script type="text/javascript">
|
105
|
+
document.write(new Date().getFullYear());
|
106
|
+
</script>
|
107
|
+
<a class="personal-link" href="{{ site.data.amber_component.garbus_beach_url }}">Garbus Beach</a>,
|
108
|
+
<a class="personal-link" href="{{ site.data.amber_component.mateusz_drewniak_url }}">Mateusz Drewniak</a>.
|
109
|
+
Made with ❤️ for ruby.
|
110
|
+
|
111
|
+
# Footer last edited timestamp
|
112
|
+
last_edit_timestamp: false # show or hide edit time - page must have `last_modified_date` defined in the frontmatter
|
113
|
+
last_edit_time_format: "%b %e %Y at %I:%M %p" # uses ruby's time format: https://ruby-doc.org/stdlib-2.7.0/libdoc/time/rdoc/Time.html
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
# Footer "Edit this page on GitHub" link text
|
118
|
+
gh_edit_link: false # show or hide edit this page link
|
119
|
+
# gh_edit_link_text: "Edit this page on GitHub"
|
120
|
+
# gh_edit_repository: "https://github.com/just-the-docs/just-the-docs" # the github URL for your repo
|
121
|
+
# gh_edit_branch: "main" # the branch that your docs is served from
|
122
|
+
# gh_edit_source: docs # the source that your files originate from
|
123
|
+
# gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately
|
124
|
+
|
125
|
+
# Google Analytics Tracking (optional)
|
126
|
+
# e.g, UA-1234567-89
|
127
|
+
|
128
|
+
# TODO:
|
129
|
+
# ga_tracking: UA-2709176-10
|
130
|
+
# ga_tracking_anonymize_ip: false # Use GDPR compliant Google Analytics settings (true/nil by default)
|
131
|
+
|
132
|
+
plugins:
|
133
|
+
- jekyll-seo-tag
|
134
|
+
|
135
|
+
kramdown:
|
136
|
+
syntax_highlighter_opts:
|
137
|
+
block:
|
138
|
+
line_numbers: false
|
139
|
+
|
140
|
+
compress_html:
|
141
|
+
clippings: all
|
142
|
+
comments: all
|
143
|
+
endings: all
|
144
|
+
startings: []
|
145
|
+
blanklines: false
|
146
|
+
profile: false
|
147
|
+
# ignore:
|
148
|
+
# envs: all
|
@@ -0,0 +1,11 @@
|
|
1
|
+
@import url(https://cdn.jsdelivr.net/npm/firacode@6.2.0/distr/fira_code.css);
|
2
|
+
|
3
|
+
@import './color_schemes/dark.scss';
|
4
|
+
@import './../variables.scss';
|
5
|
+
|
6
|
+
$link-color: $amber_color;
|
7
|
+
$btn-primary-color: $amber_color;
|
8
|
+
$body-font-family: 'Fira Code', Menlo, Consolas, Monospace;
|
9
|
+
$mono-font-family: $body-font-family;
|
10
|
+
// $body-background-color: $amber_black;
|
11
|
+
// $sidebar-color: $amber_black;
|
@@ -0,0 +1,60 @@
|
|
1
|
+
@import './../variables.scss';
|
2
|
+
|
3
|
+
.site-footer {
|
4
|
+
display: none;
|
5
|
+
}
|
6
|
+
|
7
|
+
.search {
|
8
|
+
input.search-input {
|
9
|
+
color: white;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
.btn {
|
14
|
+
&:focus,
|
15
|
+
&:focus:hover,
|
16
|
+
&.selected:focus {
|
17
|
+
box-shadow: 0 0 0 3px rgba($amber_color, 0.25);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
footer {
|
22
|
+
a.personal-link {
|
23
|
+
color: #5c5962;
|
24
|
+
text-decoration: underline;
|
25
|
+
|
26
|
+
&:hover {
|
27
|
+
color: $amber_color;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
.site-header {
|
33
|
+
a.site-title {
|
34
|
+
&:hover {
|
35
|
+
background-image: none;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
.nav-list {
|
41
|
+
.nav-list-item {
|
42
|
+
a.nav-list-link {
|
43
|
+
color: rgba(255, 255, 255, 0.8);
|
44
|
+
}
|
45
|
+
|
46
|
+
&.active {
|
47
|
+
// margin: 0 16px;
|
48
|
+
border-radius: 2px;
|
49
|
+
background-color: rgba($amber_color, 0.3);
|
50
|
+
|
51
|
+
a.nav-list-link {
|
52
|
+
&.active {
|
53
|
+
// padding-left: 18px;
|
54
|
+
color: $amber_color;
|
55
|
+
background-image: none;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
data/docs/api/index.md
ADDED
Binary file
|
data/docs/favicon.ico
ADDED
Binary file
|
data/docs/index.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Home
|
4
|
+
nav_order: 1
|
5
|
+
permalink: /
|
6
|
+
---
|
7
|
+
|
8
|
+
# AmberComponent (v{{ site.data.amber_component.version }})
|
9
|
+
|
10
|
+
A simple component library which seamlessly hooks into your Rails project and allows you to create simple backend components. They work like mini controllers which are bound with their view.
|
11
|
+
|
12
|
+
Created by [Garbus Beach]({{ site.data.amber_component.garbus_beach_url }}){:target="_blank"}
|
13
|
+
and
|
14
|
+
[Mateusz Drewniak]({{ site.data.amber_component.mateusz_drewniak_url }}){:target="_blank"}.
|
15
|
+
|
16
|
+
[Get started now](#getting-started){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 }
|
17
|
+
[View it on GitHub](https://github.com/amber-ruby/amber_component){: .btn .fs-5 .mb-4 .mb-md-0 target="_blank"}
|
data/docs/views/index.md
ADDED
data/docs/views/usage.md
ADDED
data/icon.png
ADDED
Binary file
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ::AmberComponent
|
4
|
+
# Provides methods for locating and manipulating component assets.
|
5
|
+
module Assets
|
6
|
+
# Class methods for assets.
|
7
|
+
module ClassMethods
|
8
|
+
# @return [String]
|
9
|
+
def asset_dir_path
|
10
|
+
component_file_path, = source_location
|
11
|
+
return asset_dir_from_name unless component_file_path
|
12
|
+
|
13
|
+
component_file_path.delete_suffix('.rb')
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String, nil]
|
17
|
+
def asset_dir_from_name
|
18
|
+
return unless defined?(::Rails)
|
19
|
+
|
20
|
+
::Rails.root / 'app' / 'components' / name.underscore
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get an array of all folders containing component assets.
|
24
|
+
# This method should only be used on the parent class `AmberComponent::Base` or `ApplicationComponent`.
|
25
|
+
#
|
26
|
+
# @return [Array<String>]
|
27
|
+
def all_asset_dir_paths
|
28
|
+
subclasses.map(&:asset_dir_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @param file_name [String, nil]
|
32
|
+
# @return [String, nil]
|
33
|
+
def asset_path(file_name)
|
34
|
+
return unless file_name
|
35
|
+
|
36
|
+
::File.join(asset_dir_path, file_name)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the name of the file inside the asset directory
|
40
|
+
# of this component that matches the provided `Regexp`
|
41
|
+
#
|
42
|
+
# @param type_regexp [Regexp]
|
43
|
+
# @return [Array<String>]
|
44
|
+
def asset_file_names(type_regexp)
|
45
|
+
return [] unless ::File.directory?(asset_dir_path)
|
46
|
+
|
47
|
+
::Dir.entries(asset_dir_path).select do |file|
|
48
|
+
next unless ::File.file?(::File.join(asset_dir_path, file))
|
49
|
+
|
50
|
+
file.match? type_regexp
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Instance methods for assets.
|
56
|
+
module InstanceMethods
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|