Skip to content

Commit 99aca45

Browse files
committed
Merge branch 'release/1.1.0'
2 parents 72883a5 + 19048c4 commit 99aca45

File tree

16 files changed

+144
-40
lines changed

16 files changed

+144
-40
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.1.0] - 2023-08-21
6+
7+
### <!-- 01 -->Features
8+
9+
- Add Light/Dark Theme Switch functionality
10+
11+
### <!-- 04 -->Refactor
12+
13+
- Implement dark mode via Tailwind CSS classes
14+
- Add index files and change functions to default exports
15+
- Add ThemeSwitcher and updated color scheme for better visibility
16+
17+
### <!-- 08 -->Miscellaneous Tasks
18+
19+
- Add `usehooks-ts` dependency to the project
20+
521
## [1.0.25] - 2023-08-19
622

723
### <!-- 07 -->Continuous Integrations

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-lingui-template",
3-
"version": "1.0.25",
3+
"version": "1.1.0",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
@@ -22,7 +22,8 @@
2222
"langs": "2.0.0",
2323
"next": "13.4.13",
2424
"react": "18.2.0",
25-
"react-dom": "18.2.0"
25+
"react-dom": "18.2.0",
26+
"usehooks-ts": "2.9.1"
2627
},
2728
"devDependencies": {
2829
"@lingui/cli": "4.4.0",

pnpm-lock.yaml

Lines changed: 24 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { default as Layout } from './layout'
2+
export { default as LocaleSwitcher } from './locale-switcher'
3+
export { default as ThemeSwitcher } from './theme-switcher'

src/components/locale-switcher.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Trans } from '@lingui/macro'
66
import clsx from 'clsx'
77
import { Fragment } from 'react'
88

9-
export function LocaleSwitcher() {
9+
export default function LocaleSwitcher() {
1010
const { changeLocale } = useLocaleSwitcher()
1111

1212
return (
@@ -15,7 +15,7 @@ export function LocaleSwitcher() {
1515
className="relative inline-block ltr:text-left rtl:text-right"
1616
>
1717
<div>
18-
<Menu.Button className="-bg-gray-800 -text-gray-400 -hover:text-white -focus:outline-none -focus:ring-2 -focus:ring-white -focus:ring-offset-2 -focus:ring-offset-gray-800 flex items-center rounded-full">
18+
<Menu.Button className="flex items-center rounded-full text-gray-900 dark:text-white">
1919
<span className="sr-only">
2020
<Trans>Open options</Trans>
2121
</span>

src/components/theme-switcher.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { MoonIcon, SunIcon } from '@heroicons/react/24/outline'
2+
import { t } from '@lingui/macro'
3+
import { useEffect, useState } from 'react'
4+
import { useIsMounted } from 'usehooks-ts'
5+
6+
enum Theme {
7+
Dark = 'dark',
8+
Light = 'light',
9+
}
10+
11+
const { Dark, Light } = Theme
12+
13+
export default function ThemeSwitcher() {
14+
const isMounted = useIsMounted()
15+
const [theme, setTheme] = useState<Theme>(Light)
16+
17+
const isDarkMode = theme === Dark
18+
19+
useEffect(() => {
20+
document.documentElement.classList.remove(Dark, Light)
21+
document.documentElement.classList.add(theme)
22+
}, [theme])
23+
24+
const toggleTheme = () => {
25+
setTheme((prevTheme) => (prevTheme === Light ? Dark : Light))
26+
}
27+
28+
if (!isMounted) return null
29+
30+
return (
31+
<div className="relative inline-block ltr:text-left rtl:text-right">
32+
<button
33+
onClick={toggleTheme}
34+
className="flex items-center rounded-full text-gray-900 dark:text-white"
35+
>
36+
{isDarkMode ? (
37+
<SunIcon className="h-7 w-7" />
38+
) : (
39+
<MoonIcon className="h-7 w-7" />
40+
)}
41+
<span className="sr-only">
42+
{isDarkMode ? t`Switch to light theme` : t`Switch to dark theme`}
43+
</span>
44+
</button>
45+
</div>
46+
)
47+
}

src/hooks/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './use-language-and-direction'
2+
export * from './use-lingui-init'
3+
export * from './use-locale'
4+
export * from './use-locale-switcher'

src/locales/ar/messages.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ msgstr "Next.js & Lingui: بناء موقع متعدد اللغات"
2525
msgid "Open options"
2626
msgstr "افتح الخيارات"
2727

28+
#: src/components/theme-switcher.tsx:42
29+
msgid "Switch to dark theme"
30+
msgstr "التبديل إلى المظهر المظلم"
31+
32+
#: src/components/theme-switcher.tsx:42
33+
msgid "Switch to light theme"
34+
msgstr "التبديل إلى المظهر الفاتح"
35+
2836
#: src/pages/[locale]/index.tsx:31
2937
msgid "Welcome to our Next.js and Lingui demo site! Discover the power of combining Next.js, a powerful React framework for building server-side rendered applications, with Lingui, the ultimate solution for multi-lingual support in your web projects."
3038
msgstr "مرحبًا بك في موقعنا التجريبي لـ Next.js و Lingui! اكتشف قوة الجمع بين Next.js، إطار عمل React القوي لبناء تطبيقات تتم رسمها من جانب الخادم، مع Lingui، الحل النهائي للدعم متعدد اللغات في مشاريع الويب الخاصة بك."

src/locales/en/messages.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ msgstr "Next.js & Lingui: Building a Multi-Lingual Website"
2525
msgid "Open options"
2626
msgstr "Open options"
2727

28+
#: src/components/theme-switcher.tsx:42
29+
msgid "Switch to dark theme"
30+
msgstr "Switch to dark theme"
31+
32+
#: src/components/theme-switcher.tsx:42
33+
msgid "Switch to light theme"
34+
msgstr "Switch to light theme"
35+
2836
#: src/pages/[locale]/index.tsx:31
2937
msgid "Welcome to our Next.js and Lingui demo site! Discover the power of combining Next.js, a powerful React framework for building server-side rendered applications, with Lingui, the ultimate solution for multi-lingual support in your web projects."
3038
msgstr "Welcome to our Next.js and Lingui demo site! Discover the power of combining Next.js, a powerful React framework for building server-side rendered applications, with Lingui, the ultimate solution for multi-lingual support in your web projects."

src/locales/fa/messages.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ msgstr "Next.js & Lingui: ساخت یک وب سایت چند زبانه"
2525
msgid "Open options"
2626
msgstr "باز کردن گزینه ها"
2727

28+
#: src/components/theme-switcher.tsx:42
29+
msgid "Switch to dark theme"
30+
msgstr "تغییر به تم تاریک"
31+
32+
#: src/components/theme-switcher.tsx:42
33+
msgid "Switch to light theme"
34+
msgstr "تغییر به تم روشن"
35+
2836
#: src/pages/[locale]/index.tsx:31
2937
msgid "Welcome to our Next.js and Lingui demo site! Discover the power of combining Next.js, a powerful React framework for building server-side rendered applications, with Lingui, the ultimate solution for multi-lingual support in your web projects."
3038
msgstr "به سایت دمو Next.js و Lingui ما خوش آمدید! قدرت ترکیب Next.js، یک فریم‌ورک React قدرتمند برای ساخت برنامه های رندر شده در سمت سرور، با Lingui، راه حل نهایی برای پشتیبانی چند زبانه در پروژه های وب خود را کشف کنید."

0 commit comments

Comments
 (0)