_visibility.scss 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. // Foundation by ZURB
  2. // foundation.zurb.com
  3. // Licensed under MIT Open Source
  4. @import 'global';
  5. //
  6. // Foundation Visibility Classes
  7. //
  8. $include-html-visibility-classes: $include-html-classes !default;
  9. $include-accessibility-classes: true !default;
  10. $include-table-visibility-classes: true !default;
  11. $include-legacy-visibility-classes: true !default;
  12. //
  13. // Media Class Names
  14. //
  15. // Visibility Breakpoints
  16. $visibility-breakpoint-sizes:
  17. small,
  18. medium,
  19. large,
  20. xlarge,
  21. xxlarge;
  22. $visibility-breakpoint-queries:
  23. unquote($small-up),
  24. unquote($medium-up),
  25. unquote($large-up),
  26. unquote($xlarge-up),
  27. unquote($xxlarge-up);
  28. @mixin visibility-loop {
  29. @each $current-visibility-breakpoint in $visibility-breakpoint-sizes {
  30. $visibility-inherit-list: ();
  31. $visibility-none-list: ();
  32. $visibility-visible-list: ();
  33. $visibility-hidden-list: ();
  34. $visibility-table-list: ();
  35. $visibility-table-header-group-list: ();
  36. $visibility-table-row-group-list: ();
  37. $visibility-table-row-list: ();
  38. $visibility-table-cell-list: ();
  39. @each $visibility-comparison-breakpoint in $visibility-breakpoint-sizes {
  40. @if index($visibility-breakpoint-sizes, $visibility-comparison-breakpoint) < index($visibility-breakpoint-sizes, $current-visibility-breakpoint) {
  41. // Smaller than current breakpoint
  42. $visibility-inherit-list: append($visibility-inherit-list, unquote(
  43. '.hide-for-#{$visibility-comparison-breakpoint}-only, .show-for-#{$visibility-comparison-breakpoint}-up'
  44. ), comma);
  45. $visibility-none-list: append($visibility-none-list, unquote(
  46. '.show-for-#{$visibility-comparison-breakpoint}-only, .hide-for-#{$visibility-comparison-breakpoint}-up'
  47. ), comma);
  48. $visibility-visible-list: append($visibility-visible-list, unquote(
  49. '.hidden-for-#{$visibility-comparison-breakpoint}-only, .visible-for-#{$visibility-comparison-breakpoint}-up'
  50. ), comma);
  51. $visibility-hidden-list: append($visibility-hidden-list, unquote(
  52. '.visible-for-#{$visibility-comparison-breakpoint}-only, .hidden-for-#{$visibility-comparison-breakpoint}-up'
  53. ), comma);
  54. $visibility-table-list: append($visibility-table-list, unquote(
  55. 'table.hide-for-#{$visibility-comparison-breakpoint}-only, table.show-for-#{$visibility-comparison-breakpoint}-up'
  56. ), comma);
  57. $visibility-table-header-group-list: append($visibility-table-header-group-list, unquote(
  58. 'thead.hide-for-#{$visibility-comparison-breakpoint}-only, thead.show-for-#{$visibility-comparison-breakpoint}-up'
  59. ), comma);
  60. $visibility-table-row-group-list: append($visibility-table-row-group-list, unquote(
  61. 'tbody.hide-for-#{$visibility-comparison-breakpoint}-only, tbody.show-for-#{$visibility-comparison-breakpoint}-up'
  62. ), comma);
  63. $visibility-table-row-list: append($visibility-table-row-list, unquote(
  64. 'tr.hide-for-#{$visibility-comparison-breakpoint}-only, tr.show-for-#{$visibility-comparison-breakpoint}-up'
  65. ), comma);
  66. $visibility-table-cell-list: append($visibility-table-cell-list, unquote(
  67. 'th.hide-for-#{$visibility-comparison-breakpoint}-only, td.hide-for-#{$visibility-comparison-breakpoint}-only, th.show-for-#{$visibility-comparison-breakpoint}-up, td.show-for-#{$visibility-comparison-breakpoint}-up'
  68. ), comma);
  69. // Foundation 4 compatibility:
  70. // Include .show/hide-for-[size] and .show/hide-for-[size]-down classes
  71. // for small, medium, and large breakpoints only
  72. @if $include-legacy-visibility-classes and index((small, medium, large), $visibility-comparison-breakpoint) != false {
  73. $visibility-inherit-list: append($visibility-inherit-list, unquote(
  74. '.hide-for-#{$visibility-comparison-breakpoint}, .hide-for-#{$visibility-comparison-breakpoint}-down'
  75. ), comma);
  76. $visibility-none-list: append($visibility-none-list, unquote(
  77. '.show-for-#{$visibility-comparison-breakpoint}, .show-for-#{$visibility-comparison-breakpoint}-down'
  78. ), comma);
  79. $visibility-visible-list: append($visibility-visible-list, unquote(
  80. '.hidden-for-#{$visibility-comparison-breakpoint}, .hidden-for-#{$visibility-comparison-breakpoint}-down'
  81. ), comma);
  82. $visibility-hidden-list: append($visibility-hidden-list, unquote(
  83. '.visible-for-#{$visibility-comparison-breakpoint}, .visible-for-#{$visibility-comparison-breakpoint}-down'
  84. ), comma);
  85. $visibility-table-list: append($visibility-table-list, unquote(
  86. 'table.hide-for-#{$visibility-comparison-breakpoint}, table.hide-for-#{$visibility-comparison-breakpoint}-down'
  87. ), comma);
  88. $visibility-table-header-group-list: append($visibility-table-header-group-list, unquote(
  89. 'thead.hide-for-#{$visibility-comparison-breakpoint}, thead.hide-for-#{$visibility-comparison-breakpoint}-down'
  90. ), comma);
  91. $visibility-table-row-group-list: append($visibility-table-row-group-list, unquote(
  92. 'tbody.hide-for-#{$visibility-comparison-breakpoint}, tbody.hide-for-#{$visibility-comparison-breakpoint}-down'
  93. ), comma);
  94. $visibility-table-row-list: append($visibility-table-row-list, unquote(
  95. 'tr.hide-for-#{$visibility-comparison-breakpoint}, tr.hide-for-#{$visibility-comparison-breakpoint}-down'
  96. ), comma);
  97. $visibility-table-cell-list: append($visibility-table-cell-list, unquote(
  98. 'th.hide-for-#{$visibility-comparison-breakpoint}, td.hide-for-#{$visibility-comparison-breakpoint}, th.hide-for-#{$visibility-comparison-breakpoint}-down, td.hide-for-#{$visibility-comparison-breakpoint}-down'
  99. ), comma);
  100. }
  101. } @else if index($visibility-breakpoint-sizes, $visibility-comparison-breakpoint) > index($visibility-breakpoint-sizes, $current-visibility-breakpoint) {
  102. // Larger than current breakpoint
  103. $visibility-inherit-list: append($visibility-inherit-list, unquote(
  104. '.hide-for-#{$visibility-comparison-breakpoint}-only, .hide-for-#{$visibility-comparison-breakpoint}-up'
  105. ), comma);
  106. $visibility-none-list: append($visibility-none-list, unquote(
  107. '.show-for-#{$visibility-comparison-breakpoint}-only, .show-for-#{$visibility-comparison-breakpoint}-up'
  108. ), comma);
  109. $visibility-visible-list: append($visibility-visible-list, unquote(
  110. '.hidden-for-#{$visibility-comparison-breakpoint}-only, .hidden-for-#{$visibility-comparison-breakpoint}-up'
  111. ), comma);
  112. $visibility-hidden-list: append($visibility-hidden-list, unquote(
  113. '.visible-for-#{$visibility-comparison-breakpoint}-only, .visible-for-#{$visibility-comparison-breakpoint}-up'
  114. ), comma);
  115. $visibility-table-list: append($visibility-table-list, unquote(
  116. 'table.hide-for-#{$visibility-comparison-breakpoint}-only, table.hide-for-#{$visibility-comparison-breakpoint}-up'
  117. ), comma);
  118. $visibility-table-header-group-list: append($visibility-table-header-group-list, unquote(
  119. 'thead.hide-for-#{$visibility-comparison-breakpoint}-only, thead.hide-for-#{$visibility-comparison-breakpoint}-up'
  120. ), comma);
  121. $visibility-table-row-group-list: append($visibility-table-row-group-list, unquote(
  122. 'tbody.hide-for-#{$visibility-comparison-breakpoint}-only, tbody.hide-for-#{$visibility-comparison-breakpoint}-up'
  123. ), comma);
  124. $visibility-table-row-list: append($visibility-table-row-list, unquote(
  125. 'tr.hide-for-#{$visibility-comparison-breakpoint}-only, tr.hide-for-#{$visibility-comparison-breakpoint}-up'
  126. ), comma);
  127. $visibility-table-cell-list: append($visibility-table-cell-list, unquote(
  128. 'th.hide-for-#{$visibility-comparison-breakpoint}-only, td.hide-for-#{$visibility-comparison-breakpoint}-only, th.hide-for-#{$visibility-comparison-breakpoint}-up, td.hide-for-#{$visibility-comparison-breakpoint}-up'
  129. ), comma);
  130. // Foundation 4 compatibility:
  131. // Include .show/hide-for-[size] and .show/hide-for-[size]-down classes
  132. // for small, medium, and large breakpoints only
  133. @if $include-legacy-visibility-classes and index((small, medium, large), $visibility-comparison-breakpoint) != false {
  134. $visibility-inherit-list: append($visibility-inherit-list, unquote(
  135. '.hide-for-#{$visibility-comparison-breakpoint}, .show-for-#{$visibility-comparison-breakpoint}-down'
  136. ), comma);
  137. $visibility-none-list: append($visibility-none-list, unquote(
  138. '.show-for-#{$visibility-comparison-breakpoint}, .hide-for-#{$visibility-comparison-breakpoint}-down'
  139. ), comma);
  140. $visibility-visible-list: append($visibility-visible-list, unquote(
  141. '.hidden-for-#{$visibility-comparison-breakpoint}, .visible-for-#{$visibility-comparison-breakpoint}-down'
  142. ), comma);
  143. $visibility-hidden-list: append($visibility-hidden-list, unquote(
  144. '.visible-for-#{$visibility-comparison-breakpoint}, .hidden-for-#{$visibility-comparison-breakpoint}-down'
  145. ), comma);
  146. $visibility-table-list: append($visibility-table-list, unquote(
  147. 'table.hide-for-#{$visibility-comparison-breakpoint}, table.show-for-#{$visibility-comparison-breakpoint}-down'
  148. ), comma);
  149. $visibility-table-header-group-list: append($visibility-table-header-group-list, unquote(
  150. 'thead.hide-for-#{$visibility-comparison-breakpoint}, thead.show-for-#{$visibility-comparison-breakpoint}-down'
  151. ), comma);
  152. $visibility-table-row-group-list: append($visibility-table-row-group-list, unquote(
  153. 'tbody.hide-for-#{$visibility-comparison-breakpoint}, tbody.show-for-#{$visibility-comparison-breakpoint}-down'
  154. ), comma);
  155. $visibility-table-row-list: append($visibility-table-row-list, unquote(
  156. 'tr.hide-for-#{$visibility-comparison-breakpoint}, tr.show-for-#{$visibility-comparison-breakpoint}-down'
  157. ), comma);
  158. $visibility-table-cell-list: append($visibility-table-cell-list, unquote(
  159. 'th.hide-for-#{$visibility-comparison-breakpoint}, td.hide-for-#{$visibility-comparison-breakpoint}, th.show-for-#{$visibility-comparison-breakpoint}-down, td.show-for-#{$visibility-comparison-breakpoint}-down'
  160. ), comma);
  161. }
  162. } @else {
  163. // Current breakpoint
  164. $visibility-inherit-list: append($visibility-inherit-list, unquote(
  165. '.show-for-#{$visibility-comparison-breakpoint}-only, .show-for-#{$visibility-comparison-breakpoint}-up'
  166. ), comma);
  167. $visibility-none-list: append($visibility-none-list, unquote(
  168. '.hide-for-#{$visibility-comparison-breakpoint}-only, .hide-for-#{$visibility-comparison-breakpoint}-up'
  169. ), comma);
  170. $visibility-visible-list: append($visibility-visible-list, unquote(
  171. '.visible-for-#{$visibility-comparison-breakpoint}-only, .visible-for-#{$visibility-comparison-breakpoint}-up'
  172. ), comma);
  173. $visibility-hidden-list: append($visibility-hidden-list, unquote(
  174. '.hidden-for-#{$visibility-comparison-breakpoint}-only, .hidden-for-#{$visibility-comparison-breakpoint}-up'
  175. ), comma);
  176. $visibility-table-list: append($visibility-table-list, unquote(
  177. 'table.show-for-#{$visibility-comparison-breakpoint}-only, table.show-for-#{$visibility-comparison-breakpoint}-up'
  178. ), comma);
  179. $visibility-table-header-group-list: append($visibility-table-header-group-list, unquote(
  180. 'thead.show-for-#{$visibility-comparison-breakpoint}-only, thead.show-for-#{$visibility-comparison-breakpoint}-up'
  181. ), comma);
  182. $visibility-table-row-group-list: append($visibility-table-row-group-list, unquote(
  183. 'tbody.show-for-#{$visibility-comparison-breakpoint}-only, tbody.show-for-#{$visibility-comparison-breakpoint}-up'
  184. ), comma);
  185. $visibility-table-row-list: append($visibility-table-row-list, unquote(
  186. 'tr.show-for-#{$visibility-comparison-breakpoint}-only, tr.show-for-#{$visibility-comparison-breakpoint}-up'
  187. ), comma);
  188. $visibility-table-cell-list: append($visibility-table-cell-list, unquote(
  189. 'th.show-for-#{$visibility-comparison-breakpoint}-only, td.show-for-#{$visibility-comparison-breakpoint}-only, th.show-for-#{$visibility-comparison-breakpoint}-up, td.show-for-#{$visibility-comparison-breakpoint}-up'
  190. ), comma);
  191. // Foundation 4 compatibility:
  192. // Include .show/hide-for-[size] and .show/hide-for-[size]-down classes
  193. // for small, medium, and large breakpoints only
  194. @if $include-legacy-visibility-classes and index((small, medium, large), $visibility-comparison-breakpoint) != false {
  195. $visibility-inherit-list: append($visibility-inherit-list, unquote(
  196. '.show-for-#{$visibility-comparison-breakpoint}, .show-for-#{$visibility-comparison-breakpoint}-down'
  197. ), comma);
  198. $visibility-none-list: append($visibility-none-list, unquote(
  199. '.hide-for-#{$visibility-comparison-breakpoint}, .hide-for-#{$visibility-comparison-breakpoint}-down'
  200. ), comma);
  201. $visibility-visible-list: append($visibility-visible-list, unquote(
  202. '.visible-for-#{$visibility-comparison-breakpoint}, .visible-for-#{$visibility-comparison-breakpoint}-down'
  203. ), comma);
  204. $visibility-hidden-list: append($visibility-hidden-list, unquote(
  205. '.hidden-for-#{$visibility-comparison-breakpoint}, .hidden-for-#{$visibility-comparison-breakpoint}-down'
  206. ), comma);
  207. $visibility-table-list: append($visibility-table-list, unquote(
  208. 'table.show-for-#{$visibility-comparison-breakpoint}, table.show-for-#{$visibility-comparison-breakpoint}-down'
  209. ), comma);
  210. $visibility-table-header-group-list: append($visibility-table-header-group-list, unquote(
  211. 'thead.show-for-#{$visibility-comparison-breakpoint}, thead.show-for-#{$visibility-comparison-breakpoint}-down'
  212. ), comma);
  213. $visibility-table-row-group-list: append($visibility-table-row-group-list, unquote(
  214. 'tbody.show-for-#{$visibility-comparison-breakpoint}, tbody.show-for-#{$visibility-comparison-breakpoint}-down'
  215. ), comma);
  216. $visibility-table-row-list: append($visibility-table-row-list, unquote(
  217. 'tr.show-for-#{$visibility-comparison-breakpoint}, tr.show-for-#{$visibility-comparison-breakpoint}-down'
  218. ), comma);
  219. $visibility-table-cell-list: append($visibility-table-cell-list, unquote(
  220. 'th.show-for-#{$visibility-comparison-breakpoint}, td.show-for-#{$visibility-comparison-breakpoint}, th.show-for-#{$visibility-comparison-breakpoint}-down, td.show-for-#{$visibility-comparison-breakpoint}-down'
  221. ), comma);
  222. }
  223. }
  224. }
  225. /* #{$current-visibility-breakpoint} displays */
  226. @media #{nth($visibility-breakpoint-queries, index($visibility-breakpoint-sizes, $current-visibility-breakpoint))} {
  227. #{$visibility-inherit-list} {
  228. display: inherit !important;
  229. }
  230. #{$visibility-none-list} {
  231. display: none !important;
  232. }
  233. @if $include-accessibility-classes != false {
  234. #{$visibility-visible-list} {
  235. @include element-invisible-off;
  236. }
  237. #{$visibility-hidden-list} {
  238. @include element-invisible;
  239. }
  240. }
  241. @if $include-table-visibility-classes != false {
  242. #{$visibility-table-list} {
  243. display: table !important;
  244. }
  245. #{$visibility-table-header-group-list} {
  246. display: table-header-group !important;
  247. }
  248. #{$visibility-table-row-group-list} {
  249. display: table-row-group !important;
  250. }
  251. #{$visibility-table-row-list} {
  252. display: table-row;
  253. }
  254. #{$visibility-table-cell-list} {
  255. display: table-cell !important;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. @include exports("visibility"){
  262. @if $include-html-visibility-classes != false {
  263. @include visibility-loop;
  264. /* Orientation targeting */
  265. .show-for-landscape,
  266. .hide-for-portrait { display: inherit !important; }
  267. .hide-for-landscape,
  268. .show-for-portrait { display: none !important; }
  269. /* Specific visibility for tables */
  270. table {
  271. &.hide-for-landscape,
  272. &.show-for-portrait { display: table !important; }
  273. }
  274. thead {
  275. &.hide-for-landscape,
  276. &.show-for-portrait { display: table-header-group !important; }
  277. }
  278. tbody {
  279. &.hide-for-landscape,
  280. &.show-for-portrait { display: table-row-group !important; }
  281. }
  282. tr {
  283. &.hide-for-landscape,
  284. &.show-for-portrait { display: table-row !important; }
  285. }
  286. td,
  287. th {
  288. &.hide-for-landscape,
  289. &.show-for-portrait { display: table-cell !important; }
  290. }
  291. @media #{$landscape} {
  292. .show-for-landscape,
  293. .hide-for-portrait { display: inherit !important; }
  294. .hide-for-landscape,
  295. .show-for-portrait { display: none !important; }
  296. /* Specific visibility for tables */
  297. table {
  298. &.show-for-landscape,
  299. &.hide-for-portrait { display: table !important; }
  300. }
  301. thead {
  302. &.show-for-landscape,
  303. &.hide-for-portrait { display: table-header-group !important; }
  304. }
  305. tbody {
  306. &.show-for-landscape,
  307. &.hide-for-portrait { display: table-row-group !important; }
  308. }
  309. tr {
  310. &.show-for-landscape,
  311. &.hide-for-portrait { display: table-row !important; }
  312. }
  313. td,
  314. th {
  315. &.show-for-landscape,
  316. &.hide-for-portrait { display: table-cell !important; }
  317. }
  318. }
  319. @media #{$portrait} {
  320. .show-for-portrait,
  321. .hide-for-landscape { display: inherit !important; }
  322. .hide-for-portrait,
  323. .show-for-landscape { display: none !important; }
  324. /* Specific visibility for tables */
  325. table {
  326. &.show-for-portrait,
  327. &.hide-for-landscape { display: table !important; }
  328. }
  329. thead {
  330. &.show-for-portrait,
  331. &.hide-for-landscape { display: table-header-group !important; }
  332. }
  333. tbody {
  334. &.show-for-portrait,
  335. &.hide-for-landscape { display: table-row-group !important; }
  336. }
  337. tr {
  338. &.show-for-portrait,
  339. &.hide-for-landscape { display: table-row !important; }
  340. }
  341. td,
  342. th {
  343. &.show-for-portrait,
  344. &.hide-for-landscape { display: table-cell !important; }
  345. }
  346. }
  347. /* Touch-enabled device targeting */
  348. .show-for-touch { display: none !important; }
  349. .hide-for-touch { display: inherit !important; }
  350. .touch .show-for-touch { display: inherit !important; }
  351. .touch .hide-for-touch { display: none !important; }
  352. /* Specific visibility for tables */
  353. table.hide-for-touch { display: table !important; }
  354. .touch table.show-for-touch { display: table !important; }
  355. thead.hide-for-touch { display: table-header-group !important; }
  356. .touch thead.show-for-touch { display: table-header-group !important; }
  357. tbody.hide-for-touch { display: table-row-group !important; }
  358. .touch tbody.show-for-touch { display: table-row-group !important; }
  359. tr.hide-for-touch { display: table-row !important; }
  360. .touch tr.show-for-touch { display: table-row !important; }
  361. td.hide-for-touch { display: table-cell !important; }
  362. .touch td.show-for-touch { display: table-cell !important; }
  363. th.hide-for-touch { display: table-cell !important; }
  364. .touch th.show-for-touch { display: table-cell !important; }
  365. /* Screen reader-specific classes */
  366. .show-for-sr {
  367. @include element-invisible;
  368. }
  369. .show-on-focus {
  370. @include element-invisible;
  371. &:focus,
  372. &:active {
  373. @include element-invisible-off;
  374. }
  375. }
  376. /* Print visibility */
  377. @if $include-print-styles {
  378. .print-only,
  379. .show-for-print { display: none !important; }
  380. @media print {
  381. .print-only,
  382. .show-for-print { display: block !important; }
  383. .hide-on-print,
  384. .hide-for-print { display: none !important; }
  385. table.show-for-print { display: table !important; }
  386. thead.show-for-print { display: table-header-group !important; }
  387. tbody.show-for-print { display: table-row-group !important; }
  388. tr.show-for-print { display: table-row !important; }
  389. td.show-for-print { display: table-cell !important; }
  390. th.show-for-print { display: table-cell !important; }
  391. }
  392. }
  393. }
  394. }