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

Add sections to settings #849

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Add sections to settings #849

wants to merge 19 commits into from

Conversation

MohamadNateqi
Copy link
Contributor

@MohamadNateqi MohamadNateqi commented Aug 8, 2024

close #668

This PR aims to add sections to settings.

image

Each section is an accordion, as shown in the image. When you first visit the settings page, only the General section is open, while the rest are closed. Any changes made to the state of the accordions will be saved in the localStorage. The localStorage has been chosen to prevent the unnecessary overhead of storing the states in the database and making queries.

For settings that are added by the Professional plugin, two approaches exist:

  1. Disable settings sections if the Pro extension doesn't support it
  2. Group uncategorized settings in a new section.

I implemented the second approach and created a "More" section to keep the rest of the uncategorized settings.

image

Also, the helpers method has been created to modify sections more easily. To see how sections can be added for the Pro extension, you can switch to this PR's branch: https://github.com/wpovernight/woocommerce-pdf-ips-pro/pull/443.

Since we used the word "section" for another purpose, I used the word "category" in my codes.

Copy link
Contributor

@BrunoPavlinic98 BrunoPavlinic98 left a comment

Choose a reason for hiding this comment

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

LGTM!
Categorized sections look OK to me, and I have no negative remarks for the code.

@Terminator-Barbapapa
Copy link
Contributor

@MohamadNateqi @alexmigf @BrunoPavlinic98 I made a few style tweaks. Let me know what you think.

@MohamadNateqi
Copy link
Contributor Author

MohamadNateqi commented Sep 25, 2024

@Terminator-Barbapapa It looks nice.

I find it a little hard to distinguish between the title and content here:

image

It would be good if you could somehow improve that.

@BrunoPavlinic98
Copy link
Contributor

@Terminator-Barbapapa It looks nice.

I find it a little hard to distinguish between the title and content here:

image

It would be good if you could somehow improve that.

@Terminator-Barbapapa I think it looks and works great.

Regarding the hard distinguish issue @MohamadNateqi mentioned, maybe we could put the Enable option (and all other "standalone" options, if there are any more of them) in their standalone div (the lighter div with gray border), the same one that is being shown when we open a particular section. If not that, we can provide tabulation to it so that standalone options are in the same level as the section grouped options.

@Terminator-Barbapapa
Copy link
Contributor

I agree that this option seems out of place. I think apart from some changes in the styling we should also look at where the options are placed, as I think we can create a more logical layout. In this case I think the 'Enable' option would fit well in the 'General' section. Like this:

Scherm­afbeelding 2024-09-26 om 10 56 24




In a separate issue I think we can make some additional styling improvements, where we update the primary color to #6e1edc and introduce sliders to replace checkboxes. Like this:

Scherm­afbeelding 2024-09-26 om 10 46 51

@BrunoPavlinic98
Copy link
Contributor

BrunoPavlinic98 commented Sep 26, 2024

I agree that this option seems out of place. I think apart from some changes in the styling we should also look at where the options are placed, as I think we can create a more logical layout. In this case I think the 'Enable' option would fit well in the 'General' section. Like this:

Scherm­afbeelding 2024-09-26 om 10 56 24 In a separate issue I think we can make some additional styling improvements, where we update the primary color to `#6e1edc` and introduce sliders to replace checkboxes. Like this: Scherm­afbeelding 2024-09-26 om 10 46 51

@Terminator-Barbapapa I agree to put the Enable option to general section, and I agree with sliders.

assets/css/settings-styles.css Show resolved Hide resolved
$('.settings_category h2' ).click( function() {
const index = $( '.settings_category h2' ).index( $( this ) );

$( this ).toggleClass( 'active' ).next( '.form-table' ).slideToggle( 'fast', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not work for screens sizes under 960px. At the moment we use display: block !important here:

So the section is never hidden when clicking on the section title. Also the slide animation is not working when the .form-table element is set to display: table;. Which we do when viewing the settings full screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Terminator-Barbapapa For the full-screen mode, where the display: table;, I think there is no easy way to fix it.

One way would be to make the display property block, then make the transition, and then revert it to table, which has other side effects and issues, such as the bad display of elements during the transition.

Another option would be to switch to height transition instead of toggling the display.

Another option would be wrapping the form-table around a DIV element and working with that, but this is not a good way as it requires many modifications.

I tried to fix it using the first option, but several issues appeared that made me think this was not a good approach.

If we're going to fix this issue for full-screen mode, then switching to height transition might be the better option here.

Would you happen to have any suggestions or opinions?

assets/js/admin-script.js Outdated Show resolved Hide resolved
assets/js/admin-script.js Outdated Show resolved Hide resolved
includes/documents/class-wcpdf-invoice.php Outdated Show resolved Hide resolved
includes/documents/class-wcpdf-packing-slip.php Outdated Show resolved Hide resolved
includes/class-wcpdf-settings.php Outdated Show resolved Hide resolved
includes/documents/class-wcpdf-invoice.php Outdated Show resolved Hide resolved
includes/documents/class-wcpdf-invoice.php Outdated Show resolved Hide resolved
includes/documents/class-wcpdf-packing-slip.php Outdated Show resolved Hide resolved
@Terminator-Barbapapa Terminator-Barbapapa added this to the IPS Free: 3.8.7 milestone Sep 30, 2024
@alexmigf
Copy link
Member

alexmigf commented Oct 1, 2024

@MohamadNateqi can you fix the conflicts here and also address the comments from @Terminator-Barbapapa ?

@alexmigf
Copy link
Member

alexmigf commented Oct 1, 2024

I noticed that the document title and the related settings, which used to be at the top, are now placed below everything. This change feels a bit less intuitive.

I have a few suggestions to improve the user experience:

  • Rename "Document details" to "Display," as it primarily contains display settings.
  • Move the "Additional settings" section to be directly below the "General" section for a more logical flow.
  • Rename "Additional settings" to "Document details" for better clarity.
  • Move the "Next invoice number (without prefix/suffix, etc.)" setting to the "General" section.

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.

Create settings sections
4 participants