From abe305b2122e18009bf274f2ec6bbb34a0b435f6 Mon Sep 17 00:00:00 2001 From: Nicolas Brousse Date: Wed, 3 Apr 2019 14:55:50 +0200 Subject: [PATCH 1/6] Make application routes usable on example views --- app/controllers/komponent/styleguide_controller.rb | 2 ++ .../styleguide/components/sidebar/_komponent_sidebar.html.erb | 2 +- lib/komponent/engine.rb | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/komponent/styleguide_controller.rb b/app/controllers/komponent/styleguide_controller.rb index 5c8e8cd..47132c4 100644 --- a/app/controllers/komponent/styleguide_controller.rb +++ b/app/controllers/komponent/styleguide_controller.rb @@ -5,6 +5,8 @@ class StyleguideController < ::ApplicationController layout 'komponent' rescue_from ActionView::MissingTemplate, with: :missing_template + include Rails.application.routes.url_helpers + def index; end def show diff --git a/lib/generators/komponent/templates/styleguide/components/sidebar/_komponent_sidebar.html.erb b/lib/generators/komponent/templates/styleguide/components/sidebar/_komponent_sidebar.html.erb index 195ade3..f6198a5 100644 --- a/lib/generators/komponent/templates/styleguide/components/sidebar/_komponent_sidebar.html.erb +++ b/lib/generators/komponent/templates/styleguide/components/sidebar/_komponent_sidebar.html.erb @@ -3,7 +3,7 @@ diff --git a/lib/komponent/engine.rb b/lib/komponent/engine.rb index 477160c..154a1ae 100644 --- a/lib/komponent/engine.rb +++ b/lib/komponent/engine.rb @@ -9,6 +9,7 @@ module Komponent class Engine < Rails::Engine + engine_name "komponent" isolate_namespace Komponent rake_tasks do From 8f7d0d31a0be9f49dda8d0a1afa00fde2af943d0 Mon Sep 17 00:00:00 2001 From: Nicolas Brousse Date: Tue, 19 Nov 2019 23:08:24 +0100 Subject: [PATCH 2/6] Stop isolating Komponent namespace --- app/controllers/komponent/styleguide_controller.rb | 2 -- config/routes.rb | 2 +- lib/komponent/engine.rb | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/komponent/styleguide_controller.rb b/app/controllers/komponent/styleguide_controller.rb index 47132c4..5c8e8cd 100644 --- a/app/controllers/komponent/styleguide_controller.rb +++ b/app/controllers/komponent/styleguide_controller.rb @@ -5,8 +5,6 @@ class StyleguideController < ::ApplicationController layout 'komponent' rescue_from ActionView::MissingTemplate, with: :missing_template - include Rails.application.routes.url_helpers - def index; end def show diff --git a/config/routes.rb b/config/routes.rb index 7293246..cfa10cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/lib/komponent/engine.rb b/lib/komponent/engine.rb index 154a1ae..41c40da 100644 --- a/lib/komponent/engine.rb +++ b/lib/komponent/engine.rb @@ -10,7 +10,6 @@ module Komponent class Engine < Rails::Engine engine_name "komponent" - isolate_namespace Komponent rake_tasks do load 'komponent/rails/tasks/komponent.rake' From ecec0740052c88dfa1f7f1a457aff8145fe4f894 Mon Sep 17 00:00:00 2001 From: Nicolas Brousse Date: Tue, 19 Nov 2019 23:08:31 +0100 Subject: [PATCH 3/6] Clean README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb1b078..9881451 100644 --- a/README.md +++ b/README.md @@ -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: From 22d2b2fe4ce14770eab6064c36a3d89067ce760b Mon Sep 17 00:00:00 2001 From: Nicolas Brousse Date: Tue, 19 Nov 2019 23:11:23 +0100 Subject: [PATCH 4/6] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad3b47..303e2e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ **Enhancements:** - Support for Rails 6 - Refactoring to use `Utils` in `InstallGenerator` and prevent code duplication +- Stop isolating `Komponent` namespace to permit route usage in components ([#141](https://github.com/komposable/komponent/pull/141)) **Bug fixes:** - Fixed empty `h1` in generated `_examples.html.*` file From d78ecee642b6d350fec04b2dfa5a2d6c5b7d10bd Mon Sep 17 00:00:00 2001 From: Nicolas Brousse Date: Wed, 20 Nov 2019 22:28:40 +0100 Subject: [PATCH 5/6] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 303e2e7..9ef2f62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Support for Rails 6 - Refactoring to use `Utils` in `InstallGenerator` and prevent code duplication - Stop isolating `Komponent` namespace to permit route usage in components ([#141](https://github.com/komposable/komponent/pull/141)) + Generated styleguide needs to replace `styleguide_path` by `komponent.styleguide_path` in `styleguide/components/sidebar` **Bug fixes:** - Fixed empty `h1` in generated `_examples.html.*` file From 35189ba9cc5092252a691295964c4e95ceff23e6 Mon Sep 17 00:00:00 2001 From: Hans Lemuet Date: Thu, 28 Nov 2019 16:26:26 +0100 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef2f62..96d43e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,8 @@ **Enhancements:** - Support for Rails 6 - Refactoring to use `Utils` in `InstallGenerator` and prevent code duplication -- Stop isolating `Komponent` namespace to permit route usage in components ([#141](https://github.com/komposable/komponent/pull/141)) - Generated styleguide needs to replace `styleguide_path` by `komponent.styleguide_path` in `styleguide/components/sidebar` +- 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