Skip to content

Add noscript tag #231

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

Merged
merged 1 commit into from
Oct 8, 2019
Merged
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
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/noscript/noscript.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%noscript{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/noscript/noscript.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Matestack::Ui::Core::Noscript
class Noscript < Matestack::Ui::Core::Component::Static

end
end
1 change: 1 addition & 0 deletions docs/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ You can build your [own components](/docs/extend/custom_components.md) as well,
- [link](/docs/components/link.md)
- [label](/docs/components/label.md)
- [progress](/docs/components/progress.md)
- [noscript](/docs/components/noscript.md)

## Dynamic Core Components

Expand Down
45 changes: 45 additions & 0 deletions docs/components/noscript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# matestack core component: Noscript

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

The HTML noscript tag implemented in ruby.

## Parameters

This component can take 2 optional configuration params and either yield content or display what gets passed to the `text` configuration param.

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

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

## Example 1: Yield a given block

```ruby
noscript id: "foo", class: "bar" do
plain 'Hello World' # optional content
end
```

returns

```html
<noscript id="foo" class="bar">
Hello World
</noscript>
```

## Example 2: Render options[:text] param

```ruby
noscript id: "foo", class: "bar", text: 'Hello World'
```

returns

```html
<noscript id="foo" class="bar">
Hello World
</noscript>

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

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

it 'Example 1' do

class ExamplePage < Matestack::Ui::Page

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

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

end

visit '/example'

static_output = page.html

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

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

end