Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stops komponent components from being listed in the style guide sidebar #167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Each component comes with a Ruby `module`. You can use it to set properties:

module ButtonComponent
extend ComponentHelper

property :href, required: true
property :text, default: 'My button'
end
Expand All @@ -204,7 +204,7 @@ If your partial becomes too complex and you want to extract logic from it, you m

module ButtonComponent
extend ComponentHelper

property :href, required: true
property :text, default: 'My button'

Expand Down Expand Up @@ -461,9 +461,9 @@ resolved_paths:

## Running tests

Run all Cucumber features and unit tests with `bundle exec appraisal rake test`
Install all the gems `bundle exec appraisal install`

Run the full test matrix with `bundle exec appraisal rake test`
then run the full test matrix with `bundle exec appraisal rake test`

## Contributing

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="komponent-container">
<%= yield %>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* stylelint-disable value-list-comma-newline-after */

.komponent-container {
font-size: 16px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
margin: 40px 60px 0 300px;

.komponent-code {
background-color: #333;
color: #fff;
margin: 10px 0;
padding: 10px;
}
}

/* stylelint-enable */
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./komponent_container.css";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

module KomponentContainerComponent
extend ComponentHelper
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="komponent-footer">
Built with <%= link_to "Komponent", "http://komponent.io", target: "_blank" %>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* stylelint-disable value-list-comma-newline-after */

.komponent-footer {
bottom: 30px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 14px;
position: fixed;
right: 30px;
text-align: center;

&,
a {
color: #999;
}

a {
text-decoration: none;

&:hover,
&:focus {
color: #0038ea;
}
}
}

/* stylelint-enable */
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./komponent_footer.css";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

module KomponentFooterComponent
extend ComponentHelper
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="komponent-header">
<div class="logo">Styleguide</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* stylelint-disable value-list-comma-newline-after */

.komponent-header {
align-items: center;
background-color: #0038ea;
color: white;
display: flex;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 16px;
height: 60px;
padding: 0 20px;
}

/* stylelint-enable */
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./komponent_header.css";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

module KomponentHeaderComponent
extend ComponentHelper
end
5 changes: 5 additions & 0 deletions fixtures/my_app/frontend/components/komponent/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "components/komponent/container/komponent_container";
import "components/komponent/footer/komponent_footer";
import "components/komponent/header/komponent_header";
import "components/komponent/sidebar/komponent_sidebar";

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="komponent-sidebar">
<div class="komponent-sidebar-title">Components</div>
<ul class="komponent-sidebar-items">
<%- components.each do |_k, component| %>
<li class="komponent-sidebar-item">
<%= link_to_unless_current component.title, styleguide_path(id: component.id) %>
</li>
<% end %>
</ul>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* stylelint-disable value-list-comma-newline-after */

.komponent-sidebar {
background-color: #dbe1f3;
bottom: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
left: 0;
overflow: auto;
padding: 20px;
position: absolute;
top: 60px;
width: 240px;

&-title {
color: #0038ea;
font-size: 14px;
font-weight: bold;
letter-spacing: 1px;
margin: 0 0 20px;
text-transform: uppercase;
}

&-items {
font-size: 14px;
letter-spacing: 0;
line-height: 1.25;
list-style: none;
margin: 0 0 30px;
padding: 0;
}

&-item {
margin: 0 0 5px;
}

a {
color: #333;
text-decoration: none;
}
}

/* stylelint-enable */
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./komponent_sidebar.css";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

module KomponentSidebarComponent
extend ComponentHelper
end
12 changes: 10 additions & 2 deletions lib/komponent/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def all
Dir.glob(component_dirs).sort.each do |component_dir|
component_path = Pathname.new(component_dir).relative_path_from(components_root).to_s

next unless File.exist?(components_root.join(component_path)
.join("#{component_path.underscore.gsub('/', '_')}_component.rb"))
next unless list_this_component_path?(component_path)

components[component_path] = Component.new(component_path)
end
Expand All @@ -32,6 +31,15 @@ def find(id)
def components_root
@components_root ||= Rails.application.config.komponent.root.join('components')
end

private

def list_this_component_path?(component_path)
return false if component_path.starts_with?('komponent/')

File.exist?(components_root.join(component_path)
.join("#{component_path.underscore.gsub('/', '_')}_component.rb"))
end
end

attr_reader :id
Expand Down