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: toggle for wiki opening info display #15662

Conversation

KartikWatts
Copy link
Contributor

Closes #10769

This PR implements:

  1. A toggleable fieldset display for Wikibook opening details on the Analysis page.
  2. User preference is stored as site storage with key: analyse.wikibooks.display

Local Test Link: http://localhost:9663/analysis

Other implementation discussions in the comments

const plyPrefix = (node: Tree.Node) =>
`${Math.floor((node.ply + 1) / 2)}${node.ply % 2 === 1 ? '._' : '...'}`;

const wikiBooksUrl = 'https://en.wikibooks.org';
const apiArgs = 'redirects&origin=*&action=query&prop=extracts&formatversion=2&format=json&exchars=1200';
const apiArgs = 'redirects&origin=*&action=query&prop=extracts&formatversion=2&format=json&exchars=1000';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As with the implementation of the fieldset, some width was decreased for the text content, I kept the character length 1000 not to have a scrollbar for most cases, though after implementation I also felt, the scrollbar could rather be kept within the fieldset component and be much better. Please let me know your thoughts to confirm the suitability.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes the scroll should be inside the fieldset. And the margin around the fieldset removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, thanks.

Comment on lines 13 to 16
$(window).on('load', () => {
const wikiBookField = $('#wikibook-field').first();
const wikiBookStorageKey = 'analyse.wikibooks.display';
const toggleWikiBookStorage = () => site.storage.boolean(wikiBookStorageKey).toggle();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I wanted to do this in the best possible way using Scala features like hook, or typescript snabbdom library, but couldn't come across a better solution. Some assistance here provided kindly might be really helpful. Regards.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This file uses plain javascript DOM manipulation, so it makes sense to continue in that direction, as you did.

You don't need $(window).on('load'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I tried it without the load event earlier as well and again, but couldn't understand, the event doesn't trigger without it.
Even though the element already exists, any idea, why it could be so, else I may invest some more time to analyze this. Regards.

@KartikWatts KartikWatts changed the title Feat/toggle for wiki opening info display feat: toggle for wiki opening info display Jul 5, 2024
@@ -1,4 +1,5 @@
@import '../analyse.abstract';
@import '../../../common/css/component/mselect';
@import '../../../common/css/form/form3';
Copy link
Collaborator

Choose a reason for hiding this comment

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

the analysis board doesn't need form components, so I think the fieldset styling should be extracted to a new scss file, which form3 imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted to a reusable scss file: ui/common/css/component/_toggle-box.scss
Updated.

site.pubsub.emit('chat.resize');
};

$(window).on('load', () => {
const wikiBookField = $('#wikibook-field').first();
const wikiBookStorageKey = 'analyse.wikibooks.display';
Copy link
Collaborator

Choose a reason for hiding this comment

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

const wikiBookStorage = site.storage.boolean('analyse.wikibooks.display')

which you can then use like wikiBookStorage.toggle()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, thanks.

Copy link
Collaborator

@ornicar ornicar left a comment

Choose a reason for hiding this comment

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

looking pretty good!

- ui improvements for toggle box container
- separate implementation for css styles and logic
@KartikWatts KartikWatts force-pushed the feat/toggle-for-wiki-opening-info-display branch from 7eff495 to f4642e3 Compare July 9, 2024 13:10
@ornicar ornicar merged commit 0ec5a83 into lichess-org:master Jul 9, 2024
4 checks passed
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.

make Wiki Opening Info on Analysis Board optional
2 participants