class NfgUi::Components::Foundations::Image

Image doc coming soon

Public Instance Methods

image() click to toggle source

Prefer image, image is used on other components that pull in the image (e.g. Illustration)

# File lib/nfg_ui/components/foundations/image.rb, line 15
def image
  options.fetch(:image, nil)
end
render() click to toggle source
# File lib/nfg_ui/components/foundations/image.rb, line 19
def render
  image_tag(view_context.image_path(image_location), **html_options)
end
src() click to toggle source

Allow :src to come through since :src is a native and viable to way source a image path / url

# File lib/nfg_ui/components/foundations/image.rb, line 26
def src
  options.fetch(:src, image)
end

Private Instance Methods

component_css_class() click to toggle source
# File lib/nfg_ui/components/foundations/image.rb, line 36
def component_css_class
  ''
end
default_responsive() click to toggle source
# File lib/nfg_ui/components/foundations/image.rb, line 40
def default_responsive
  true
end
image_location() click to toggle source

Provide a fallback image location and default to src :src will default to the :image option if :src is not set.

We prefer the :image keyword here because of its specificity and to pass between components.

Ex: `:button, image: '…'`

# File lib/nfg_ui/components/foundations/image.rb, line 51
def image_location
  src || ''
end
non_html_attribute_options() click to toggle source

:src is removed because we leveage the image_tag helper method.

the image_tag helper method automatically turns the first argument into the `src` attribute.

# File lib/nfg_ui/components/foundations/image.rb, line 58
def non_html_attribute_options
  super.push(:image, :src)
end
responsive_css_class() click to toggle source
# File lib/nfg_ui/components/foundations/image.rb, line 32
def responsive_css_class
  'img-fluid'
end