-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
371 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
; top-most EditorConfig file | ||
root = true | ||
|
||
; Unix-style newlines | ||
[*] | ||
end_of_line = LF | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require "komponent/component" | ||
|
||
module Komponent | ||
class StyleguideController < ::ApplicationController | ||
layout 'komponent' | ||
rescue_from ActionView::MissingTemplate, with: :missing_template | ||
|
||
def index; end | ||
|
||
def show | ||
@component = Komponent::Component.find(params[:id]) | ||
end | ||
|
||
private | ||
|
||
def missing_template | ||
render "komponent/styleguide/missing_template" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="header"> | ||
<h1>Styleguide</h1> | ||
</div> | ||
|
||
<% if komponent_components.any? %> | ||
<div class="description"> | ||
Select one of the components from the side to view its examples and documentation. | ||
</div> | ||
<% else %> | ||
<div class="hint"> | ||
<h2><span>Hint:</span>You haven't created any components yet</h2> | ||
<p>You can generate your first component by running:</p> | ||
<pre>rails generate component component-name</pre> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>Example missing</h1> | ||
|
||
<p>Please create <code><%= @component.path %>/_example.html.<%= Rails.application.config.app_generators.rails[:template_engine] || :erb %></code> file.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render partial: @component.example_view %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Styleguide</title> | ||
<%= javascript_pack_tag "komponent" %> | ||
<%= stylesheet_pack_tag "komponent", media: "all" %> | ||
<%= csrf_meta_tags %> | ||
</head> | ||
<body> | ||
<%=c 'komponent/header' %> | ||
<%=c 'komponent/sidebar' %> | ||
<%=c 'komponent/container' do %> | ||
<%= yield %> | ||
<% end %> | ||
<%=c 'komponent/footer' %> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
Komponent::Engine.routes.draw do | ||
resources :styleguide, only: %i[index show] #, path: Komponent.configuration.styleguide_path | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
frontend/components/komponent/container/_komponent_container.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="komponent-container"> | ||
<%= yield %> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
frontend/components/komponent/container/komponent_container.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.komponent-container { | ||
margin-left: 24rem; | ||
margin-top: 4rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./komponent_container.css"; |
5 changes: 5 additions & 0 deletions
5
frontend/components/komponent/container/komponent_container_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module KomponentContainerComponent | ||
extend ComponentHelper | ||
end |
3 changes: 3 additions & 0 deletions
3
frontend/components/komponent/footer/_komponent_footer.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.komponent-footer { | ||
font-size: 1.4rem; | ||
position: absolute; | ||
bottom: 4rem; | ||
right: 4rem; | ||
text-align: center; | ||
|
||
&, | ||
a { | ||
color: #999; | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
|
||
&:hover, | ||
&:focus { | ||
color: #0038ea; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./komponent_footer.css"; |
5 changes: 5 additions & 0 deletions
5
frontend/components/komponent/footer/komponent_footer_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module KomponentFooterComponent | ||
extend ComponentHelper | ||
end |
3 changes: 3 additions & 0 deletions
3
frontend/components/komponent/header/_komponent_header.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="komponent-header"> | ||
<div class="logo">Styleguide</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.komponent-header { | ||
align-items: center; | ||
background-color: #0038ea; | ||
color: white; | ||
display: flex; | ||
font-size: 1.8rem; | ||
height: 8rem; | ||
padding: 2rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./komponent_header.css"; |
5 changes: 5 additions & 0 deletions
5
frontend/components/komponent/header/komponent_header_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module KomponentHeaderComponent | ||
extend ComponentHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import "components/komponent/container/komponent_container"; | ||
import "components/komponent/footer/komponent_footer"; | ||
import "components/komponent/header/komponent_header"; | ||
import "components/komponent/sidebar/komponent_sidebar"; |
10 changes: 10 additions & 0 deletions
10
frontend/components/komponent/sidebar/_komponent_sidebar.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> | ||
<%- komponent_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> |
35 changes: 35 additions & 0 deletions
35
frontend/components/komponent/sidebar/komponent_sidebar.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.komponent-sidebar { | ||
background-color: #dbe1f3; | ||
bottom: 0; | ||
left: 0; | ||
padding: 4rem 2rem; | ||
position: absolute; | ||
top: 8rem; | ||
width: 20rem; | ||
|
||
&-title { | ||
color: #0038ea; | ||
font-size: 1.4rem; | ||
font-weight: bold; | ||
letter-spacing: 0.2rem; | ||
margin: 0 0 2rem; | ||
text-transform: uppercase; | ||
} | ||
|
||
&-items { | ||
line-height: 1.25; | ||
list-style: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
&-item + &-item { | ||
margin-top: 0.5rem; | ||
} | ||
|
||
a { | ||
color: #333; | ||
display: block; | ||
text-decoration: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./komponent_sidebar.css"; |
5 changes: 5 additions & 0 deletions
5
frontend/components/komponent/sidebar/komponent_sidebar_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module KomponentSidebarComponent | ||
extend ComponentHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1><%= component_name %></h1> | ||
|
||
<%%= component "<%= component_name %>" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%h1 <%= component_name %> | ||
|
||
= component "<%= component_name %>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
h1 <%= component_name %> | ||
|
||
= component "<%= component_name %>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'komponent/component' | ||
|
||
module Komponent | ||
module Generators | ||
class ExamplesGenerator < Rails::Generators::Base | ||
source_root File.expand_path('../../component/templates', __FILE__) | ||
|
||
def create_example_files | ||
Komponent::Component.all.each do |name, component| | ||
@name = name | ||
create_example_view_file | ||
end | ||
end | ||
|
||
protected | ||
|
||
# TODO: refactoring | ||
# all methods below come from ComponentGenerator | ||
def split_name | ||
@name.split(/[:,::,\/]/).reject(&:blank?).map(&:underscore) | ||
end | ||
|
||
def component_path | ||
path_parts = [default_path, "components", *split_name] | ||
|
||
Pathname.new(path_parts.join("/")) | ||
end | ||
|
||
def component_name | ||
split_name.last.underscore | ||
end | ||
|
||
def rails_configuration | ||
Rails.application.config | ||
end | ||
|
||
def app_generators | ||
rails_configuration.app_generators | ||
end | ||
|
||
def template_engine | ||
app_generators.rails[:template_engine] || :erb | ||
end | ||
|
||
def default_path | ||
rails_configuration.komponent.root | ||
end | ||
|
||
private | ||
|
||
def create_example_view_file | ||
template "example.html.#{template_engine}.erb", component_path + "_example.html.#{template_engine}" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require "komponent/version" | ||
require 'komponent/version' | ||
|
||
module Komponent | ||
require 'komponent/railtie' if defined?(Rails) | ||
require 'komponent/engine' if defined?(Rails) | ||
end |
Oops, something went wrong.