Skip to content

Commit

Permalink
Merge pull request #19 from logik-works/beastUI
Browse files Browse the repository at this point in the history
updating readme
  • Loading branch information
Leonid Medovyy authored Nov 29, 2018
2 parents a80d022 + b2543c9 commit 457f0d4
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 102 deletions.
100 changes: 50 additions & 50 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
PATH
remote: .
specs:
dc_ui (2.5.5)
dc_ui (3.0.0)
hashie (~> 3.5.7)
rails (~> 5.2.0)

GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.1)
actionpack (= 5.2.1)
actioncable (5.2.1.1)
actionpack (= 5.2.1.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
actionmailer (5.2.1.1)
actionpack (= 5.2.1.1)
actionview (= 5.2.1.1)
activejob (= 5.2.1.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.1)
actionview (= 5.2.1)
activesupport (= 5.2.1)
actionpack (5.2.1.1)
actionview (= 5.2.1.1)
activesupport (= 5.2.1.1)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.1)
activesupport (= 5.2.1)
actionview (5.2.1.1)
activesupport (= 5.2.1.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.1)
activesupport (= 5.2.1)
activejob (5.2.1.1)
activesupport (= 5.2.1.1)
globalid (>= 0.3.6)
activemodel (5.2.1)
activesupport (= 5.2.1)
activerecord (5.2.1)
activemodel (= 5.2.1)
activesupport (= 5.2.1)
activemodel (5.2.1.1)
activesupport (= 5.2.1.1)
activerecord (5.2.1.1)
activemodel (= 5.2.1.1)
activesupport (= 5.2.1.1)
arel (>= 9.0)
activestorage (5.2.1)
actionpack (= 5.2.1)
activerecord (= 5.2.1)
activestorage (5.2.1.1)
actionpack (= 5.2.1.1)
activerecord (= 5.2.1.1)
marcel (~> 0.3.1)
activesupport (5.2.1)
activesupport (5.2.1.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand All @@ -53,64 +53,64 @@ GEM
ast (2.4.0)
builder (3.2.3)
byebug (10.0.2)
codecov (0.1.10)
codecov (0.1.14)
json
simplecov
url
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.3)
crass (1.0.4)
diff-lcs (1.3)
docile (1.3.1)
erubi (1.7.1)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashie (3.5.7)
i18n (1.1.0)
i18n (1.1.1)
concurrent-ruby (~> 1.0)
json (2.1.0)
loofah (2.2.2)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.2)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.0)
method_source (0.9.2)
mimemagic (0.3.2)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
nio4r (2.3.1)
nokogiri (1.8.4)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
parallel (1.12.1)
parser (2.5.1.2)
parser (2.5.3.0)
ast (~> 2.4.0)
powerpack (0.1.2)
rack (2.0.5)
rack (2.0.6)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.1)
actioncable (= 5.2.1)
actionmailer (= 5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
activemodel (= 5.2.1)
activerecord (= 5.2.1)
activestorage (= 5.2.1)
activesupport (= 5.2.1)
rails (5.2.1.1)
actioncable (= 5.2.1.1)
actionmailer (= 5.2.1.1)
actionpack (= 5.2.1.1)
actionview (= 5.2.1.1)
activejob (= 5.2.1.1)
activemodel (= 5.2.1.1)
activerecord (= 5.2.1.1)
activestorage (= 5.2.1.1)
activesupport (= 5.2.1.1)
bundler (>= 1.3.0)
railties (= 5.2.1)
railties (= 5.2.1.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.1)
actionpack (= 5.2.1)
activesupport (= 5.2.1)
railties (5.2.1.1)
actionpack (= 5.2.1.1)
activesupport (= 5.2.1.1)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
Expand All @@ -123,7 +123,7 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.1)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
Expand All @@ -150,7 +150,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.20.0)
thor (0.20.3)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
Expand All @@ -173,4 +173,4 @@ DEPENDENCIES
rubocop (~> 0.50.0)

BUNDLED WITH
1.16.4
1.17.1
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# DC-UI
# beastUI
[ ![Codeship Status for leonid-io/dc-ui](https://app.codeship.com/projects/3a47e490-8794-0135-3a84-7eb6ba30fb88/status?branch=master)](https://app.codeship.com/projects/248380)
[![codecov](https://codecov.io/gh/leonid-io/dc-ui/branch/master/graph/badge.svg)](https://codecov.io/gh/leonid-io/dc-ui)

DC-UI makes it easy to build a custom front-end dsl for you.

It is loosly coupled with [Semantic UI](http://www.semantic-ui.com) and
adds some framework specific options to make front-end development a little easier.
Conquer complex UIs with beastUI.

## Benefits

- Better front end design
- Cleaner markup
- Rapidly build complex UIs.
- Massive reduction in Cognitive Load
- Cleaner(ish) Markup
- Build a deisgn vocabulary
- Faster front end Development
- Easier UI Upgrades (debatable)
- Rapid UI iterations


## Installation

Expand Down Expand Up @@ -163,8 +163,9 @@ will produce
<div class="segment hero"><h1>Hello World</h1></div>
```

## Contributing
Made and maintained by [Leonid Medovyy](http://www.leonid.io)
## Contributors
- [Leonid Medovyy]()


## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
10 changes: 9 additions & 1 deletion lib/dc_ui/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def build_component
build_default_class
build_vue
build_vue_props
build_stimulus_props
end

# builds out the ui class for the component
Expand Down Expand Up @@ -73,7 +74,7 @@ def build_default_class
add_class @settings[:css_class] if @settings.key?(:css_class)
end

# enalbes vue in the data array
# enables vue in the data array
def build_vue
add_data :vue, true if on?(:vue)
end
Expand All @@ -86,6 +87,13 @@ def build_vue_props
end
end

# builds out stimulus.js shortcuts
def build_stimulus_props
add_data :controller, @settings[:controller] if @settings.key?(:controller)
add_data :target, @settings[:target] if @settings.key?(:target)
add_data :action, @settings[:action] if @settings.key?(:action)
end

private

def transpose_settings(items)
Expand Down
64 changes: 34 additions & 30 deletions lib/dc_ui/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
module DcUi
# helper module that gets included into a gem
module Helpers
# ui factory
def ui(name, args = {}, &block)
settings = DcUi::Utilities.instance.merge_defaults(name, args)
component = DcUi::Component.new(settings)
render_component(component, &block)
end

# rubocop:disable MethodLength
def method_missing(m, *args, &block)
if DcUi::Utilities.instance.component_defined?(m)
Expand All @@ -31,57 +24,68 @@ def respond_to_missing?(method_name, include_private = false)

private

# ui factory
def ui(name, args = {}, &block)
settings = DcUi::Utilities.instance.merge_defaults(name, args)
component = DcUi::Component.new(settings)
render_component(component, &block)
end

def render_component(component, &block)
# throw an error if the url & img are both passed in
error_msg = 'Can not pass `img` and `url` at the same time. You must choose ...'
raise ArgumentError, error_msg if component.url && component.img

if component.img
build_image_component(component)
render_image_component(component)
elsif component.url
build_link_component(component, &block)
render_link_component(component, &block)
else
build_tag_component(component, &block)
render_tag_component(component, &block)
end
end

def build_image_component(c)
arguments = build_arguments(c)
image_tag c.img, arguments
# renders the image component
def render_image_component(component)
arguments = build_arguments(component)
image_tag component.img, arguments
end

def build_link_component(c, &block)
arguments = build_arguments(c)
link_to c.url, arguments do
if c.text.nil?
# renders the link component
def render_link_component(component, &block)
arguments = build_arguments(component)
link_to component.url, arguments do
if component.text.nil?
raw(capture(&block)) if block_given?
else
c.text
component.text
end
end
end

def build_tag_component(c, &block)
arguments = build_arguments(c)
# renders the tag component
def render_tag_component(component, &block)
arguments = build_arguments(component)

content_tag c.tag, arguments do
if c.text.nil?
content_tag component.tag, arguments do
if component.text.nil?
raw(capture(&block)) if block_given?
else
c.text
component.text
end
end
end

def build_arguments(c)
# constructs the arguments from a component
def build_arguments(component)
arguments = {}
arguments[:class] = c.css_class
arguments[:id] = c.id
arguments[:data] = c.data
arguments[:style] = c.style
return arguments if c.vue_props.empty?
arguments[:class] = component.css_class
arguments[:id] = component.id
arguments[:data] = component.data
arguments[:style] = component.style
return arguments if component.vue_props.empty?

c.vue_props.each do |prop|
component.vue_props.each do |prop|
arguments[prop.keys.first] = prop.values.first
end
arguments
Expand Down
15 changes: 5 additions & 10 deletions lib/dc_ui/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ def component_defined?(component)
# Merges passed options with defaults defined in the config file
def merge_defaults(component, args = nil)
component_missing?(component)
args = prepare_args(args)

# special case where only a single string is passed as an argument
# we're treating it as the same as setting a class
args = { class: args } if !args.nil? && args.is_a?(String)
args = {} if args.nil? || args.empty?

defaults = @config.defaults[component]

Expand Down Expand Up @@ -58,15 +62,6 @@ def number_in_words(int)

private

# parses arguments
def prepare_args(args)
# special case where only a single string is passed as an argument
# we're treating it as the same as setting a class
args = { class: args } if !args.nil? && args.is_a?(String)
args = {} if args.nil? || args.empty?
args
end

# raises component missing error
def component_missing?(component)
error = "component :: #{component} :: is undefined in the ui.yml"
Expand Down
2 changes: 1 addition & 1 deletion lib/dc_ui/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module DcUi
VERSION = '2.5.5'.freeze
VERSION = '3.0.0'.freeze
end

0 comments on commit 457f0d4

Please sign in to comment.