
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
bootstrap4_rails_components
Advanced tools
The authoritative resource for the Network for Good front-end UI, empowered by the NFG Design System.
Note: the readme documentation is a little out of date and will be updated with accurate info soon (note added on Jan. 19, 2019)
Jump to development / setting up the gem locally
gem 'bootstrap4_rails_components'
NFG UX & UI team_ (J&K) are excited to bring you... the Network For Good design system gem or: bootstrap4_rails_components
gem. This bad boy is an all encompassing one-stop shop for everything front-end for Network for Good products.
This gem is an organic, evolving and ongoing work that is the loving result of 4+ years of study, practice, implementation, planning, drafting and good ol' sweat. After a dozen code drafts, a fully realized Sketch design system suite, and the canvas to work on... we're building a robust design system framework.
With this gem, you can stand up a brand new rails app and it will seamlessly, from day 1, look, feel and be a Network for Good product. Huzzah
To review the documentation for the components, get code samples and browse the library, follow the instructions at the bottom for getting the gem setup locally. It has its own test_app
so the documentation is hosted there and the gem doesn't need to be added to a seperate parent app (unless you want to). We intend to get this online in its own dedicated space... until then, that's your best bet for browsing docs.
gem 'bootstrap4_rails_components'
NOTE: This gem has not taken over ownership of JS from Evo yet. Some styles have been brought over for documentation visual check purposes (the core styling is in place), but it's not fully brought over yet. This includes javascript plugins, etc. To use bootstrap4_rails_components
images, note the special requirements:
In application.scss
add your pertinent stylesheet suite based on whatever context you're building an interface. These are currently two categories: admin
and public
(and email
)
Admin stylesheets should be @imported
in your pertinent application.scss file:
@import 'bootstrap4_rails_components/network_for_good/admin/application';
Public stylesheets should be @imported
in your pertinent application.scss file:
@import 'bootstrap4_rails_components/network_for_good/public/application';
Email stylesheeets should be @imported
as above:
@import 'bootstrap4_rails_components/network_for_good/email/application';
Currently, there is only one javascript library. This will likely change, but the current setup is as follows:
Javascript should be //= required
in your pertinent application.js file:
//= require bootstrap4_rails_components/application
This gem allows you to add any NFG design component to your haml view at command. You can build one line, all inclusive components and build out high level pre-designed and pre-configured context-specific components.
Components also come with traits. Traits are stackable and overwriteable. Traits are meaningful symbols added as the first array of arguments on your component. Read more about traits below. The key value of traits: it provides pre-set and pre-designed components out of the box so that you don't need to go through the monotonous task of adding theme colors, sizes, headlines, etc every time you need to use that component. Handy
All components accept the same attributes when appropriate. This list will expand but here is a sample:
id
, data
, aria
, required
, if it's an attribute, it's available)body: 'Inserted content into the obvious content space for the component'
title: 'For modals and tiles'
headline: 'For components with headlines like media objects'
:collapsible
and :collapsed
tooltip: 'My tooltip text'
is available on many components (that would make sense to have tooltips) and will automatically apply a tooltip to the componentExamples:
// Produce a styled, pre-designed submit button for your form on the fly
= ui.bootstrap :button, :submit
// Is the traited / predesigned equivalent of...
= ui.bootstrap :button, as: :button, type: 'submit', icon: 'chevron-right', body: 'Save & Exit', theme: :primary, disable_with: "<i class='fa fa-spinner fa-spin mr-1'></i> Saving..."
// Build your own button
= ui.bootstrap :button, :danger, data: { describe: 'delete-button' } do
= ui.bootstrap :icon, 'trash', class: 'mr-1', text: 'Delete Row'
Traits are designed to allow you to speedily build components, or pre-design complex components using meaningful symbols.
Traits are pre-designed / pre-created in the gem (the process / system for this is getting an update after some very cool conversations recently, but the implementation on the front end likely won't be changing)
We use two general "kinds" of traits (this is being examined in more detail, but the usage is the same).
The first "kind" of trait is "speedy" versions of options. The second "kind" of trait are more like a combination of options.
We do this, for example, with an error alert, which then pre-supplies a set of options...
= ui.bootstrap :alert, :error
// is the pre-designed error alert that looks like this:
= ui.bootstrap :alert, :dismissible, theme: :danger, heading: 'Oops!', body: 'There appears to be someting wrong with your submission! Please take a look...'
The second kind of trait is the speedy version (described above).
Here are some implementation examples of speedy traits:
ui.bootstrap :button, :primary
is a speedy way to write ui.bootstrap :button, theme: :primary
:primary
:secondary
:success
:danger
:warning
:info
:light
:dark
ui.bootstrap :button, :large
is the same as ui.bootstrap :button, size: :large
:lg
:large
:sm
:small
ui.bootstrap :tile, :collapsible
is the same as ui.bootstrap :tile, collapsed: false
ui.bootstrap :tile, :collapsed
is the same as ui.bootstrap :tile, collapsed: true
:collapsible
:collapsed
More soon...
Syntax: = ui.bootstrap :component_name, optional_traits, options
Components are organized into 4 major groupings. Currently 3 of the groupings are available through this gem.
The basic essentials that form elements
:color
:icon
:image
:input
:grid
:typeface
The main component blocks, made up of foundation components.
:activity
:alert
:badge
:breadcrumb
:breadcrumb_item
:button
:chart
:dropdown
:form_control
:input_group
:key
:list_group_item
:loader
:media_object
:nav
:popover
:progress_bar
:slat
:stat
:table
:task
:tooltip
Groupings of elements to create rich interfaces. For example, an :activity_feed
(one of the patterns) is made up many :activity
:activity_feed
:button_group
:card
:carousel
:empty_state
:filter_bar
:form_group
:graph
:jumbotron
:list_group
:media
:modal
:navbar
:slat_list
:task_list
:tile
:tile_body
:tile_header
:tile_section
Coming soon
Utilize all bootstrap4 components, coded to strict bootstrap standards via a similar method: = ui.bootstrap :my_component, options...
Note: while the names of bootstrap components and network for good components may be similar or identical (ex.: the design system has an :alert
as does bootstrap), do not use bootstrap components on the front-end. Only use ui.bootstrap
components for front-end code. Great care has been taken to ensure that any component you'd expect to have from bootstrap4 is made available by an appropriately coded and designed design system component
The bootstrap side of this will eventually be isolated into its own gem. Until then, it lives within the bootstrap4_rails_components
gem.
// An example alert
= ui.bootstrap :alert, theme: :danger, dismissible: false, headline: 'Oh snap!', body: 'The alert body content'
// Build your own button
= ui.bootstrap :button, theme: :danger, data: { describe: 'delete-button' } do
= fa_icon 'trash', class: 'mr-1', text: 'Delete Row'
Syntax: = ui.bootstrap :component_name, options
:alert
:badge
:breadcrumb
:breadcrumb_item
:button
:button_group
:card
:carousel
:dropdown
:form
:input_group
:jumbotron
:list_group
:list_group_item
:media_object
:modal
:nav
:navbar
:pagination
:popover
:progress
:table
:tooltip
$ git clone https://github.com/network-for-good/bootstrap4_rails_components.git
$ bundle exec bundle install
See this gist: https://gist.github.com/jonathanroehm/70749fb6f29c61d0af7c7ed9cc233f79
All done!
Browse the components at: http://localhost:3000/
From the gem's root directory (not spec/test_app/):, Begin rails server the normal way.
$ rails s
If you're running other rails apps on port 3000 or 3001 you can run this on another port, for example:
$ rails s -p 3003
Documentation .haml files can be found here:
/spec/test_app/app/views
Within that folder are all of the component code examples found when you click through the navigation. Divided up as Bootstrap
, then the grouping names: patterns
, elements
, foundations
.
From the gem's root directory (not spec/test_app/): This gem comes with spring, you can use spring when executing rspec
$ spring rspec
$ Collapsible? (Y/n):
Write out a step by step process for manually creating a component of different nesting levels
Trait documentation
RDoc
Userful error library, particularly on any quirky things (also note quirky things as code-smell stuff to fix.).
Look into setting up an installer for allowing configuration options (specifically, initially on whether or not to include simple_form)
Host test_app on heroku for online documentation
Migrate test_app content into the design system CMS app.
Design token integration
API feed for design token for third party sites like wordpress?
Add I18n lookup.
Update browser gem in all NFG apps to 2.5+
Review what's involved in having simple_form "subscribe" to our design system inputs and form controls, particularly the advanced ones (like radio buttons with images) so that the design system is actually hosting the html and not obnoxiously complicated simple_form classes doing that job.
Design tokens
need a better way to define and create / map traits. I am not enjoying the bloat in attr_readers...
Generator for customizable components with commented out class methods (like devise's generated controllers) for easy customization (reference that kicked this off was the modal title ... allowing an icon on the bs version might be what you want to do if you're a gem consumer...)
Consider implementing a universal catch all "content" attribute when there's only one region so that users don't need to guess if a something like the dropdown header uses heading
or body
or content
for passing in the content.
Create a registered list ... for things like tooltippable nfg components (all? some?) -- that way can mass add modules for nfg side as needed.
Look into collapsible toggle / collapse toggle, There are lots of buttons that have their classes removed so they can behave as a "link"
Trait specs
Consider moving component_css_class out of private so it can be manipulated in the component (instead of needing stuff like remove_component_css_classes methods)
Author useful error notifications for missing traits (instead of 'something_trait' method error)
need an overlay_blocker
should form-row be a (nfg?) component? see: Givecorps-site/app/views/bootstrap4/addresses/_address_form.html.haml
card sub title and card title components?
consider typeface for link_to so we can supply our luxuries to link_to.
Add a trait for dropdown items where we pass in a "not_deletable" type of attribute that shows when a can't delete condition is present -- or make it more generic and have it be embedded dropdown text that we conditionalize on the component.
Examine how theme css prefix class is being worked out... looks like we'd be better off having some kind of value that's shared / accessible... somethign like "type of theme" ... :text (text-success). right now, we're doing it by setting the prefix to 'text-'
Slat list sm ...
Add a generator to supply the bootstrap shared examples for spec writing your own components.
Need to integrate will_paginate rendering into the bootstrap4_rails_components gem.
FAQs
Unknown package
We found that bootstrap4_rails_components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.