mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-07-25 16:03:48 +00:00
Merge branch '56873-only-load-syntax-highlighting-css-when-selected' into 'master'
Resolve "Only load syntax highlighting css when selected" Closes #57739 and #56873 See merge request gitlab-org/gitlab-ce!25232
This commit is contained in:
@ -39,16 +39,6 @@
|
||||
*/
|
||||
@import "components/**/*";
|
||||
|
||||
/*
|
||||
* Code highlight
|
||||
*/
|
||||
@import "highlight/dark";
|
||||
@import "highlight/monokai";
|
||||
@import "highlight/solarized_dark";
|
||||
@import "highlight/solarized_light";
|
||||
@import "highlight/white";
|
||||
@import "highlight/none";
|
||||
|
||||
/*
|
||||
* Styles for JS behaviors.
|
||||
*/
|
||||
|
@ -113,11 +113,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
@mixin dark-diff-match-line {
|
||||
color: $dark-diff-match-bg;
|
||||
background: $dark-diff-match-color;
|
||||
}
|
||||
|
||||
@mixin webkit-prefix($property, $value) {
|
||||
#{'-webkit-' + $property}: $value;
|
||||
#{$property}: $value;
|
||||
|
18
app/assets/stylesheets/highlight/common.scss
Normal file
18
app/assets/stylesheets/highlight/common.scss
Normal file
@ -0,0 +1,18 @@
|
||||
@import "../framework/variables";
|
||||
|
||||
@mixin diff-background($background, $idiff, $border) {
|
||||
background: $background;
|
||||
|
||||
&.line_content span.idiff {
|
||||
background: $idiff;
|
||||
}
|
||||
|
||||
&.diff-line-num {
|
||||
border-color: $border;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin dark-diff-match-line {
|
||||
color: $dark-diff-match-bg;
|
||||
background: $dark-diff-match-color;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
/* https://github.com/MozMorris/tomorrow-pygments */
|
||||
|
||||
@import "../common";
|
||||
|
||||
/*
|
||||
* Dark syntax colors
|
||||
*/
|
@ -1,5 +1,7 @@
|
||||
/* https://github.com/richleland/pygments-css/blob/master/monokai.css */
|
||||
|
||||
@import "../common";
|
||||
|
||||
/*
|
||||
* Monokai Colors
|
||||
*/
|
@ -2,7 +2,7 @@
|
||||
* None Syntax Colors
|
||||
*/
|
||||
|
||||
|
||||
@import "../common";
|
||||
|
||||
@mixin match-line {
|
||||
color: $black-transparent;
|
@ -1,5 +1,7 @@
|
||||
/* https://gist.github.com/qguv/7936275 */
|
||||
|
||||
@import "../common";
|
||||
|
||||
/*
|
||||
* Solarized dark colors
|
||||
*/
|
@ -1,5 +1,7 @@
|
||||
/* https://gist.github.com/qguv/7936275 */
|
||||
|
||||
@import "../common";
|
||||
|
||||
/*
|
||||
* Solarized light syntax colors
|
||||
*/
|
3
app/assets/stylesheets/highlight/themes/white.scss
Normal file
3
app/assets/stylesheets/highlight/themes/white.scss
Normal file
@ -0,0 +1,3 @@
|
||||
.code.white {
|
||||
@import "../white_base";
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
.code.white {
|
||||
@import "white_base";
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
/* https://github.com/aahan/pygments-github-style */
|
||||
|
||||
@import "./common";
|
||||
|
||||
/*
|
||||
* White Syntax Colors
|
||||
*/
|
||||
|
@ -602,18 +602,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
@mixin diff-background($background, $idiff, $border) {
|
||||
background: $background;
|
||||
|
||||
&.line_content span.idiff {
|
||||
background: $idiff;
|
||||
}
|
||||
|
||||
&.diff-line-num {
|
||||
border-color: $border;
|
||||
}
|
||||
}
|
||||
|
||||
.files {
|
||||
.diff-file:last-child {
|
||||
margin-bottom: 0;
|
||||
|
@ -38,6 +38,8 @@
|
||||
= stylesheet_link_tag 'performance_bar' if performance_bar_enabled?
|
||||
= stylesheet_link_tag 'csslab' if Feature.enabled?(:csslab)
|
||||
|
||||
= stylesheet_link_tag "highlight/themes/#{user_color_scheme}", media: "all"
|
||||
|
||||
= Gon::Base.render_data
|
||||
|
||||
- if content_for?(:library_javascripts)
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: Only load syntax highlight CSS of selected theme
|
||||
merge_request: 25232
|
||||
author:
|
||||
type: performance
|
@ -147,6 +147,8 @@ module Gitlab
|
||||
config.assets.precompile << "errors.css"
|
||||
config.assets.precompile << "csslab.css"
|
||||
|
||||
config.assets.precompile << "highlight/themes/*.css"
|
||||
|
||||
# Import gitlab-svgs directly from vendored directory
|
||||
config.assets.paths << "#{config.root}/node_modules/@gitlab/svgs/dist"
|
||||
config.assets.precompile << "icons.svg"
|
||||
|
@ -62,6 +62,14 @@ describe 'layouts/_head' do
|
||||
end
|
||||
end
|
||||
|
||||
it 'adds selected syntax highlight stylesheet' do
|
||||
allow_any_instance_of(PreferencesHelper).to receive(:user_color_scheme).and_return("solarised-light")
|
||||
|
||||
render
|
||||
|
||||
expect(rendered).to match('<link rel="stylesheet" media="all" href="/stylesheets/highlight/themes/solarised-light.css" />')
|
||||
end
|
||||
|
||||
def stub_helper_with_safe_string(method)
|
||||
allow_any_instance_of(PageLayoutHelper).to receive(method)
|
||||
.and_return(%q{foo" http-equiv="refresh}.html_safe)
|
||||
|
Reference in New Issue
Block a user