-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ede222
commit 991ac03
Showing
11 changed files
with
169 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createContext, ReactNode, useContext } from 'react'; | ||
|
||
type LocaleContext = { | ||
locales: string[]; | ||
}; | ||
|
||
type LocaleContextProviderProps = { | ||
locales: string[]; | ||
children: ReactNode; | ||
}; | ||
|
||
const Context = createContext<LocaleContext | null>(null); | ||
|
||
export const LocaleContextProvider = ({ | ||
locales, | ||
children, | ||
}: LocaleContextProviderProps) => { | ||
const value = { locales }; | ||
return <Context.Provider value={value}>{children}</Context.Provider>; | ||
}; | ||
|
||
const throwIfNoProvider = () => { | ||
throw new Error('Please wrap your application in a LocaleContextProvider.'); | ||
}; | ||
|
||
export const useLocales = () => { | ||
const { locales } = useContext(Context) ?? throwIfNoProvider(); | ||
return locales; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useLocales } from '../providers/locale'; | ||
|
||
type IntlDateProps = { | ||
date: string; | ||
timeZone?: string; | ||
}; | ||
|
||
export const RenderDate = ({ date, timeZone }: IntlDateProps) => { | ||
const dateFromString = new Date(date); | ||
|
||
const locales = useLocales(); | ||
const isoString = dateFromString.toISOString(); | ||
const formattedDate = new Intl.DateTimeFormat(locales, { | ||
year: 'numeric', | ||
month: 'short', | ||
day: 'numeric', | ||
timeZone, | ||
}).format(dateFromString); | ||
|
||
return <time dateTime={isoString}>{formattedDate}</time>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { RemixBrowser } from '@remix-run/react'; | ||
import { startTransition, StrictMode, useEffect } from 'react'; | ||
import { startTransition, StrictMode } from 'react'; | ||
import { hydrateRoot } from 'react-dom/client'; | ||
|
||
import { LocaleContextProvider } from './components/providers/locale'; | ||
|
||
const locales = window.navigator.languages; | ||
|
||
startTransition(() => { | ||
hydrateRoot( | ||
document, | ||
<StrictMode> | ||
<RemixBrowser /> | ||
<LocaleContextProvider locales={locales}> | ||
<RemixBrowser /> | ||
</LocaleContextProvider> | ||
</StrictMode> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
a:not(.title) { | ||
font-weight: 700; | ||
-webkit-text-decoration: underline; | ||
text-decoration: underline; | ||
text-decoration-color: #207DE9; | ||
text-decoration-thickness: 1px; | ||
text-decoration-skip-ink: none; | ||
text-underline-offset: 0.25em; | ||
} | ||
|
||
a:not(.title):hover { | ||
text-decoration-color: currentcolor; | ||
text-decoration-thickness: 2px; | ||
color: #207DE9; | ||
} | ||
|
||
a.title:hover { | ||
text-decoration-color: currentcolor; | ||
text-decoration-thickness: 2px; | ||
color: #207DE9; | ||
-webkit-text-decoration: underline; | ||
text-decoration: underline; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.