Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/dfn/dfn.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%dfn{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
6 changes: 6 additions & 0 deletions app/concepts/matestack/ui/core/dfn/dfn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Matestack::Ui::Core::Dfn
class Dfn < Matestack::Ui::Core::Component::Static

end
end

5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/u/u.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%u{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
6 changes: 6 additions & 0 deletions app/concepts/matestack/ui/core/u/u.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Matestack::Ui::Core::U
class U < Matestack::Ui::Core::Component::Static

end
end

49 changes: 49 additions & 0 deletions docs/components/dfn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# matestack core component: Hr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dfn, not Hr


Show [specs](/spec/usage/components/dfn_spec.rb)

The HTML `<dfn>` tag implemented in ruby.

## Parameters

This component can take 2 optional configuration params.

#### # id (optional)
Expects a string with all ids the dfn should have.

#### # class (optional)
Expects a string with all classes the dfn should have.

## Example 1
Adding an optional id

```ruby
div id: "foo", class: "bar" do
dfn id: "dfn-id"
end
```

returns

```html
<div id="foo" class="bar">
<dfn id="dfn-id">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing closing tag

</div>
```

## Example 2
Adding an optional class

```ruby
div id: "foo", class: "bar" do
dfn class: "dfn-class"
end
```

returns

```html
<div id="foo" class="bar">
<dfn class="dfn-class">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing closing tag

</div>
```
49 changes: 49 additions & 0 deletions docs/components/u.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# matestack core component: Hr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U, not Hr


Show [specs](/spec/usage/components/hr_spec.rb)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


The HTML `<u>` tag implemented in ruby.

## Parameters

This component can take 2 optional configuration params.

#### # id (optional)
Expects a string with all ids the u should have.

#### # class (optional)
Expects a string with all classes the u should have.

## Example 1
Adding an optional id

```ruby
div id: "foo", class: "bar" do
u id: "u-id"
end
```

returns

```html
<div id="foo" class="bar">
<u id="u-id">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing closing tag

</div>
```

## Example 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide one example using the text: 'Whatever and one using

u do plain 'Whatever' end 

Just like in the spec file!

Adding an optional class

```ruby
div id: "foo", class: "bar" do
u class: "u-class"
end
```

returns

```html
<div id="foo" class="bar">
<u class="u-class">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing </u> closing tag

</div>
```
66 changes: 66 additions & 0 deletions spec/usage/components/dfn_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
require_relative "../../support/utils"
include Utils

describe 'dfn Component', type: :feature, js: true do

it 'Example 1 - yield, no options[:text]' do

class ExamplePage < Matestack::Ui::Page

def response
components {
# simple dfn
dfn do
plain 'I am simple'
end

# enhanced dfn
dfn id: 'my-id', class: 'my-class' do
plain 'I am enhanced'
end
}
end

end

visit '/example'

static_output = page.html

expected_static_output = <<~HTML
<dfn>I am simple</dfn>
<dfn id="my-id" class="my-class">I am enhanced</dfn>
HTML

expect(stripped(static_output)).to include(stripped(expected_static_output))
end

it 'Example 2 - render options[:text]' do

class ExamplePage < Matestack::Ui::Page

def response
components {
# simple dfn
dfn text: 'I am simple'

# enhanced dfn
dfn id: 'my-id', class: 'my-class', text: 'I am enhanced'
}
end

end

visit '/example'

static_output = page.html

expected_static_output = <<~HTML
<dfn>I am simple</dfn>
<dfn id="my-id" class="my-class">I am enhanced</dfn>
HTML

expect(stripped(static_output)).to include(stripped(expected_static_output))
end

end
66 changes: 66 additions & 0 deletions spec/usage/components/u.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
require_relative "../../support/utils"
include Utils

describe 'u Component', type: :feature, js: true do

it 'Example 1 - yield, no options[:text]' do

class ExamplePage < Matestack::Ui::Page

def response
components {
# simple u
u do
plain 'I am simple'
end

# enhanced u
u id: 'my-id', class: 'my-class' do
plain 'I am enhanced'
end
}
end

end

visit '/example'

static_output = page.html

expected_static_output = <<~HTML
<u>I am simple</u>
<u id="my-id" class="my-class">I am enhanced</u>
HTML

expect(stripped(static_output)).to include(stripped(expected_static_output))
end

it 'Example 2 - render options[:text]' do

class ExamplePage < Matestack::Ui::Page

def response
components {
# simple u
u text: 'I am simple'

# enhanced u
u id: 'my-id', class: 'my-class', text: 'I am enhanced'
}
end

end

visit '/example'

static_output = page.html

expected_static_output = <<~HTML
<u>I am simple</u>
<u id="my-id" class="my-class">I am enhanced</u>
HTML

expect(stripped(static_output)).to include(stripped(expected_static_output))
end

end