Skip to content

Commit

Permalink
Merge pull request #1475 from antonDedyaev/dark-theme
Browse files Browse the repository at this point in the history
Fix #1470: prepare layout for dark theme
  • Loading branch information
fey authored Jan 18, 2023
2 parents 5549141 + 5c41ab0 commit 2316803
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 12 deletions.
1 change: 1 addition & 0 deletions resources/js/common/currentTheme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default document.querySelector('html').dataset.bsTheme;
4 changes: 4 additions & 0 deletions resources/js/components/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { useDispatch, useSelector } from 'react-redux';
import { useTranslation } from 'react-i18next';
import { changeContent } from '../slices/editorSlice.js';
import codeTemplates from '../common/codeTemplates.js';
import theme from '../common/currentTheme';

import 'codemirror/lib/codemirror.css';
import 'codemirror/theme/material-darker.css';
import 'codemirror/theme/neat.css';
import 'codemirror/addon/scroll/simplescrollbars.css';
import 'codemirror/addon/scroll/simplescrollbars.js';
import 'codemirror/addon/edit/closebrackets.js';
Expand Down Expand Up @@ -55,6 +58,7 @@ const Editor = () => {
scrollbarStyle: 'overlay',
lineNumbers: true,
tabSize: 2,
theme: theme === 'dark' ? 'material-darker' : 'neat',
};

return loadingState === 'loading'
Expand Down
10 changes: 8 additions & 2 deletions resources/js/components/Output.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { useSelector } from 'react-redux';
import { Alert } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import Highlight from 'react-syntax-highlighter';
import { vs } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import { vs, vs2015 } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import theme from '../common/currentTheme';

const statusToTypeMap = {
success: 'success',
Expand Down Expand Up @@ -37,7 +38,12 @@ const Output = () => {
<Alert className="m-3" variant={alertClassName}>
{message}
</Alert>
<Highlight className="flex-grow-1 m-0" language="vbnet" style={vs} showLineNumbers>
<Highlight
className="flex-grow-1 m-0"
language="vbnet"
style={theme === 'dark' ? vs2015 : vs}
showLineNumbers
>
{output}
</Highlight>
</>
Expand Down
10 changes: 8 additions & 2 deletions resources/js/components/TeacherSolution.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import React from 'react';
import { useSelector } from 'react-redux';
import Highlight from 'react-syntax-highlighter';
import { vs } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import { vs, vs2015 } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import theme from '../common/currentTheme';

const TeacherSolution = () => {
const { hasTeacherSolution, teacherSolutionCode } = useSelector((state) => state.exerciseInfo);

return hasTeacherSolution ? (
<div className="d-flex h-100">
<Highlight className="h-100" language="scheme" style={vs} showLineNumbers>
<Highlight
className="h-100"
language="scheme"
style={theme === 'dark' ? vs2015 : vs}
showLineNumbers
>
{teacherSolutionCode}
</Highlight>
</div>
Expand Down
10 changes: 8 additions & 2 deletions resources/js/components/Tests.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import React from 'react';
import { useSelector } from 'react-redux';
import Highlight from 'react-syntax-highlighter';
import { vs } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import { vs, vs2015 } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import theme from '../common/currentTheme';

const Tests = () => {
const { hasTests, testCode } = useSelector((state) => state.exerciseInfo);

return hasTests ? (
<div className="d-flex h-100">
<Highlight className="h-100" language="scheme" style={vs} showLineNumbers>
<Highlight
className="h-100"
language="scheme"
style={theme === 'dark' ? vs2015 : vs}
showLineNumbers
>
{testCode}
</Highlight>
</div>
Expand Down
5 changes: 1 addition & 4 deletions resources/sass/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
// Body
$nav-tabs-link-active-bg: #fff;

// Typography
$font-family-sans-serif: 'Onest', sans-serif;
$font-family-sans-serif: 'Onest', sans-serif;
13 changes: 12 additions & 1 deletion resources/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
// NOTE: move if it will be necessary. It should be do for the site.
// TODO grep and replace by .bd-gray-200
// https://getbootstrap.com/docs/5.0/customize/color/
.x-bg-gray-200 {
.x-bg-gray {
background: $gray-200;
}

@include color-mode(dark) {
.x-bg-gray {
background: $gray-800;
}
.hljs {
color: inherit;
background-color: inherit;
}
}

2 changes: 1 addition & 1 deletion resources/views/exercise/navigation.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul class="nav nav-tabs nav-fill rounded border-bottom-0 x-bg-gray-200 p-2 mb-4">
<ul class="nav nav-tabs nav-fill rounded border-bottom-0 x-bg-gray p-2 mb-4">
<li class="nav-item mb-0">
<a href="{{ route('exercises.index') }}" @class(['nav-link', 'rounded', 'border-0', 'active' => Request::routeIs('exercises.index')]) >
{{ __('layout.nav.exercises') }}
Expand Down

0 comments on commit 2316803

Please sign in to comment.