Policy 1707 commit to LF
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / docs / _includes / css / helpers.html
1 <div class="bs-docs-section">
2   <h1 id="helper-classes" class="page-header">Helper classes</h1>
3
4   <h3 id="helper-classes-colors">Contextual colors</h3>
5   <p>Convey meaning through color with a handful of emphasis utility classes. These may also be applied to links and will darken on hover just like our default link styles.</p>
6   <div class="bs-example" data-example-id="contextual-colors-helpers">
7     <p class="text-muted">Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.</p>
8     <p class="text-primary">Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
9     <p class="text-success">Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</p>
10     <p class="text-info">Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
11     <p class="text-warning">Etiam porta sem malesuada magna mollis euismod.</p>
12     <p class="text-danger">Donec ullamcorper nulla non metus auctor fringilla.</p>
13   </div>
14 {% highlight html %}
15 <p class="text-muted">...</p>
16 <p class="text-primary">...</p>
17 <p class="text-success">...</p>
18 <p class="text-info">...</p>
19 <p class="text-warning">...</p>
20 <p class="text-danger">...</p>
21 {% endhighlight %}
22   <div class="bs-callout bs-callout-info" id="callout-helper-context-color-specificity">
23     <h4>Dealing with specificity</h4>
24     <p>Sometimes emphasis classes cannot be applied due to the specificity of another selector. In most cases, a sufficient workaround is to wrap your text in a <code>&lt;span&gt;</code> with the class.</p>
25   </div>
26   <div class="bs-callout bs-callout-warning" id="callout-helper-context-color-accessibility">
27     <h4>Conveying meaning to assistive technologies</h4>
28     <p>Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (the contextual colors are only used to reinforce meaning that is already present in the text/markup), or is included through alternative means, such as additional text hidden with the <code>.sr-only</code> class.</p>
29   </div>
30
31   <h3 id="helper-classes-backgrounds">Contextual backgrounds</h3>
32   <p>Similar to the contextual text color classes, easily set the background of an element to any contextual class. Anchor components will darken on hover, just like the text classes.</p>
33   <div class="bs-example bs-example-bg-classes" data-example-id="contextual-backgrounds-helpers">
34     <p class="bg-primary">Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
35     <p class="bg-success">Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</p>
36     <p class="bg-info">Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
37     <p class="bg-warning">Etiam porta sem malesuada magna mollis euismod.</p>
38     <p class="bg-danger">Donec ullamcorper nulla non metus auctor fringilla.</p>
39   </div>
40 {% highlight html %}
41 <p class="bg-primary">...</p>
42 <p class="bg-success">...</p>
43 <p class="bg-info">...</p>
44 <p class="bg-warning">...</p>
45 <p class="bg-danger">...</p>
46 {% endhighlight %}
47   <div class="bs-callout bs-callout-info" id="callout-helper-bg-specificity">
48     <h4>Dealing with specificity</h4>
49     <p>Sometimes contextual background classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element's content in a <code>&lt;div&gt;</code> with the class.</p>
50   </div>
51   <div class="bs-callout bs-callout-warning" id="callout-helper-bg-accessibility">
52     <h4>Conveying meaning to assistive technologies</h4>
53     <p>As with <a href="#helper-classes-colors">contextual colors</a>, ensure that any meaning conveyed through color is also conveyed in a format that is not purely presentational.</p>
54   </div>
55
56   <h3 id="helper-classes-close">Close icon</h3>
57   <p>Use the generic close icon for dismissing content like modals and alerts.</p>
58   <div class="bs-example" data-example-id="close-icon">
59     <p><button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button></p>
60   </div>
61 {% highlight html %}
62 <button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>
63 {% endhighlight %}
64
65
66   <h3 id="helper-classes-carets">Carets</h3>
67   <p>Use carets to indicate dropdown functionality and direction. Note that the default caret will reverse automatically in <a href="../components/#btn-dropdowns-dropup">dropup menus</a>.</p>
68   <div class="bs-example" data-example-id="caret">
69     <span class="caret"></span>
70   </div>
71 {% highlight html %}
72 <span class="caret"></span>
73 {% endhighlight %}
74
75
76   <h3 id="helper-classes-floats">Quick floats</h3>
77   <p>Float an element to the left or right with a class. <code>!important</code> is included to avoid specificity issues. Classes can also be used as mixins.</p>
78 {% highlight html %}
79 <div class="pull-left">...</div>
80 <div class="pull-right">...</div>
81 {% endhighlight %}
82 {% highlight scss %}
83 // Classes
84 .pull-left {
85   float: left !important;
86 }
87 .pull-right {
88   float: right !important;
89 }
90
91 // Usage as mixins
92 .element {
93   .pull-left();
94 }
95 .another-element {
96   .pull-right();
97 }
98 {% endhighlight %}
99
100   <div class="bs-callout bs-callout-warning" id="callout-helper-pull-navbar">
101     <h4>Not for use in navbars</h4>
102     <p>To align components in navbars with utility classes, use <code>.navbar-left</code> or <code>.navbar-right</code> instead. <a href="../components/#navbar-component-alignment">See the navbar docs</a> for details.</p>
103   </div>
104
105
106   <h3 id="helper-classes-center">Center content blocks</h3>
107   <p>Set an element to <code>display: block</code> and center via <code>margin</code>. Available as a mixin and class.</p>
108 {% highlight html %}
109 <div class="center-block">...</div>
110 {% endhighlight %}
111 {% highlight scss %}
112 // Class
113 .center-block {
114   display: block;
115   margin-left: auto;
116   margin-right: auto;
117 }
118
119 // Usage as a mixin
120 .element {
121   .center-block();
122 }
123 {% endhighlight %}
124
125
126   <h3 id="helper-classes-clearfix">Clearfix</h3>
127   <p>Easily clear <code>float</code>s by adding <code>.clearfix</code> <strong>to the parent element</strong>. Utilizes <a href="http://nicolasgallagher.com/micro-clearfix-hack/">the micro clearfix</a> as popularized by Nicolas Gallagher. Can also be used as a mixin.</p>
128 {% highlight html %}
129 <!-- Usage as a class -->
130 <div class="clearfix">...</div>
131 {% endhighlight %}
132 {% highlight scss %}
133 // Mixin itself
134 .clearfix() {
135   &:before,
136   &:after {
137     content: " ";
138     display: table;
139   }
140   &:after {
141     clear: both;
142   }
143 }
144
145 // Usage as a mixin
146 .element {
147   .clearfix();
148 }
149 {% endhighlight %}
150
151
152   <h3 id="helper-classes-show-hide">Showing and hiding content</h3>
153   <p>Force an element to be shown or hidden (<strong>including for screen readers</strong>) with the use of <code>.show</code> and <code>.hidden</code> classes. These classes use <code>!important</code> to avoid specificity conflicts, just like the <a href="#helper-classes-floats">quick floats</a>. They are only available for block level toggling. They can also be used as mixins.</p>
154   <p><code>.hide</code> is available, but it does not always affect screen readers and is <strong>deprecated</strong> as of v3.0.1. Use <code>.hidden</code> or <code>.sr-only</code> instead.</p>
155   <p>Furthermore, <code>.invisible</code> can be used to toggle only the visibility of an element, meaning its <code>display</code> is not modified and the element can still affect the flow of the document.</p>
156 {% highlight html %}
157 <div class="show">...</div>
158 <div class="hidden">...</div>
159 {% endhighlight %}
160 {% highlight scss %}
161 // Classes
162 .show {
163   display: block !important;
164 }
165 .hidden {
166   display: none !important;
167   visibility: hidden !important;
168 }
169 .invisible {
170   visibility: hidden;
171 }
172
173 // Usage as mixins
174 .element {
175   .show();
176 }
177 .another-element {
178   .hidden();
179 }
180 {% endhighlight %}
181
182
183   <h3 id="helper-classes-screen-readers">Screen reader and keyboard navigation content</h3>
184   <p>Hide an element to all devices <strong>except screen readers</strong> with <code>.sr-only</code>. Combine <code>.sr-only</code> with <code>.sr-only-focusable</code> to show the element again when it's focused (e.g. by a keyboard-only user). Necessary for following <a href="../getting-started/#accessibility">accessibility best practices</a>. Can also be used as mixins.</p>
185 {% highlight html %}
186 <a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>
187 {% endhighlight %}
188 {% highlight scss %}
189 // Usage as a mixin
190 .skip-navigation {
191   .sr-only();
192   .sr-only-focusable();
193 }
194 {% endhighlight %}
195
196
197   <h3 id="helper-classes-image-replacement">Image replacement</h3>
198   <p>Utilize the <code>.text-hide</code> class or mixin to help replace an element's text content with a background image.</p>
199 {% highlight html %}
200 <h1 class="text-hide">Custom heading</h1>
201 {% endhighlight %}
202 {% highlight scss %}
203 // Usage as a mixin
204 .heading {
205   .text-hide();
206 }
207 {% endhighlight %}
208 </div>