summaryrefslogtreecommitdiff
path: root/addons/web/static/src/scss/utils.scss
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2018-03-12 16:24:31 +0100
committerqsm-odoo <qsm@odoo.com>2018-04-18 15:59:19 +0200
commit6e4db7d13a926845bf82f5b035afede42d6d5a89 (patch)
treea9804dbe2b2844faff9359560102d222d0e37654 /addons/web/static/src/scss/utils.scss
parentfbfd0119041ca7dc830796e76d9ae5c303459d4f (diff)
[REF] *: review scss variables handling
Unlike LESS, SCSS variables are not lazy loaded. Our system has thus to be updated. This commit creates new templates which are t-called in assets bundles (to replace the old less_helpers template): - web._assets_utils: regroups the mixins and functions which *can* (and so should) be available in every asset bundle - web._assets_primary_variables: regroups the variables (or mixins used as variables) which *can* (and so should) be available in every asset bundle - web._assets_secondary_variables: same as above but provides an environnement where all the 'primary' ones are accessible. This is for example useful to handle the community/enterprise split: // Community primary variables $o-pink-color: pink; // enterprise color $o-brand-primary: blue; // Enterprise primary variables $o-brand-primary: $o-pink-color; // Community secondary variables $o-my-darker-primary: darken($o-brand-primary, 5%); => If there was only one variable template, enterprise edition would have been able to define its primary color at the end but the darker primary would not have been updated. Using the "!default" system and putting enterprise definition above would not have solved the problem as the $o-pink-color would not have been accessible. - web._assets_backend_helpers: regroups the variables, mixins and functions which *can* (and so should) be available in the backend asset bundle only. This is especially (only?) useful for bootstrap variables overriddes. - web._assets_frontend_helpers: regroups the variables, mixins and functions which *can* (and so should) be available in the frontend asset bundle only. This is especially (only?) useful for bootstrap variables overriddes. Note: bootstrap variables are not accessible in any of those anymore. If you have variables that should depend on bootstrap, you have 3 solutions: - Find another way: your variable is probably useless, use bootstrap variables directly or create a variable that will influence the value of bootstrap variables. E.g. instead of declaring: `$myvar: $bootstrapvar * 3` and using $myvar alone, declare: `$myvar: 3` and use `$myvar * $bootstrapvar` where needed. - Declare a copy of the bootstrap variable and use that one. In that case, you should also force-set the real bootstrap one to be sure they match (this should be done in appropriate templates mentioned above). E.g. ``` $o-boostrapvar: 5; ... $boostrapvar: $o-bootstrapvar; ``` - Set your variable to null and set it to your bootstrap expression in the file you will need it (where bootstrap variables are accessible) without forgetting to add the !default flag to allow overriddes. ``` $myvar: null; ... $myvar: $bootstrapvar * 5 !default; ``` This commit also partly changes the variable names to follow the convention: $o-<app_id>-<name> where 'app_id' is the current's app name or a meaningful unique identifier ("theme" for all themes for example, as no multiple themes can be installed).
Diffstat (limited to 'addons/web/static/src/scss/utils.scss')
-rw-r--r--addons/web/static/src/scss/utils.scss322
1 files changed, 247 insertions, 75 deletions
diff --git a/addons/web/static/src/scss/utils.scss b/addons/web/static/src/scss/utils.scss
index 6db15976bd5..f64d50fd240 100644
--- a/addons/web/static/src/scss/utils.scss
+++ b/addons/web/static/src/scss/utils.scss
@@ -3,16 +3,6 @@
///
// ------------------------------------------------------------------
-// Padding
-// ------------------------------------------------------------------
-@mixin o-webclient-padding($top: 0px, $right: $odoo-horizontal-padding, $bottom: 0px, $left: $odoo-horizontal-padding) {
- padding-top: $top;
- padding-right: $right;
- padding-bottom: $bottom;
- padding-left: $left;
-}
-
-// ------------------------------------------------------------------
// Caret
// ------------------------------------------------------------------
@mixin utils-caret-boilerplate {
@@ -22,38 +12,6 @@
height: 0;
vertical-align: middle;
}
-@mixin o-caret-down($caret-width: $caret-width-base) {
- @include utils-caret-boilerplate;
- border-bottom: 0;
- border-left: $caret-width solid transparent;
- border-right: $caret-width solid transparent;
- border-top: $caret-width solid;
- -moz-transform: scale(0.9999); // Smooth the caret on firefox
-}
-@mixin o-caret-up($caret-width: $caret-width-base) {
- @include utils-caret-boilerplate;
- border-bottom: $caret-width solid;
- border-left: $caret-width solid transparent;
- border-right: $caret-width solid transparent;
- border-top: 0;
- -moz-transform: scale(0.9999); // Smooth the caret on firefox
-}
-@mixin o-caret-left($caret-width: $caret-width-base) {
- @include utils-caret-boilerplate;
- border-bottom: $caret-width solid transparent;
- border-left: 0;
- border-right: $caret-width solid;
- border-top: $caret-width solid transparent;
- -moz-transform: scale(0.9999); // Smooth the caret on firefox
-}
-@mixin o-caret-right($caret-width: $caret-width-base) {
- @include utils-caret-boilerplate;
- border-bottom: $caret-width solid transparent;
- border-left: $caret-width solid;
- border-right: 0;
- border-top: $caret-width solid transparent;
- -moz-transform: scale(0.9999); // Smooth the caret on firefox
-}
// ------------------------------------------------------------------
// Vendor prefixes
@@ -121,33 +79,6 @@
}
// ------------------------------------------------------------------
-// Dropdowns
-// ------------------------------------------------------------------
-@mixin o-selected-li {
- li {
- position: relative;
- > a {
- color: $odoo-main-text-color;
- &:hover {
- color: darken($odoo-main-text-color, 10%);
- }
- }
- &.selected {
- > a {
- color: darken($odoo-main-text-color, 10%);
- font-weight: bold;
- &:before {
- font-family: FontAwesome;
- position: absolute;
- left: 6px;
- content: "\f00c";
- }
- }
- }
- }
-}
-
-// ------------------------------------------------------------------
// Select Appearance
// ------------------------------------------------------------------
@mixin o-appearance($value) {
@@ -265,6 +196,95 @@
opacity: $hover-opacity;
}
}
+
+//------------------------------------------------------------------------------
+// Colors
+//------------------------------------------------------------------------------
+
+@function luma($color) {
+ @return ((red($color) * .299) + (green($color) * .587) + (blue($color) * .114)) / 255 * 100%;
+}
+@function o-get-most-contrast($color, $c1, $c2) {
+ $luma: luma($color);
+ @return if(abs($luma - luma($c1)) > abs($luma - luma($c2)), $c1, $c2);
+}
+
+// ------------------------------------------------------------------
+// Padding
+// ------------------------------------------------------------------
+@mixin o-webclient-padding($top: 0px, $right: $o-horizontal-padding, $bottom: 0px, $left: $o-horizontal-padding) {
+ padding-top: $top;
+ padding-right: $right;
+ padding-bottom: $bottom;
+ padding-left: $left;
+}
+
+// ------------------------------------------------------------------
+// Caret
+// ------------------------------------------------------------------
+@mixin o-caret-down($caret-width: $caret-width-base) {
+ @include utils-caret-boilerplate;
+ border-bottom: 0;
+ border-left: $caret-width solid transparent;
+ border-right: $caret-width solid transparent;
+ border-top: $caret-width solid;
+ -moz-transform: scale(0.9999); // Smooth the caret on firefox
+}
+@mixin o-caret-up($caret-width: $caret-width-base) {
+ @include utils-caret-boilerplate;
+ border-bottom: $caret-width solid;
+ border-left: $caret-width solid transparent;
+ border-right: $caret-width solid transparent;
+ border-top: 0;
+ -moz-transform: scale(0.9999); // Smooth the caret on firefox
+}
+@mixin o-caret-left($caret-width: $caret-width-base) {
+ @include utils-caret-boilerplate;
+ border-bottom: $caret-width solid transparent;
+ border-left: 0;
+ border-right: $caret-width solid;
+ border-top: $caret-width solid transparent;
+ -moz-transform: scale(0.9999); // Smooth the caret on firefox
+}
+@mixin o-caret-right($caret-width: $caret-width-base) {
+ @include utils-caret-boilerplate;
+ border-bottom: $caret-width solid transparent;
+ border-left: $caret-width solid;
+ border-right: 0;
+ border-top: $caret-width solid transparent;
+ -moz-transform: scale(0.9999); // Smooth the caret on firefox
+}
+
+// ------------------------------------------------------------------
+// Dropdowns
+// ------------------------------------------------------------------
+@mixin o-selected-li {
+ li {
+ position: relative;
+ > a {
+ color: $o-main-text-color;
+ &:hover {
+ color: darken($o-main-text-color, 10%);
+ }
+ }
+ &.selected {
+ > a {
+ color: darken($o-main-text-color, 10%);
+ font-weight: bold;
+ &:before {
+ font-family: FontAwesome;
+ position: absolute;
+ left: 6px;
+ content: "\f00c";
+ }
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------
+// Hovering effects
+// ------------------------------------------------------------------
@mixin o-hover-text-color($default-color: $text-color, $hover-color: $link-color) {
color: $default-color;
@@ -273,11 +293,163 @@
}
}
-//------------------------------------------------------------------------------
-// Colors
-//------------------------------------------------------------------------------
+// ------------------------------------------------------------------
+// Mixin to define variations for btn-links and muted btn-links
+// ------------------------------------------------------------------
+@mixin o-btn-link-variant($color, $color-active) {
+ text-transform: none;
+ @include o-hover-text-color($default-color: $color, $hover-color: $color-active);
-@function o-get-most-contrast($color, $c1, $c2) {
- $brightness: brightness($color);
- @return if(abs($brightness - brightness($c1)) > abs($brightness - brightness($c2)), $c1, $c2);
+ &, &:hover, &:focus, &:active, &.active {
+ border-color: transparent;
+ background-color: transparent
+ }
+
+ &.text-muted, .text-muted {
+ @include o-hover-opacity;
+ @include o-hover-text-color($default-color: $text-muted, $hover-color: $color-active);
+ }
+}
+
+// ------- Kanban grouped mixins -------
+@mixin o-kanban-icon($base-opacity: 0.5) {
+ display: block;
+ text-align: center;
+ color: $o-main-text-color;
+ font-size: $font-size-small;
+ cursor: pointer;
+ @include o-hover-opacity($base-opacity);
+}
+@mixin o-kanban-tag-color {
+ @for $size from 1 through length($o-colors) {
+ // Note: the first color is supposed to be invisible if there is a color
+ // field but it is used as a default color when there is no color field
+ &.o_tag_color_#{$size - 1} span {
+ background-color: nth($o-colors, $size);
+ }
+ }
+}
+@mixin o-kanban-record-color {
+ @for $size from 2 through length($o-colors) {
+ // Note: the first color is not defined as it is the 'no color' for kanban
+ .oe_kanban_color_#{$size - 1}::after {
+ background-color: nth($o-colors, $size);
+ }
+ }
+}
+@mixin o-kanban-slim-col {
+ position: relative;
+ @include o-flex(0, 0, auto);
+ margin: 0;
+ padding: 0 floor($o-kanban-group-padding * 0.7);
+ cursor: pointer;
+}
+@mixin o-kanban-header-title {
+ @include o-flex-display;
+ @include o-align-items(center);
+ height: $o-kanban-header-title-height;
+ line-height: 2.2;
+ color: $headings-color;
+}
+@mixin o-kanban-v-title {
+ @include o-position-absolute($o-kanban-inside-vgutter * 2, $left: floor(-$o-kanban-inside-vgutter * 1.2));
+ @include o-transform-origin(left, bottom, $z: 0);
+ @include o-transform(rotate(90deg));
+ overflow: visible;
+ white-space: nowrap;
+ font-size: 15px;
+}
+
+// ------- Kanban records mixins -------
+@mixin o-kanban-record-title($font-size) {
+ color: $headings-color;
+ font-size: $font-size;
+ font-weight: 500;
+ margin-bottom: 0;
+ margin-top: 0;
+}
+@mixin o-kanban-dropdown($padding-base: $o-kanban-inside-vgutter) {
+ margin: -1px -1px auto auto; // compensate border
+ padding: $padding-base/2 $padding-base;
+ border: 1px solid transparent;
+ border-bottom: none;
+ vertical-align: top;
+ color: $text-color;
+
+ &:hover {
+ color: $headings-color;
+ }
+ &:focus, &:active, &:focus:active {
+ outline: none;
+ }
+}
+@mixin o-kanban-dropdown-open {
+ position: relative;
+ background: white;
+ border-color: $gray-lighter-darker;
+ z-index: $zindex-dropdown + 1;
+}
+@mixin o-kanban-dropdown-menu {
+ @include o-position-absolute($right: -1px);
+ margin-top: -1px;
+ border-color: $gray-lighter-darker;
+}
+@mixin o-kanban-colorpicker {
+ max-width: 150px;
+ padding: 3px ($o-dropdown-hpadding - $o-kanban-inner-hmargin) 3px $o-dropdown-hpadding;
+
+ > li {
+ display: inline-block;
+ margin: $o-kanban-inner-hmargin $o-kanban-inner-hmargin 0 0;
+ border: 1px solid white;
+ box-shadow: 0 0 0 1px $gray-lighter-dark;
+
+ > a {
+ display: block;
+
+ &::after {
+ content: "";
+ display: block;
+ width: 20px;
+ height: 15px;
+ }
+ }
+
+ // No Color
+ &:first-child > a {
+ position: relative;
+ &::before {
+ content: "";
+ @include o-position-absolute(-2px, $left: 10px);
+ display: block;
+ width: 1px;
+ height: 20px;
+ @include rotate(45deg);
+ background-color: red;
+ }
+ &::after {
+ background-color: white;
+ }
+ }
+ }
+}
+
+// Emulate dropdown links
+@mixin o-kanban-dashboard-dropdown-link($link-padding-gap: $o-dropdown-hpadding) {
+ padding: 0;
+
+ > a {
+ margin: auto auto auto -$link-padding-gap;
+ padding: 3px $link-padding-gap;
+ color: $text-color;
+ display: block;
+
+ &:hover {
+ background-color: $gray-lighter-dark;
+ color: $headings-color;
+ }
+ }
+ &:last-child {
+ margin-bottom: 5px;
+ }
}