Skip to content

Commit

Permalink
Merge pull request #1480 from fey/dark-theme
Browse files Browse the repository at this point in the history
add dark theme
  • Loading branch information
fey committed Jan 25, 2023
2 parents 125c361 + b5fb0cd commit 1ff0fc5
Show file tree
Hide file tree
Showing 18 changed files with 316 additions and 284 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Expand Up @@ -17,6 +17,9 @@ indent_size = 2
[*.{js,jsx,scss}]
indent_size = 2

[*.{blade.php}]
indent_size = 2

[package.json]
indent_size = 2

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.render
Expand Up @@ -13,4 +13,4 @@ RUN npm run prod

RUN php artisan migrate:fresh --force --seed

CMD [ "php artisan serve --host 0.0.0.0 --port 8000" ]
CMD [ "php artisan serve --host 0.0.0.0 --port 80" ]
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -21,7 +21,7 @@ start:
heroku local -f Procfile.dev

start-app:
php artisan serve --host 0.0.0.0 --port 8000
php artisan serve --host 0.0.0.0

start-frontend:
npm run watch
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -21,7 +21,7 @@
"@popperjs/core": "^2.11.5",
"@reduxjs/toolkit": "^1.6.2",
"axios": "^0.25",
"bootstrap": "^5.2.3",
"bootstrap": "^5.3.0-alpha1",
"codemirror": "^5.64.0",
"highlight.js": "^11.x",
"i18next": "^21.5.4",
Expand Down
1 change: 1 addition & 0 deletions resources/js/common/currentTheme.js
@@ -0,0 +1 @@
export default document.querySelector('html').dataset.bsTheme;
4 changes: 4 additions & 0 deletions resources/js/components/Editor.jsx
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
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
@@ -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
@@ -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
@@ -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
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
@@ -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
15 changes: 7 additions & 8 deletions resources/views/exercise/show.blade.php
Expand Up @@ -96,14 +96,13 @@ class="btn btn-primary"
<div id="codemirrorContainer"></div>
</div>
</div>
@endsection
@push('scripts')
<script>
const userId = "{{ $authUser->id }}";
const exerciseId = "{{ $exercise->id }}";
const locale = "{{ LaravelLocalization::getCurrentLocale() }}";
window.sicpEditorData = { userId, exerciseId, locale };
const userId = "{{ $authUser->id }}";
const exerciseId = "{{ $exercise->id }}";
const locale = "{{ LaravelLocalization::getCurrentLocale() }}";
window.sicpEditorData = { userId, exerciseId, locale };
</script>

@push('scripts')
<script src="{{ mix('js/editor.js') }}" defer></script>
@endpush
@endsection
@endpush

0 comments on commit 1ff0fc5

Please sign in to comment.