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/issue 12/language switcher - Responsive Language Switcher with Custom SVG and Padding #18

Merged
merged 19 commits into from
Mar 18, 2024

Conversation

katporks
Copy link
Collaborator

@katporks katporks commented Mar 14, 2024

This PR introduces a responsive language switcher that utilizes Django's set_language redirect view to handle language changes.

A new CSS class, .language-select, has been added to the language switcher component. This class enables us to use a custom SVG as the dropdown arrow for the select element and to provide custom padding to properly position this SVG.

The select element's default appearance varies across different browsers and doesn't allow for much customization. To address this, we've used the -moz-appearance, -webkit-appearance, and appearance properties to remove the default browser styling.

A background-image property with an SVG encoded as a data URL has been added. This SVG serves as our custom dropdown arrow. We've used background-repeat: no-repeat to ensure the SVG only appears once, and background-size: 18px 18px to control the size of the SVG.

The padding-right: 27.25px property is used to add space on the right side of the select element, ensuring the SVG doesn't overlap with the text.

We've also added a rule for .language-select::-ms-expand to handle Internet Explorer, which uses a different method to render the dropdown arrow. This rule hides the default dropdown arrow in IE.

Finally, we've added .language-select:focus to remove the default focus outline and box-shadow, as they interfere with our custom styling. Please note that this could impact accessibility, and we should consider adding a custom focus style in the future.

This change enhances the visual consistency of our language switcher across different browsers and aligns with our branding. It also ensures a seamless user experience when changing languages on our platform.

image
image
image

Copy link
Member

@spwoodcock spwoodcock left a comment

Choose a reason for hiding this comment

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

Looks good!

Two small things:

  • If you use many icons in the site, then you could consider using an icon library like material, font-awesome etc to make your life easier. But if not used much the svg approach is good too - requires one less dependency and is future proof.

  • I think you can safely drop internet explorer support. Many sites have done so since it's last official update mid 2022 (it's dead).

@spwoodcock
Copy link
Member

Thanks for the detailed descriptions and screenshots to help review by the way 😁

@katporks
Copy link
Collaborator Author

Looks good!

Two small things:

  • If you use many icons in the site, then you could consider using an icon library like material, font-awesome etc to make your life easier. But if not used much the svg approach is good too - requires one less dependency and is future proof.
  • I think you can safely drop internet explorer support. Many sites have done so since it's last official update mid 2022 (it's dead).

Great suggestion! I'll bring it up with Swoon to see if they're happy with the font-awesome or material icons. I'll drop the IE workaround 👍🏼

@katporks katporks merged commit b5d1068 into main Mar 18, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment