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

Fix: Allow overrides on content objects (fixes #12) #15

Merged
merged 11 commits into from
Jun 28, 2023
Merged

Conversation

swashbuck
Copy link
Contributor

@swashbuck swashbuck commented Mar 23, 2023

Fixes #12

Fix

  • Adds _isHidden option to hide the logo on the main menu (in course.json)
  • Content objects will inherit logo's _src and alt values from course.json
  • Removes version number from README.md

@swashbuck swashbuck self-assigned this Mar 23, 2023
@swashbuck swashbuck marked this pull request as ready for review March 23, 2023 19:00
Copy link
Contributor

@kirsty-hames kirsty-hames 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 finding that the contentObject config is preventing the course config being applied globally. In a Framework build, we typically only add config when we want to override a model so this isn't an issue. In the AAT, all config exists and the default contentObject config _navigationLogo._isEnabled: false is removing the logo from all pages unless I enable and link up an image src etc for each contentObject.

Looking at where we have similar inheritance in Adapt we could try either of the following:

  • An inheritance option like we have in Trickle.
  • A hide option like we have in homebutton.

@swashbuck
Copy link
Contributor Author

I'm finding that the contentObject config is preventing the course config being applied globally.

Thanks, Kirsty! This will need a bit of a refactor then. The AAT always complicates things 😛

@kirsty-hames @StuartNicholls Do we need the ability to override the logo image for specific pages? Or are we fine with a single logo image that's always defined at the course level? Then, it can be shown or hidden on specific pages and the menu.

@swashbuck
Copy link
Contributor Author

swashbuck commented Apr 19, 2023

@kirsty-hames @StuartNicholls I've added a new _isHidden property (only to the documentation, example.json, and schemas) in bfb1768. Let me know if this will work, and I'll implement it in the code.

@swashbuck swashbuck changed the title Fix: Allow overrides on content objects (fixes #12) Breaking: Allow overrides on content objects (fixes #12) May 1, 2023
@swashbuck swashbuck requested a review from kirsty-hames May 1, 2023 22:36
@swashbuck
Copy link
Contributor Author

swashbuck commented May 1, 2023

@kirsty-hames @StuartNicholls I went ahead with the _isHidden option for course.json. PR description is updated above. This should work with the AAT now (tested in legacy AAT).

@kirsty-hames
Copy link
Contributor

a single logo image that's always defined at the course level? Then, it can be shown or hidden on specific pages and the menu.

Apologies for the delayed response but I agree with your suggestion, a single logo image with the option show/hide for specific pages and menu.

@kirsty-hames
Copy link
Contributor

  • Changes src to _src to align with _mobileSrc

Looking at image source defined elsewhere in Adapt, src does seem to be the majority. e.g. _graphic.src for Boxmenu items and components. Should we be using src and mobileSrc for consistency?

Note, boxmenu logo graphic does use _src but this was the only non src instance I could find.

@StuartNicholls
Copy link

  • Changes src to _src to align with _mobileSrc

Looking at image source defined elsewhere in Adapt, src does seem to be the majority. e.g. _graphic.src for Boxmenu items and components. Should we be using src and mobileSrc for consistency?

Note, boxmenu logo graphic does use _src but this was the only non src instance I could find.

Should this not be _small and _large so it reflects the breakpoints?

@StuartNicholls
Copy link

We could do with improving/rethinking the CSS in my humble opinion (or maybe I'm missing something) but perhaps thats a separate issue anyways.

@oliverfoster
Copy link
Member

The _ is short for not translatable. All resource URLs should start with _. src without the underscore is a mistake that was replicated.

@kirsty-hames
Copy link
Contributor

The _ is short for not translatable. All resource URLs should start with _. src without the underscore is a mistake that was replicated.

Just so I'm clear @oliverfoster, are we saying to use _src moving forward and it's a known issue that we have src used elsewhere?

@StuartNicholls
Copy link

@kirsty-hames I think that's just an issue here, but yep, the underscore indicates 'do not translate' etc. My point is that elsewhere we use the breakpoint terminology, fixing this will be a breaking change no? Might as well update?

https://github.com/adaptlearning/adapt-contrib-graphic/blob/master/example.json

@kirsty-hames
Copy link
Contributor

Should this not be _small and _large so it reflects the breakpoints?

I'd agree, it does seem we use src for a single image source and large/small for responsive image sources in Adapt (noting these should be prefixed by _). If this is something that needs discussion perhaps it's best to leave the breaking change out of this PR and raise as a separate issue? And keep this PR for the content object overrides only.

@kirsty-hames
Copy link
Contributor

@kirsty-hames @StuartNicholls I went ahead with the _isHidden option for course.json. PR description is updated above. This should work with the AAT now (tested in legacy AAT).

This is working as expected thanks @swashbuck.

@oliverfoster
Copy link
Member

oliverfoster commented May 3, 2023

The _ is short for not translatable. All resource URLs should start with _. src without the underscore is a mistake that was replicated.

Just so I'm clear @oliverfoster, are we saying to use _src moving forward and it's a known issue that we have src used elsewhere?

Yeas. Always use an _ unless the property is text and translatable.

@oliverfoster
Copy link
Member

oliverfoster commented May 3, 2023

@kirsty-hames I think that's just an issue here, but yep, the underscore indicates 'do not translate' etc. My point is that elsewhere we use the breakpoint terminology, fixing this will be a breaking change no? Might as well update?

https://github.com/adaptlearning/adapt-contrib-graphic/blob/master/example.json

Yes, which is why it hasn't yet been fixed in the graphic schema / example, please don't change the properties in adapt-contrib-graphic schema or example. It is fixed in the image.jsx template.
https://github.com/adaptlearning/adapt-contrib-core/blob/b20e6f85edd597007e2846152d64996e07f1ee10/templates/image.jsx#L12-L21

@StuartNicholls
Copy link

@oliverfoster Completely missed there wasn't an underscore there!

@swashbuck swashbuck changed the title Breaking: Allow overrides on content objects (fixes #12) Fix: Allow overrides on content objects (fixes #12) May 3, 2023
@swashbuck
Copy link
Contributor Author

swashbuck commented May 3, 2023

Ok, I've reverted the src property change and have raised a new PR (#16). Otherwise, let me know if you need any other changes.

@swashbuck
Copy link
Contributor Author

Ok to merge, @StuartNicholls ?

@StuartNicholls
Copy link

@kirsty-hames correct me if I'm wrong but I think the logic is wrong here. @swashbuck I think we want the logo to appear on content object pages if there is no config present for framework builds. So example.json should also be:

// contentObjects.json
"_navigationLogo": {
    "_isEnabled": false
}

I think this reflects the functionality of homebutton ?

Also, the default nav order is 1, which is possibly correct, but the default spacer order in framework is 0, so the logo appears on the right hand side. Wasn't it on the left perviously? Maybe spacer should be 50 in framework?

@swashbuck
Copy link
Contributor Author

I think we want the logo to appear on content object pages if there is no config present for framework builds.

@StuartNicholls Ok, I've made this change in d6cbc15. Content objects no longer require a _navigationLogo property and will be enabled by default if the config is in course.json.

@swashbuck swashbuck requested a review from kirsty-hames June 21, 2023 19:45
@swashbuck
Copy link
Contributor Author

Also, the default nav order is 1, which is possibly correct, but the default spacer order in framework is 0, so the logo appears on the right hand side.

@StuartNicholls Will you file a new ticket for this one? It may be part of a larger discussion about nav order default values. Thanks!

@kirsty-hames
Copy link
Contributor

Also, the default nav order is 1, which is possibly correct, but the default spacer order in framework is 0, so the logo appears on the right hand side.

@StuartNicholls Will you file a new ticket for this one? It may be part of a larger discussion about nav order default values. Thanks!

Setting the nav order to 0 does mean the logo displays to the left of the spacer but agree this would be better raised as a core issue to review the nav order as a collection. On projects I typically use increments of 10 (minimum) as it gives a bit of flexibility when appending new nav items. I think this approach would be useful for setting defaults as it allows wriggle room for non-core plugins to fit around the core elements.

@kirsty-hames
Copy link
Contributor

I think we want the logo to appear on content object pages if there is no config present for framework builds.

@StuartNicholls Ok, I've made this change in d6cbc15. Content objects no longer require a _navigationLogo property and will be enabled by default if the config is in course.json.

Can confirm this is working as described. Testing on Mac Safari, FF, Chrome and iPhone

README.md Outdated
@@ -6,7 +6,7 @@

## Settings overview

The image displays with minimal padding by default or can be configured to fill the navigation bar height. For mobile, an alternative, mobile-friendly image can be specified or the logo can be hidden entirely.
The image displays with minimal padding by default or can be configured to fill the navigation bar height. For mobile, an alternative, mobile-friendly image can be specified or the logo can be hidden entirely. The logo can be shown on the menu, on specific pages, or everywhere.
Copy link
Contributor

@kirsty-hames kirsty-hames Jun 22, 2023

Choose a reason for hiding this comment

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

Perhaps add the default display to the last line?

e.g. The logo can be shown on the menu, on specific pages, or everywhere as default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in e62e714

Copy link
Contributor

@kirsty-hames kirsty-hames left a comment

Choose a reason for hiding this comment

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

Working as expected thanks @swashbuck. Re-tested on Mac Safari, FF, Chrome and iPhone.

@swashbuck swashbuck merged commit cdac516 into master Jun 28, 2023
@swashbuck swashbuck deleted the issue/12 branch June 28, 2023 13:26
@github-actions
Copy link

🎉 This PR is included in version 3.0.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@guywillis
Copy link
Contributor

Just a note to say the _isHidden property should probably be called something a bit more explicit to imply what the config option does. At present, _isEnabled and _isHidden both imply similar functionality whilst something like _isHiddenOnMenu is more descriptive.

@swashbuck
Copy link
Contributor Author

Just a note to say the _isHidden property should probably be called something a bit more explicit to imply what the config option does. At present, _isEnabled and _isHidden both imply similar functionality whilst something like _isHiddenOnMenu is more descriptive.

Thanks, @guywillis . Will you mind raising a new ticket for this? Alternatively, we have a ticket ( #16 ) to align image source properties, so we could tack it on to that?

@kirsty-hames
Copy link
Contributor

Just a note to say the _isHidden property should probably be called something a bit more explicit to imply what the config option does. At present, _isEnabled and _isHidden both imply similar functionality whilst something like _isHiddenOnMenu is more descriptive.

Thanks, @guywillis . Will you mind raising a new ticket for this? Alternatively, we have a ticket ( #16 ) to align image source properties, so we could tack it on to that?

Both the readme text and the schema title note this hides the logo on the menu.

@guywillis
Copy link
Contributor

guywillis commented Jun 28, 2023

Both the readme text and the schema title note this hides the logo on the menu.

It's great to have the functionality defined in documentation but I do think the naming of config options should try to succinctly describe functionality too.

Thanks, @guywillis . Will you mind raising a new ticket for this? Alternatively, we have a ticket ( #16 ) to align image source properties, so we could tack it on to that?

Sure, I'll raise a new ticket. Ticket here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to make logo Menu or page only
5 participants