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

Make application routes usable on example views #141

Open
wants to merge 6 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
**Enhancements:**
- Support for Rails 6
- Refactoring to use `Utils` in `InstallGenerator` and prevent code duplication
- Stop isolating `Komponent` namespace to allow using routes from main application in components ([#141](https://github.com/komposable/komponent/pull/141))
NB: If you already generated a styleguide in your app, you need to replace `styleguide_path` by `komponent.styleguide_path` in `styleguide/components/sidebar`

**Bug fixes:**
- Fixed empty `h1` in generated `_examples.html.*` file
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ This command will:
* add a new `komponent.js` pack to your packs folder
* mount the engine in your routes

Then, for each component, you can describe it and render examples for each state in the `_example.html.slim` file from the component folder. The engine will then render it on the component page.
Then, for each component, you can describe it and render examples for each state in the `_examples.html.slim` file from the component folder. The engine will then render it on the component page.

If you have existing components, you can generate all their example files at once with:

Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

Komponent::Engine.routes.draw do
resources :styleguide, only: %i[index show]
resources :styleguide, only: %i[index show], module: :komponent
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<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) %>
<%= link_to_unless_current component.title, komponent.styleguide_path(id: component.id) %>
</li>
<% end %>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion lib/komponent/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

module Komponent
class Engine < Rails::Engine
isolate_namespace Komponent
engine_name "komponent"
nicolas-brousse marked this conversation as resolved.
Show resolved Hide resolved

rake_tasks do
load 'komponent/rails/tasks/komponent.rake'
Expand Down