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

FR: set HTML direction #83

Open
2 tasks done
omar2205 opened this issue Mar 2, 2023 · 1 comment
Open
2 tasks done

FR: set HTML direction #83

omar2205 opened this issue Mar 2, 2023 · 1 comment
Labels
good first issue Good for newcomers

Comments

@omar2205
Copy link
Collaborator

omar2205 commented Mar 2, 2023

Describe the problem

we don't add a dir prop to the HTML element.

Describe the proposed solution

In

  1. https://github.com/CodingGarden/listd/blob/main/src/app.html#L2
- <html lang="%lang%">
+ <html lang="%lang%" dir="%dir%">
  1. https://github.com/CodingGarden/listd/blob/main/src/hooks.server.ts#L25
- return resolve(event, { transformPageChunk: ({ html }) => html.replace('%lang%', locale) });
+ const direction = (new Intl.Locale(locale)).textInfo.direction
+ return resolve(event, { transformPageChunk: ({ html }) => html.replace('%lang%', locale).replace('%dir%', direction) });

Intl.Locale ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale

Have you checked if this issue has already been raised?

  • I did not find any similar issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@omar2205 omar2205 added the good first issue Good for newcomers label Mar 2, 2023
@w3cj w3cj added this to listd media Mar 3, 2023
@w3cj w3cj moved this to Backlog in listd media Mar 3, 2023
@ostadomid
Copy link

I changed app.d.ts file content and seems it works correctly.

declare global {
	namespace App {
          // old stuff
	}
	namespace Intl {
            interface Locale {
		textInfo: {
			direction: 'rtl' | 'lrt';
		};
	}
   }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

2 participants