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

feat(theme): add themes #1954

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft

feat(theme): add themes #1954

wants to merge 31 commits into from

Conversation

JPSchellenberg
Copy link
Member

No description provided.

@JPSchellenberg JPSchellenberg self-assigned this Dec 3, 2021
@JPSchellenberg JPSchellenberg added the [type] feature Changes that introduce a new feature (resulting in minor-version-bump) label Dec 3, 2021
@@ -11,7 +12,7 @@ export default (model: IPlayerModel): string => `<!doctype html>
${model.scripts
.map((script) => `<script src="${script}"></script>`)
.join('\n ')}

<style>${generateThemeCSS(model.theme)}</style>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The theme should be optional

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is optional. When the theme is not defined it returns an empty string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought I think the way to inject the theme with the global custom style is better, as it doesn‘t require changes in the client and it will also work with the iframe embed type.

@@ -15,5 +15,16 @@
"H5P.CoursePresentation": ["H5P.MathDisplay"],
"H5P.InteractiveVideo": ["H5P.MathDisplay"],
"H5P.DragQuestion": ["H5P.MathDisplay"]
},
"theme": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Further customization options could be:

  • corner rounding other button decorations
  • font sizes and font faces
  • margins and paddings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already planed to add those.

this.globalCustomStyles =
this.options?.customization?.global?.styles || [];
this.globalCustomStyles = this.options?.customization?.global
?.styles || [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The theme should not replace the global styles; they should be concatenated I guess

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not replaced but entered as the first entry in the array .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? From what I see it takes the global styles and if it is undefined it now takes the theme. They are not combined. The && doesn‘t work here, as this only works in React.

fontColor: string;
disabledFontColor: string;
backgroundColor: string;
paperBackgroundColor: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"paper" is a Material UI term; is there a more generic term?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secondaryBackground?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@sr258
Copy link
Member

sr258 commented Dec 6, 2021

It would also make sense to accomodate scenarios in which you have a per-content object theme that is configurable by the content author.

} from '../expressErrorHandler';

/**
* This router implements all Ajax calls necessary for the H5P (editor) client to work.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description is not correct

@@ -2089,3 +2092,24 @@ export interface ILockProvider {
options: { timeout: number; maxOccupationTime: number }
): Promise<T>;
}

export interface ITheme {
themeUrl: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is used nowhere else? What is its function?

@sr258
Copy link
Member

sr258 commented Feb 26, 2022

There are still details in content type editors that aren't styled: (didn't look at all of them yet)

Bildschirmaufnahme_Auswahlbereich_20220226182608
Bildschirmaufnahme_Auswahlbereich_20220226182621
Bildschirmaufnahme_Auswahlbereich_20220226182634
Bildschirmaufnahme_Auswahlbereich_20220226182700
Bildschirmaufnahme_Auswahlbereich_20220226182715
Bildschirmaufnahme_Auswahlbereich_20220226182750
Bildschirmaufnahme_Auswahlbereich_20220226182804
Bildschirmaufnahme_Auswahlbereich_20220226182817
Bildschirmaufnahme_Auswahlbereich_20220226182914
Bildschirmaufnahme_Auswahlbereich_20220226182948

@sr258
Copy link
Member

sr258 commented Feb 28, 2022

I've fixed most of the issues above in the editor. There's mostly work to be done in the course presentation editor (it's various submenus).

I've noticed that it seems like a bad idea to override the color property of the body as this has many side effects. H5P is so complex that it's difficult to predict where there might be a panel with a hardcoded background color, so setting the color globally is dangerous as it can easily lead to situations in which there's white on white. It would probably be better to set the color in a more restricted way.

I haven't really looked at the player yet.

@sr258
Copy link
Member

sr258 commented Jun 17, 2022

I've reviewed the state of the theme in the player and I think the approach of the PR isn't working out. Nearly all content types are broken in some way. I've reviewed about 40% (results below)

I suggest this:

  • We have a list of content types that are supported (separate for editor and player).
  • There are two themes, one for editor, one for player
  • The CSS of the theme is never global but always scoped to the content type (in the player, and as far as possible also in the editor)
  • The H5PEditor and H5PPlayer object decide whether to add a theme to the UI based on the content type
  • There's a callback that implementations can pass in to disable themes for content (so that it is a setting for the content object)
  • We go through the list of content types one by one and write SCSS for it, checking every feature and option. We avoid duplication using SCSS imports and mixins.

@JPSchellenberg @jankapunkt What do you think of this approach?
Cornell 1
Cornell 2
Dictation
Dictation 2
Drag and Drop
Essay 1
Essay 2
Fill in the Blanks
Find the hotspot
Find the words
Guess the answer
Image Choice
Image Pairing
Image Sequence
image slider
Interactive Video 1
Interactive Video 2
Interactive Video 3
Interactive Video 4
Interactive Video 5
Kewar
Multiple Choice
Multiple Choice 2
personality quiz 1
Personality quiz 2
Sort Paragraphs
Summary
Timeline
True false
Virtual Tour 1
Virtual Tour 2

@jankapunkt
Copy link
Contributor

Wow, @sr258 you made an effort here. From my perspective this sounds good, especially with the scoping. We also use scss but I wonder if there are people who use just css or things like tailwind. Can they still use the theming then?

@sr258
Copy link
Member

sr258 commented Jun 17, 2022

Yes, the theme builder compiles it to css.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[type] feature Changes that introduce a new feature (resulting in minor-version-bump)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants