% @side_nav = "js" %>
To create the dropdown you'll need to attach a data-dropdown="your-id"
to whatever element you want the dropdown attached to. From there you'll create a list that holds the links or content and add an id="your-id"
that associates with the element it belongs to. To style the dropdown, we've included a class of .f-dropdown
that you can target and style to your hearts desire. If you want the dropdown to be content, simply chain the class .content
to the dropdown. Here's an example of that markup:
Has Dropdown | Has Content Dropdown
You'll notice that data-dropdown="drop1"
and id="drop1"
have the same value. This is what tells the dropdown plugin where to look to find the position to attach the dropdown.
Available class options:
tiny
: Make the dropdown have a max-width of 200pxsmall
: Make the dropdown have a max-width of 300pxmedium
: Make the dropdown have a max-width of 500pxlarge
: Make the dropdown have a max-width of 800pxcontent
: Add padding inside the dropdown for better looking content.You may chain one class from each group to build up desired default styles. For these styles to take effect, make sure you have the default Abstractio CSS package or that you've selected dropdowns from a custom package. These should be linked up following our default HTML page structure.
We've included SCSS mixins used to style dropdowns. To use the mixin, you'll need to have the extension installed or grab _abstractio-global.scss, _global.scss and _dropdown.scss from Github and throw them into a abstractio folder in your project directory. From there, you can import the files at the top of your own SCSS stylesheet, like so:
<%= code_example ' @import "abstractio/abstractio-global", "abstractio/components/global", "abstractio/components/dropdown"; ', :css %>If you are using the mixins, you may include the styles on whatever class or ID you'd like, just make sure you follow our markup structure:
<%= code_example ' Has Dropdown ', :html %>There are two mixin you can use when building your dropdowns, the container and the list style. The container mixin will give you all the styles needed for the base styles of the dropdown, not including styles for the default link list style. The container mixin looks like this:
<%= code_example ' /* Container mixin and its options */ .your-class-name { @include dropdown-container($content, $triangle, $max-width); } /* This can be set to "list" or "content" depending on what you want inside. */ $content: list /* If you do not want to attach the triangle pop, set this to false. */ $triangle: true /* By default, the dropdown is 200px max-width, taking on 100% when gets smaller than that. */ /* You can set this to any number you want or change it globally with the variable. */ $max-width: $f-dropdown-max-width ', :css %>For content dropdowns, we don't add any extra style to the inside of the dropdown other than padding around the edges. For link lists, we wanted to predefined style that would look good out of the box and match the style of our custom select dropdowns. The style mixin looks like this:
<%= code_example ' /* The style mixin - It has no options other than variables to make global changes */ .your-class-name { @include dropdown-container($content, $triangle, $max-width); li { @include dropdown-style; } } ', :css %>Note: emCalc();
is a function we wrote to convert px
to em
. It is included in _abstractio-global.scss.
You'll need to include abstractio.joyride.js
to get plugin to work. You'll also need to make sure to include zepto.js
and abstractio.js
above the alert plugin. Above your closing </body>
tag include the following line of code and make sure you have the JS in your directory.
Read how to install Abstractio JavaScript
Required Abstractio Library: abstractio.dropdown.js
Dropdown options can only be passed in during initialization at this time.
<%= code_example " { // specify the class used for active dropdowns activeClass: 'open' }", :js %>Some text that people will think is awesome! Some text that people will think is awesome! Some text that people will think is awesome!
More test.
ButtonSome text that people will think is awesome! Some text that people will think is awesome! Some text that people will think is awesome!