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

Feature/optional header #989

Merged
merged 24 commits into from May 21, 2024
Merged

Feature/optional header #989

merged 24 commits into from May 21, 2024

Conversation

BeritJanssen
Copy link
Collaborator

@BeritJanssen BeritJanssen commented May 2, 2024

Close #941 by adding a configurable header to the theme. ExperimentCollectionDashboard will display a <Header> component if a theme with header is set.

Something that's now inconsistent with other views, but perhaps more consistent with json guidelines, is that the dicts sent to the frontend for ExperimentCollection objects will be in camel case, rather than snake case.

Copy link
Contributor

@drikusroor drikusroor left a comment

Choose a reason for hiding this comment

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

I'm a bit concerned about both the ThemeConfig and the DefaultPage being somewhere in between something generic and something Experiment(Collection) oriented, though I'm not sure what the solution should be. Secondly, I feel like the frontend hasn't been finished properly: The experiment tiles seem to be vertically stacked and the other theme properties haven't been implemented. As for the latter, I think you could just copy + paste the font loader & background image configuration from the Experiment or perhaps even use this opportunity to abstract the font loader & background image to one single page/layout.

@@ -34,6 +34,7 @@ def serialize_experiment_collection(
'description': experiment_collection.description,
'consent': consent,
'about_content': about_content,
'theme_id': experiment_collection.theme_config.pk if experiment_collection.theme_config else None
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering why you are sending the theme's id here instead of serialising the theme like we are doing in the experiment. Now you have to first fetch the experiment collection and then do a second http request for fetching the theme. Won't that result in some flashy/glitchy behaviour as you first seen the themeless version and then suddenly the theme might pop up after it's done fetching?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did this based on earlier feedback in which you seemed to be concerned about mixing different models in one serialization.

backend/theme/admin.py Outdated Show resolved Hide resolved
Comment on lines 9 to 24
def serialize_footer(footer: FooterConfig) -> dict:
return {
'disclaimer': footer.disclaimer,
'logos': [
join(settings.MEDIA_URL, str(logo.file)) for logo in footer.logos.all()
],
'privacy': footer.privacy
}


def serialize_header(header: HeaderConfig) -> dict:
return {
'next_experiment_button_text': _('Next experiment'),
'about_button_text': _('About us'),
'show_score': header.show_score
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we have experiment collection specific properties in the theme, does that mean themes are now officially used for experiment collections and we will phase out the theme for specific experiments, or what do you think about this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, with #928 as a proposed course of action, I think the link of Experiment to ThemeConfig can be removed eventually.

Comment on lines 22 to 25
<DefaultPage
collectionSlug={experimentCollection.slug}
nextExperimentSlug={nextExperimentSlug}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it's only on my machine but the tiles are showing as a vertical stack

image

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it has to do with .aha__page .container having a max-width: 600px !important; in Page.scss

frontend/src/components/Header/Header.tsx Outdated Show resolved Hide resolved
frontend/src/components/Header/Header.tsx Outdated Show resolved Hide resolved

// DefaultPage is a Page with an AppBar and a width-restricted container for content
const DefaultPage = ({ className, title, logoClickConfirm, children }) => {
const DefaultPage = ({ className, title, logoClickConfirm, collectionSlug='', nextExperimentSlug='', children }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the/a DefaultPage is a default page in the sense of a generic wrapper whose purpose is to only be a layout for all/some pages, should it really contain properties related to experiments or collections? It seems to become more like a ExperimentCollectionPage now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps I should indeed make a new component.

const DefaultPage = ({ className, title, logoClickConfirm, children }) => {
const DefaultPage = ({ className, title, logoClickConfirm, collectionSlug='', nextExperimentSlug='', children }) => {

const theme = useBoundStore((state) => state.theme);
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it was a conscious decision, but the fonts and background image are not shown like they are on the experiment page:

// Experiment.jsx
<FontLoader fontUrl={theme?.heading_font_url} fontType="heading" />
<FontLoader fontUrl={theme?.body_font_url} fontType="body" />
// Page.jsx
const theme = useBoundStore((state) => state.theme);
const backgroundImageUrl = theme?.background_image || '/public/images/background.jpg';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should indeed still be adjusted.

Comment on lines 72 to 76
if (experimentCollection?.theme_id) {
getTheme(experimentCollection.theme_id).then( (theme: ITheme) =>
setTheme(theme)
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned before, I think it might be better to directly populate the theme property on the experiment collection so you don't have to do two http requests in a row.

Co-authored-by: Drikus Roor <drikusroor@gmail.com>
@BeritJanssen BeritJanssen merged commit 8e86a73 into develop May 21, 2024
10 checks passed
@BeritJanssen BeritJanssen deleted the feature/optional-header branch May 21, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the "Volgende experiment" button on Dashboard
2 participants