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

Update icons to use blade components, standardize button colors and format #15327

Merged
merged 36 commits into from
Aug 20, 2024

Conversation

snipe
Copy link
Owner

@snipe snipe commented Aug 18, 2024

This looks a lot scarier than it is, with all the files it touches. It simply switches to using an icon blade component where we can, so that we can always be sure that the icon is correct, and has the appropriate attributes (aria-hidden, for example).

This will improve our accessibility as well, since in working on this I found a bunch of icons that didn't have the aria-hidden attribute, and it will (hopefully) mean less hunting down icons that we use consistently throughout the system.

As I was poking around in some of the transformers, I also got rid of a stupid way we were handling titles on some of the older ones. I must have missed those when I came up with the better way (using the custom css-blah class.)

Note: There are a few places we cannot use the icon blade components yet. I'm working on those, but some may be unsurmountable - specifically the error messages we include under each form field. It's not really a big deal IMHO, since they always use the same icon, but I bet I can probably work on that too. It breaks because we use {!! !!} for our error messages so that we can use the <span class="alert-msg" to apply the red error color to the error message, but that means the component doesn't get parsed properly. Something I can work around in a different PR I think.

Icons that are only used once were not included in the icon helper.

This PR also standardizes the order and color of the main action buttons (edit, checkout, checkin, etc) across all first-class views.

Copy link

what-the-diff bot commented Aug 18, 2024

PR Summary

  • Introduction of Icon Helper
    A new utility file, IconHelper.php, was added to our project. This helpful tool generates different icons based on the input it is given.

  • Icon Alias Addition
    To facilitate easier use, an alias for the IconHelper was added in the configuration file named config/app.php.

  • UI Enhancements Across Views
    Several interface elements across different views were upgraded by replacing conventional icons (denoted <i> tag in HTML) with our custom IconHelper. This allows for better control, flexibility, and maintainability in managing iconography throughout the project.

  • Updated UI Components with Icon Helper
    Existing UI components were updated to take advantage of the new IconHelper. The IconHelper was used to replace many instances of icons scattered throughout the project. The change provides more control over the icons without having to edit every individual instance.

  • New File Addition to Handle Icons
    A new file, icon.blade.php was introduced to manage the displaying of icons in a more effective and efficient manner.

  • Tooltips Addition
    Tooltips with the appropriate icon types were added across several files enhancing the overall user experience.

  • Conversion of Icons to Icon Component in Multiple Files
    Many instances of the icon tags <i> were converted to use the new <x-icon> component across multiple files. This change improved consistency and maintainability of the icons.

  • Internationalization Enhancement for the Download Button
    The download button now uses an internationalization function trans for label translation which makes the app more accessible to multiple regions/languages.

  • Updated Save Button Labels
    The save button labels in various settings files were updated, again using the trans function to translate the labels. Additionally, icon components were added to these buttons improving the aesthetic.

  • Replacement of User Icons
    In certain places, the conventional user icon was replaced with the new <x-icon> component providing a uniform and improved look.

@snipe snipe changed the title WIP - Update button style WIP - Update icons to use blade components, standardize button colors and format Aug 19, 2024
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
@snipe snipe marked this pull request as ready for review August 19, 2024 12:40
@snipe snipe changed the title WIP - Update icons to use blade components, standardize button colors and format Update icons to use blade components, standardize button colors and format Aug 19, 2024
@snipe snipe requested a review from uberbrady August 19, 2024 13:17
Signed-off-by: snipe <[email protected]>
'id' => false,
'title' => false,
])
<i {{ $attributes->merge(['class' => Icon::icon($type).' '.$class]) }} {{ isset($style) ? $attributes->merge(['style' => $style]): '' }} {{ isset($title) ? $attributes->merge(['title' => $title]): '' }} aria-hidden="true"></i>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think, since the only place the 'Icon helper' is used is right here, that you might be able to directly paste it in above this <i> tag, in a @php block.

Then the thing that spits out the icons is right next to the place we use the icons, right? And you can get rid of some other extra little bits here and there.

Copy link
Owner Author

Choose a reason for hiding this comment

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

There are some other places where we're not directly generating an icon itself though (some transformers, etc) so it seemed better to keep that logic out of the blade component.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In fact, you can just make it into a simple PHP array if it makes sense - something like:

$iconmap = [
    /* ..... */
    'caret-down' => 'fa fa-caret-down',
    /* ..... */
];

Copy link
Owner Author

Choose a reason for hiding this comment

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

Again, I didn't want that logic in the blade, since there are other places where it could be useful, specifically when we're trying to determine which icon to use in transformers, even though we're not actually using that icon in those methods, we're passing it elsewhere (sometimes because it's in javascript, etc)

Copy link
Collaborator

Choose a reason for hiding this comment

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

fwiw, I'm for avoiding a giant @php block in the component too.

@marcusmoore
Copy link
Collaborator

"blade components" in the title caught my eye. I'm going to add myself as a reviewer to see if I have any other input 😄

@marcusmoore marcusmoore self-requested a review August 19, 2024 17:33
@snipe
Copy link
Owner Author

snipe commented Aug 19, 2024

@marcusmoore ticktock ticktock :P

Copy link
Collaborator

@marcusmoore marcusmoore left a comment

Choose a reason for hiding this comment

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

There is some slight spacing issues...gonna try to track it down.

menu

'id' => false,
'title' => false,
])
<i {{ $attributes->merge(['class' => Icon::icon($type).' '.$class]) }} {{ isset($style) ? $attributes->merge(['style' => $style]): '' }} {{ isset($title) ? $attributes->merge(['title' => $title]): '' }} aria-hidden="true"></i>
Copy link
Collaborator

Choose a reason for hiding this comment

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

fwiw, I'm for avoiding a giant @php block in the component too.

app/Helpers/IconHelper.php Show resolved Hide resolved
'id' => false,
'title' => false,
])
<i {{ $attributes->merge(['class' => Icon::icon($type).' '.$class]) }} {{ isset($style) ? $attributes->merge(['style' => $style]): '' }} {{ isset($title) ? $attributes->merge(['title' => $title]): '' }} aria-hidden="true"></i>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another note: I think we should avoid using isset in components since that should be handled by @props. If something is in @props without a default value then the component will throw an exception when trying to render and if it does have a value then we don't need to use isset (we could add a conditional around the value if needed of course).

In this case we should be able to remove class from the props list since {{ $attributes->class(...) }} should handle that.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I tried that, but it still threw an error that the variable was not set.

@marcusmoore
Copy link
Collaborator

Looks like fa-fw is missing on some of the icons on the left nav bar and also on the ones along the top. Here's a gif of the differences between develop and this branch:

showing icon alignment

@snipe snipe merged commit 64bed01 into develop Aug 20, 2024
8 of 9 checks passed
@snipe snipe deleted the update_button_style branch August 20, 2024 09:13
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.

3 participants