From 6e4db7d13a926845bf82f5b035afede42d6d5a89 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 12 Mar 2018 16:24:31 +0100 Subject: [PATCH] [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-- 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). --- .../static/src/scss/account_dashboard.scss | 10 +- .../src/scss/account_journal_dashboard.scss | 22 +- .../src/scss/account_reconciliation.scss | 28 +- addons/account/static/src/scss/variables.scss | 5 + addons/account/views/account.xml | 6 + addons/calendar/static/src/scss/calendar.scss | 4 +- addons/event/static/src/scss/event.scss | 2 +- .../static/src/scss/google_calendar.scss | 2 +- .../static/src/scss/hr_attendance.scss | 2 +- .../static/src/scss/hr_org_chart.scss | 88 ++--- .../static/src/scss/variables.scss | 14 + addons/hr_org_chart/views/hr_templates.xml | 6 + .../static/src/scss/copy_clipboard.scss | 2 +- .../src/scss/im_livechat_bootstrap.scss | 11 +- .../views/im_livechat_channel_templates.xml | 1 - addons/lunch/static/src/scss/lunch.scss | 2 +- addons/mail/static/src/scss/chat_window.scss | 25 +- addons/mail/static/src/scss/chatter.scss | 8 +- addons/mail/static/src/scss/composer.scss | 14 +- addons/mail/static/src/scss/discuss.scss | 45 ++- .../static/src/scss/extended_chat_window.scss | 2 +- addons/mail/static/src/scss/followers.scss | 8 +- .../mail/static/src/scss/mail_activity.scss | 4 +- addons/mail/static/src/scss/systray.scss | 10 +- addons/mail/static/src/scss/thread.scss | 20 +- addons/mail/static/src/scss/variables.scss | 17 +- addons/mail/views/mail_templates.xml | 7 +- .../static/src/scss/mass_mailing.ui.scss | 14 +- .../mrp/static/src/scss/mrp_bom_report.scss | 2 +- addons/portal/static/src/scss/portal.scss | 2 +- .../static/src/scss/project_dashboard.scss | 2 +- .../static/src/scss/sale_timesheet.scss | 6 +- .../static/src/scss/sales_team_dashboard.scss | 5 +- .../src/scss/stock_traceability_report.scss | 6 +- addons/survey/views/survey_templates.xml | 3 +- addons/web/static/src/scss/base_settings.scss | 20 +- .../static/src/scss/bootstrap_overridden.scss | 118 ++----- .../scss/bootstrap_overridden_frontend.scss | 0 addons/web/static/src/scss/control_panel.scss | 9 +- addons/web/static/src/scss/data_export.scss | 6 +- addons/web/static/src/scss/datepicker.scss | 14 +- .../web/static/src/scss/domain_selector.scss | 6 +- addons/web/static/src/scss/dropdown.scss | 8 +- .../web/static/src/scss/dropdown_extra.scss | 7 +- addons/web/static/src/scss/fields.scss | 36 +- addons/web/static/src/scss/fields_extra.scss | 2 +- addons/web/static/src/scss/form_view.scss | 78 ++--- .../web/static/src/scss/form_view_extra.scss | 12 +- addons/web/static/src/scss/graph_view.scss | 2 +- .../src/scss/kanban_column_progressbar.scss | 7 +- .../web/static/src/scss/kanban_dashboard.scss | 173 ---------- .../src/scss/kanban_examples_dialog.scss | 6 +- addons/web/static/src/scss/kanban_view.scss | 6 +- .../static/src/scss/kanban_view_mobile.scss | 4 +- .../static/src/scss/layout_background.scss | 12 +- addons/web/static/src/scss/layout_clean.scss | 18 +- addons/web/static/src/scss/list_view.scss | 19 +- .../static/src/scss/model_field_selector.scss | 4 +- addons/web/static/src/scss/navbar.scss | 46 +-- addons/web/static/src/scss/pivot_view.scss | 10 +- .../static/src/scss/primary_variables.scss | 92 +++++ addons/web/static/src/scss/progress_bar.scss | 6 +- addons/web/static/src/scss/rainbow.scss | 12 +- addons/web/static/src/scss/search_view.scss | 6 +- .../static/src/scss/search_view_extra.scss | 4 +- .../static/src/scss/secondary_variables.scss | 43 +++ addons/web/static/src/scss/tooltip.scss | 16 +- addons/web/static/src/scss/utils.scss | 322 ++++++++++++++---- addons/web/static/src/scss/variables.scss | 82 ----- addons/web/static/src/scss/views.scss | 4 +- addons/web/static/src/scss/web_calendar.scss | 48 ++- addons/web/static/src/scss/webclient.scss | 12 +- .../web/static/src/scss/webclient_extra.scss | 9 +- .../web/static/src/scss/webclient_layout.scss | 13 +- addons/web/views/webclient_templates.xml | 48 ++- .../static/src/scss/web_editor.common.scss | 35 -- .../static/src/scss/web_editor.ui.scss | 161 ++++----- .../static/src/scss/web_editor.variables.scss | 97 ++++-- addons/web_editor/views/editor.xml | 4 +- .../static/src/scss/dashboard.scss | 2 +- addons/web_tour/static/src/scss/tip.scss | 2 +- .../static/src/scss/website.backend.scss | 52 +-- .../static/src/scss/website.edit_mode.scss | 2 +- addons/website/static/src/scss/website.scss | 2 +- .../website/static/src/scss/website.ui.scss | 18 +- addons/website/views/website_templates.xml | 2 +- .../views/website_livechat.xml | 1 - .../static/src/scss/website_quotation.scss | 2 +- .../static/src/scss/website_rating.scss | 6 +- .../static/src/scss/website_sale.scss | 2 +- .../src/scss/website_sale_dashboard.scss | 10 +- .../static/src/scss/website_slides.scss | 25 +- .../src/scss/website_theme_install.scss | 8 +- 93 files changed, 1095 insertions(+), 1081 deletions(-) create mode 100644 addons/account/static/src/scss/variables.scss create mode 100644 addons/hr_org_chart/static/src/scss/variables.scss create mode 100644 addons/web/static/src/scss/bootstrap_overridden_frontend.scss create mode 100644 addons/web/static/src/scss/primary_variables.scss create mode 100644 addons/web/static/src/scss/secondary_variables.scss delete mode 100644 addons/web/static/src/scss/variables.scss diff --git a/addons/account/static/src/scss/account_dashboard.scss b/addons/account/static/src/scss/account_dashboard.scss index de562759e11..938bc058af2 100644 --- a/addons/account/static/src/scss/account_dashboard.scss +++ b/addons/account/static/src/scss/account_dashboard.scss @@ -1,7 +1,7 @@ .o_kanban_view.o_kanban_dashboard.o_account_kanban { &.o_kanban_ungrouped .o_account_dashboard_header { - margin: (0 - $o-kanban-record-margin) ($o-kanban-record-margin - $odoo-horizontal-padding) $o-kanban-record-margin; + margin: (0 - $o-kanban-record-margin) ($o-kanban-record-margin - $o-horizontal-padding) $o-kanban-record-margin; } .o_account_dashboard_header { @@ -11,10 +11,10 @@ width: 100%; height: auto; // cancel o_form_view height 100%, which hides the help tip message at the bottom of the screen min-height: 0%; // cancel o_form_view min-height 100%, which hides the help tip message at the bottom of the screen - background-color: $odoo-view-background-color; + background-color: $o-view-background-color; .o_form_statusbar { - padding-right: $odoo-horizontal-padding; + padding-right: $o-horizontal-padding; } h4 { @@ -52,8 +52,8 @@ } &:last-of-type { - margin-left: $odoo-horizontal-padding; - padding-left: $odoo-horizontal-padding*.5; + margin-left: $o-horizontal-padding; + padding-left: $o-horizontal-padding*.5; border-left: 1px solid $gray-lighter-dark; } } diff --git a/addons/account/static/src/scss/account_journal_dashboard.scss b/addons/account/static/src/scss/account_journal_dashboard.scss index e068040784d..1b87a6363a6 100644 --- a/addons/account/static/src/scss/account_journal_dashboard.scss +++ b/addons/account/static/src/scss/account_journal_dashboard.scss @@ -6,17 +6,17 @@ } .o_kanban_card_settings { - padding-top: $odoo-horizontal-padding/2; - padding-bottom: $odoo-horizontal-padding/2; + padding-top: $o-horizontal-padding/2; + padding-bottom: $o-horizontal-padding/2; border-top: 1px solid; - border-color: $odoo-brand-lightsecondary; + border-color: $o-brand-lightsecondary; } .o_dashboard_star { font-size: 12px; &.fa-star-o { - color: $odoo-main-color-muted; + color: $o-main-color-muted; &:hover { color: gold; } @@ -27,7 +27,7 @@ } .o_dashboard_graph { - margin-bottom: -$odoo-horizontal-padding/2; + margin-bottom: -$o-horizontal-padding/2; } } @@ -58,7 +58,7 @@ } g.tick.major { // Don't know why, but leads to strange bold text - // stroke: $odoo-brand-primary; + // stroke: $o-brand-primary; line { display: none; @@ -72,13 +72,13 @@ g.nv-linesWrap { g.nv-group.nv-series-0 { fill-opacity: 0.3 !important; - fill: $odoo-brand-primary !important; - stroke: $odoo-brand-primary !important; + fill: $o-brand-primary !important; + stroke: $o-brand-primary !important; .nv-point { visibility: hidden; r: 3; - stroke: $odoo-brand-primary !important; + stroke: $o-brand-primary !important; fill: white; stroke-width: 2; } @@ -99,11 +99,11 @@ g.nv-group.nv-series-0 { g.past { opacity: 0.5; - fill: $odoo-brand-primary !important; + fill: $o-brand-primary !important; } g.future { opacity: 0.5; - fill: $odoo-brand-optional !important; + fill: $o-brand-optional !important; } } } diff --git a/addons/account/static/src/scss/account_reconciliation.scss b/addons/account/static/src/scss/account_reconciliation.scss index 5d3e8ec3810..204337c5808 100644 --- a/addons/account/static/src/scss/account_reconciliation.scss +++ b/addons/account/static/src/scss/account_reconciliation.scss @@ -1,11 +1,3 @@ -$actionColWidth: 15px; -$mainTableBordersPadding: 3px; -$lightBorder: 1px solid #bbb; -$accountingBorder: 1px solid #000; -$initialLineBackground: #f0f0f0; -$infoColor: #44c; - - .o_reconciliation { h1 { width: 48%; @@ -18,7 +10,7 @@ $infoColor: #44c; &.statement_name { @include o-text-overflow; &.editable:hover { - outline: 1px dashed $odoo-brand-optional; + outline: 1px dashed $o-brand-optional; outline-offset: -1px; cursor: pointer; } @@ -51,7 +43,7 @@ $infoColor: #44c; .o_view_noreconciliation { max-width: none; padding: 0 10%; - color: $odoo-main-color-muted; + color: $o-main-color-muted; font-size: 125%; } @@ -110,16 +102,16 @@ $infoColor: #44c; cursor: pointer; } tr.already_reconciled { - color: $infoColor; + color: $o-account-info-color; } tr.invalid { text-decoration: line-through; } thead td { - border-top: $lightBorder; + border-top: $o-account-light-border; padding-top: 4px; padding-bottom: 5px; - background-color: $initialLineBackground; + background-color: $o-account-initial-line-background; } tfoot td { color: #bbb; @@ -182,7 +174,7 @@ $infoColor: #44c; td { padding-top: 10px; text-align: center; - color: $infoColor; + color: $o-account-info-color; } } @@ -231,7 +223,7 @@ $infoColor: #44c; content: "\f067"; } .match_controls { - padding: 0 0 5px ($actionColWidth+$mainTableBordersPadding); + padding: 0 0 5px ($o-account-action-col-width+$o-account-main-table-borders-padding); .filter { width: 240px; @@ -254,7 +246,7 @@ $infoColor: #44c; } .show_more { display: inline-block; - margin-left: ($actionColWidth+$mainTableBordersPadding); + margin-left: ($o-account-action-col-width+$o-account-main-table-borders-padding); margin-top: 5px; } } @@ -262,7 +254,7 @@ $infoColor: #44c; /* Create view */ .create { > div { - margin: 0 $actionColWidth; + margin: 0 $o-account-action-col-width; padding: 10px; overflow: auto; border: 1px solid #ddd; @@ -294,7 +286,7 @@ $infoColor: #44c; .add_line_container { text-align: center; clear: both; - color: $infoColor; + color: $o-account-info-color; cursor: pointer; } } diff --git a/addons/account/static/src/scss/variables.scss b/addons/account/static/src/scss/variables.scss new file mode 100644 index 00000000000..b83890b01a1 --- /dev/null +++ b/addons/account/static/src/scss/variables.scss @@ -0,0 +1,5 @@ +$o-account-action-col-width: 15px !default; +$o-account-main-table-borders-padding: 3px !default; +$o-account-light-border: 1px solid #bbb !default; +$o-account-initial-line-background: #f0f0f0 !default; +$o-account-info-color: #44c !default; diff --git a/addons/account/views/account.xml b/addons/account/views/account.xml index 45ca15f14bd..d8153c82871 100644 --- a/addons/account/views/account.xml +++ b/addons/account/views/account.xml @@ -1,5 +1,11 @@ + +