Skip to content

Commit

Permalink
Added useHtmlLang hook
Browse files Browse the repository at this point in the history
  • Loading branch information
boutmansb committed Dec 6, 2024
1 parent 836fe22 commit 7ebb14a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 20 deletions.
29 changes: 15 additions & 14 deletions build/index.cjs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion build/index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ declare class CookieStorage implements Storage {

declare function useDocumentTitle(title: string): void;

declare function useHtmlLang(lang: string): void;

declare function useIcoFavicon(ico: string): void;

declare function useSvgFavicon(svg: string | SVGElement): void;
Expand Down Expand Up @@ -122,4 +124,4 @@ declare class BrowserAccessibilityPreferences {

declare const useBrowserAccessibilityPreferences: () => BrowserAccessibilityPreferences;

export { BrowserAccessibilityPreferences, CookieStorage, type ScrollState, type ScrollToArgs, useAppleTouchFavicon, useBrowserAccessibilityPreferences, useCopyToClipboard, useDebounce, useDocumentTitle, useEventListener, useGeolocation, useHover, useIcoFavicon, useIdle, useLockBodyScroll, useLongPress, useMeasure, useMediaQuery, useOnScreen, usePrefersDarkMode, usePrefersHighContast, usePrefersLowContrast, usePrefersReducedMotion, usePrefersReducedTransparancy, useScript, useStorage, useSvgFavicon, useThrottle, useViewportSize, useVisibilityChange, useWindowScroll };
export { BrowserAccessibilityPreferences, CookieStorage, type ScrollState, type ScrollToArgs, useAppleTouchFavicon, useBrowserAccessibilityPreferences, useCopyToClipboard, useDebounce, useDocumentTitle, useEventListener, useGeolocation, useHover, useHtmlLang, useIcoFavicon, useIdle, useLockBodyScroll, useLongPress, useMeasure, useMediaQuery, useOnScreen, usePrefersDarkMode, usePrefersHighContast, usePrefersLowContrast, usePrefersReducedMotion, usePrefersReducedTransparancy, useScript, useStorage, useSvgFavicon, useThrottle, useViewportSize, useVisibilityChange, useWindowScroll };
4 changes: 3 additions & 1 deletion build/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ declare class CookieStorage implements Storage {

declare function useDocumentTitle(title: string): void;

declare function useHtmlLang(lang: string): void;

declare function useIcoFavicon(ico: string): void;

declare function useSvgFavicon(svg: string | SVGElement): void;
Expand Down Expand Up @@ -122,4 +124,4 @@ declare class BrowserAccessibilityPreferences {

declare const useBrowserAccessibilityPreferences: () => BrowserAccessibilityPreferences;

export { BrowserAccessibilityPreferences, CookieStorage, type ScrollState, type ScrollToArgs, useAppleTouchFavicon, useBrowserAccessibilityPreferences, useCopyToClipboard, useDebounce, useDocumentTitle, useEventListener, useGeolocation, useHover, useIcoFavicon, useIdle, useLockBodyScroll, useLongPress, useMeasure, useMediaQuery, useOnScreen, usePrefersDarkMode, usePrefersHighContast, usePrefersLowContrast, usePrefersReducedMotion, usePrefersReducedTransparancy, useScript, useStorage, useSvgFavicon, useThrottle, useViewportSize, useVisibilityChange, useWindowScroll };
export { BrowserAccessibilityPreferences, CookieStorage, type ScrollState, type ScrollToArgs, useAppleTouchFavicon, useBrowserAccessibilityPreferences, useCopyToClipboard, useDebounce, useDocumentTitle, useEventListener, useGeolocation, useHover, useHtmlLang, useIcoFavicon, useIdle, useLockBodyScroll, useLongPress, useMeasure, useMediaQuery, useOnScreen, usePrefersDarkMode, usePrefersHighContast, usePrefersLowContrast, usePrefersReducedMotion, usePrefersReducedTransparancy, useScript, useStorage, useSvgFavicon, useThrottle, useViewportSize, useVisibilityChange, useWindowScroll };
6 changes: 3 additions & 3 deletions build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tactics/browser",
"version": "0.0.6",
"version": "0.0.7",
"description": "Utilities to help ease use of the web browser in javascript",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down
7 changes: 7 additions & 0 deletions src/hooks/use-html-lang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";

export function useHtmlLang(lang: string) {
React.useEffect(() => {
document.documentElement.lang = lang;
}, [lang]);
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export { useEventListener } from "@/hooks/use-event-listener";
export { CookieStorage } from "@/storage/cookie";

export { useDocumentTitle } from "@/hooks/use-document-title";
export { useHtmlLang } from "@/hooks/use-html-lang";
export { useIcoFavicon } from "@/hooks/use-ico-favicon";
export { useSvgFavicon } from "@/hooks/use-svg-favicon";
export { useAppleTouchFavicon } from "@/hooks/use-apple-touch-favicon";
Expand Down

0 comments on commit 7ebb14a

Please sign in to comment.