Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1924] Dark theme fixes #2201

Merged
merged 13 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/openforms/js/components/admin/form_design/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ const TinyMCEEditor = ({content, onEditorChange}) => {
const editorRef = useRef(null);
const tinyMceUrl = useContext(TinyMceContext);
const intl = useIntl();
// TODO Django 4.2: use explicit theme names rather than the media query approach:
// https://github.com/django/django/blob/main/django/contrib/admin/static/admin/css/dark_mode.css#L36
const useDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
SilviaAmAm marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
<Editor
tinymceScriptSrc={tinyMceUrl}
onInit={(evt, editor) => (editorRef.current = editor)}
value={content}
init={{...tinyMceConfig, language: intl.locale}}
init={{
...tinyMceConfig,
language: intl.locale,
skin: useDarkMode ? 'oxide-dark' : 'oxide',
content_css: useDarkMode ? 'dark' : 'default',
SilviaAmAm marked this conversation as resolved.
Show resolved Hide resolved
}}
onEditorChange={onEditorChange}
/>
</>
Expand Down
4 changes: 2 additions & 2 deletions src/openforms/scss/components/admin/_ReactModal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
position: absolute;
width: 50vw;
height: 50vh;
background: white;
border: solid 1px #eee;
background: var(--body-bg);
border: 1px solid var(--hairline-color);
border-radius: 0;
outline: none;
padding: 20px;
Expand Down
6 changes: 5 additions & 1 deletion src/openforms/scss/components/admin/_sdk-snippet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
display: inline-block;
padding-top: 10px;
padding-bottom: 10px;
background-color: #efefef;
background-color: var(--form-input-bg);
border-style: solid;
border-width: thin;
border-color: var(--border-color);

pre {
font-size: 100%;
margin-bottom: 0;
color: var(--body-fg);
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/openforms/scss/components/builder/_admin-fixes.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import '~microscope-sass/lib/color';
@import '~microscope-sass/lib/typography';
SilviaAmAm marked this conversation as resolved.
Show resolved Hide resolved

@import '../../vars';

Expand Down Expand Up @@ -35,3 +36,7 @@ div#content h1 {
color: $color-danger;
font-weight: bold;
}

.formio-button-add-another:not(:hover) {
color: var(--body-fg) !important;
}
SilviaAmAm marked this conversation as resolved.
Show resolved Hide resolved
42 changes: 20 additions & 22 deletions src/openforms/scss/components/builder/_builder.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,35 +69,33 @@ div.flatpickr-calendar.open {
padding-top: 10px;
}

[ref='editForm'] {
SilviaAmAm marked this conversation as resolved.
Show resolved Hide resolved
.choices__list {
&--dropdown {
background-color: var(--body-bg);
color: var(--body-fg);
border-color: var(--border-color);
}

.choices__input {
background-color: var(--form-input-bg);
border-color: var(--border-color);
}

.choices__item--selectable.is-highlighted {
background-color: var(--formio-dropdown-highlighted-bg);
}
.choices__list {
&--dropdown {
background-color: var(--body-bg);
color: var(--body-fg);
border-color: var(--border-color);
}

.choices__list + .choices__input {
border: none;
border-radius: unset;
padding: 4px 0 4px 2px;
.choices__input {
background-color: var(--form-input-bg) !important;
border-color: var(--border-color) !important;
SilviaAmAm marked this conversation as resolved.
Show resolved Hide resolved
}

.choices__list:not(:empty) + .choices__input {
width: 1ch;
.choices__item--selectable.is-highlighted {
background-color: var(--formio-dropdown-highlighted-bg);
}
}

.choices__list + .choices__input {
border: none;
border-radius: unset;
padding: 4px 0 4px 2px;
}

.choices__list:not(:empty) + .choices__input {
width: 1ch;
}

.builder-sidebar_scroll {
top: 100px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.formio-component-file {
.list-group-item {
background-color: var(--body-bg);
border-color: var(--hairline-color);
}
}
3 changes: 3 additions & 0 deletions src/openforms/scss/components/builder/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
// fixes of styling broken by django admin styling
@import 'formio-component-checkbox';

// Fix for dark theme
@import 'formio-component-file';

@import 'columns';
@import 'openforms-component';
14 changes: 14 additions & 0 deletions src/openforms/scss/components/builder/_openforms-component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '~microscope-sass/lib/typography';

@import '../../../ui/static/ui/scss/settings';
@import '../../vars';

Expand All @@ -14,6 +16,10 @@
$color-tooltip-background 20px
);

legend {
@include h2(auto);
}

label {
color: $color_dark;
}
Expand All @@ -22,4 +28,12 @@
opacity: 0.9;
}
}

.ck-editor__main {
// TODO: Formio uses CKEditor5, but using their dark theme seems more complex than for the tinymce.
// So for now we keep the default theme, but ensure that the text in the editor is dark and not light.
@media (prefers-color-scheme: dark) {
color: $color-dark;
}
}
}
5 changes: 5 additions & 0 deletions src/openforms/scss/vendor/_rjsf-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
input[type='email'] {
width: $input-field-size; // override from admin/rjsf default
}

select {
background-color: var(--form-input-bg) !important;
border-color: var(--border-color) !important;
}
SilviaAmAm marked this conversation as resolved.
Show resolved Hide resolved
}

&__errors {
Expand Down