baz_april/squelettes/scss/utils/_mixins.scss

272 lines
6.4 KiB
SCSS
Raw Normal View History

@mixin flex-center($horizontal: true, $vertical: true) {
display: flex;
flex-direction: column;
-webkit-flex-direction: column;
@if ($vertical==true) {
justify-content: center;
}
@if ($horizontal==true) {
align-items: center;
}
}
@mixin flex() {
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Chrome */
display: flex; /* NEW, Spec - Opera 12.1, Firefox 20+ */
}
@mixin page-container() {
width: 100%;
padding-left: 1em;
padding-right: 1em;
@include media($bp-largeplus-up) {
padding-left: 0;
padding-right: 0;
margin-left: auto;
margin-right: auto;
width: em($screen-largeplus);
}
}
@mixin full_width() {
//width: 100vw;
//position: relative;
//left: 50%;
//right: 50%;
//margin-left: -50vw;
//margin-right: -50vw;
width: 100%; /* fallback for browsers that don't understand vw or calc */
width: calc(100vw - 14px); /* -15 because vw is calculated without the scrollbar being considered & 15px is width of scrollbars */
position: relative; /* use this if the parent div isn't flush left */
right: calc((100vw - 14px - 100%) / 2);
}
// des liens dans la couleur du texte courant mais avec couleur au survol
@mixin link-color-text() {
a {
color: $couleur-texte;
&:hover, &:focus {
color: $couleur-lien-hover;
}
}
}
/*
* Hide only visually, but have it available for screen readers:
* https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
*
* 1. For long content, line feeds are not interpreted as spaces and small width
* causes content to wrap 1 word per line:
* https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
*/
@mixin visuallyhidden() {
border: 0;
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
margin: 0;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
white-space: nowrap; /* 1 */
/*
* Extends the .visuallyhidden class to allow the element
* to be focusable when navigated to via the keyboard:
* https://www.drupal.org/node/897638
*/
& .focusable:active,
& .focusable:focus {
clip: auto;
clip-path: none;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
white-space: inherit;
}
}
2020-06-27 02:45:19 +02:00
@mixin clearfix() {
&:after, &:before {
display:block;
content:'';
clear:both;
}
}
2020-12-07 18:05:04 +01:00
@mixin bouton($sombre:$couleurPrincipale, $clair:#fff, $survol:$couleurSecondaire) {
2020-06-27 02:45:19 +02:00
display: inline-block;
line-height: 1.2;
border: none;
box-shadow: none;
text-align: center;
transition: background 0.3s;
cursor: pointer;
2020-12-07 16:50:11 +01:00
font-family:$typo-Merriweather;
border-radius:($spacer/4);
background:$sombre;
2020-12-07 18:05:04 +01:00
color:$clair !important;
2020-12-07 16:50:11 +01:00
font-weight:700;
padding: ($spacer/2) $spacer;
2020-06-27 02:45:19 +02:00
&:hover {
2020-12-07 16:50:11 +01:00
background-color: $survol;
2020-06-27 02:45:19 +02:00
text-decoration: none;
2020-12-07 18:05:04 +01:00
color: $clair !important;
2020-06-27 02:45:19 +02:00
}
&:focus {
2020-12-07 18:05:04 +01:00
background-color: lighten($survol,10%);
2020-06-27 02:45:19 +02:00
text-decoration: none;
2020-12-07 18:05:04 +01:00
color: $clair !important;
2020-06-27 02:45:19 +02:00
}
&[disabled=disabled] {
2020-12-07 16:50:11 +01:00
background: desaturate($clair, 45%);
color: darken($sombre, 10%) !important;
2020-06-27 02:45:19 +02:00
}
.fas {
2020-12-07 16:50:11 +01:00
padding-left:em(12px);
float:right;
2020-06-27 02:45:19 +02:00
&:before {
2020-12-07 16:50:11 +01:00
font-size:em(22px);
line-height:1;
2020-06-27 02:45:19 +02:00
font-weight:700;
2020-12-07 16:50:11 +01:00
color:$clair;
2020-06-27 02:45:19 +02:00
}
}
2020-12-07 16:50:11 +01:00
&:hover .fas:before, &:focus .fas:before {
color: $clair;
2020-06-27 02:45:19 +02:00
}
2020-12-07 16:50:11 +01:00
}
2020-06-27 02:45:19 +02:00
2020-12-07 16:50:11 +01:00
@mixin list-reset() {
list-style: none;
margin: 0;
padding: 0;
& > * {
margin: 0;
padding: 0;
}
}
@mixin list-inline() {
// supprimer les espaces blancs qui apparaissent si on utilise display: inline-block
& > * {
float: left;
& > a {
float: left;
}
}
}
@mixin list-separator($text: '|', $margin: 0.5em, $color:false) {
@include list-reset;
@include list-inline;
& > *:not(:last-child):after {
content: $text;
margin: 0 $margin;
@if $color {
color: $color;
}
}
}
@mixin text-block() {
margin-top: 0;
margin-bottom: 1em;
@include zero-bottom-margin;
}
@mixin module-block() {
margin-bottom: 1.5em;
@include zero-bottom-margin;
}
@mixin vendor-prefix($name, $value) {
@each $vendor in ('-webkit-', '-moz-', '-ms-', '-o-', '') {
#{$vendor}#{$name}: #{$value};
}
}
// supprime le margin-bottom du dernier élément
@mixin zero-bottom-margin() {
& > :last-child {
margin-bottom: 0;
}
}
@mixin media($query) {
@media screen and ($query) {
@content;
}
}
@function breakpoint($query, $dimension) {
@return $query+": "+$dimension;
}
@function em($px, $base: $body-font-size) {
@if (unitless($px)) {
$px: $px * 1px;
}
@return ($px / $base) * 1em;
}
@function pourcent($value, $total) {
@if ($value==0) {
@return 0;
}
@return ($value/$total * 100)*1%;
}
@function strip-unit($number) {
@if type-of($number) == 'number' and not unitless($number) {
@return $number / ($number * 0 + 1);
}
@return $number;
}
2020-10-07 19:03:07 +02:00
@mixin rotate ($deg) {
-webkit-transform: rotate($deg);
-moz-transform: rotate($deg);
-ms-transform: rotate($deg);
-o-transform: rotate($deg);
}
2020-12-16 09:08:52 +01:00
@mixin gradient-4 ($couleur1: #004050,$couleur2: $couleurConnex 7.5%,$couleur3: $couleurConnex 92.5%,$couleur4: #004050) {
background: -webkit-linear-gradient($couleur1,$couleur2,$couleur3,$couleur4);
background: -moz-linear-gradient($couleur1,$couleur2,$couleur3,$couleur4);
background: -ms-linear-gradient($couleur1,$couleur2,$couleur3,$couleur4);
background: -o-linear-gradient($couleur1,$couleur2,$couleur3,$couleur4);
}
2020-10-07 19:03:07 +02:00
/// Font Face
/// https://gist.github.com/jonathantneal/d0460e5c2d5d7f9bc5e6#file-_mixins-scss
/// simplification pour uniquement woff2 et woff
@mixin font-face($name, $path, $weight: null, $style: null, $exts: woff2 woff) {
$src: null;
@each $ext in $exts {
$src: append($src, url(quote("../webfonts/" + $path + "." + $ext)) format(quote($ext)), comma);
}
@font-face {
font-family: quote($name);
font-style: $style;
font-weight: $weight;
src: $src;
}
}